Posts

Showing posts from January, 2014

c++ - Calculating used memory by a set of processes on Linux -

i'm having trouble calculating used memory (resident) set of processes. the issue came user set of processes share memory between themselves, simple addition of used memory ends nonsense number (>60gb when machine has 48gb memory). is there simple way approach problem? i can approximation. take (res mem - shared mem) * num proc + shared mem . not processes share same memory block. i'm looking posix or linux solution problem c/c++. you want iterate through each processes /proc/[pid]/smaps it contain entry each vm mapping of likes: 7ffffffe7000-7ffffffff000 rw-p 00000000 00:00 0 [stack] size: 100 kb rss: 20 kb pss: 20 kb shared_clean: 0 kb shared_dirty: 0 kb private_clean: 0 kb private_dirty: 20 kb referenced: 20 kb anonymous: 20 kb anonhugepages: 0 kb swap: 0 kb kernelpagesize: 4 kb mmupagesize...

php - How can I 301 Redirect and Change Url with .htaccess? -

i discovered have duplicate pages need remove pages should not exist indexed , generating small amounts of traffic. want redirect urls original ones. http://www.example.com/buy-something.php to http://www.example.com/something.php i need remove "buy-" in urls , make sure page redirected proper page. here have far: #301 redirect buy- none rewriterule ^([a-za-z\.]+).php$ /buy-$1.php [l,r=301] but nothing pages should redirected , adds loop of buy-buy-buy-buy-buy-buy- other pages , causes them time out. have tried few other variations no prevail. your appreciated. you mixed syntax, right redirecting .php /buy- .php, since want other way arround try: redirectrule ^buy-([a-za-z\.]+).php$ /$1.php [l,r=301] that should take buy-*.php domains , redirect them *.php code 301. source: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

python - wait for button click on button click move button to a slot in tkinter -

i title wasn't best don't quite know how explain it. tkinter want make square widgets "slots on them. when app run want buttons show @ top of screen , 4x4 grid of square widgets. app wait user click on button. button should move top left slot on top left square. after done user should repeat process , next button should go next slot on top left square , on until square full, repeat process next square. should fixed position button allows me pass on slot without putting things in it? how should accomplish this? have loop need: elem in zip(*l): in elem: print(a) i'm not entirely sure if understand problem correctly, looks @ core, you're trying reposition tkinter widgets, correct? you can geometry manager. if use grid method (which in case recommend) can do: def changebuttonpostion(): button2.grid_remove() #gets rid of widget in top left corner button.grid(row=0, column=1) #the top left corner of 4x4 grid otherwise, can use p...

c++ - Start Debugging session in NetBeans -

i trying familiar netbeans debugging environment, c/c++ applications. followed procedures on https://netbeans.org/kb/docs/cnd/debugging.html every time want start debugging : debug>debug project ctrl+f5 , bothering error this: gdb has unexpectedly stopped return -1,073,741,515 any idea should ?! thanks

java - wowza onAppStart method call -

i try build module wowza 3.6.2 . module needs instance of iapplicationidstance , samples found in onappstart method, not called when access wowza application. i have following: public class testmodule extends modulebase { public void onappstart(iapplicationinstance appinstance) { string fullname = appinstance.getapplication().getname() + "/" + appinstance.getname(); getlogger().info("onappstart: " + fullname); } public void onappstop(iapplicationinstance appinstance) { string fullname = appinstance.getapplication().getname() + "/" + appinstance.getname(); getlogger().info("onappstop: " + fullname); } .... } application configuration: <module> <name>testmodule</name> <description>mytestmodule</description> <class>mnesterenko.testmodule</class> </module> also have applicati...

vim - how to compile cscope with quickfix -

in .vimrc , added set cscopequickfix=s-,c-,d-,i-,t-,e- ,but when use cscope command in vim, quick window not appear automatically. i read doc vim cscope, , tell me use "cscopequickfix=s-,c-,d-,i-,t-,e-" have compile cscope +quickfix feature. now question how compile cscope +quickfix feathre

objective c - ARC and UIView instance variables -

if have uiview instance variable add view subview; does calling removefromsuperview dealloc instance variable when using arc? or can add again different view? if have strong pointer view you're adding/removing, calling removefromsupeview not cause object deallocated. can have strong pointer either declaring uiview ivar, or declaring strong property (preferred). however, if have no other strong pointer view, deallocated arc if remove superview. (the superview keeping strong pointer, , breaking connection.)

java - onCreateOptionsMenu compile error -

i tried use oncreateoptionsmenu in application. followed developers blog , didn't work of me. when use code: @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu items use in action bar menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.homepage_actionbar, menu); return super.oncreateoptionsmenu(menu); } i got compile errors: multiple markers @ line - syntax error on token ")", ; expected - illegal modifier parameter oncreateoptionsmenu; final permitted - syntax error on token "(", ; expected multiple markers @ line - void methods cannot return value my xml file: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/add_option" android:title="add item" andr...

svg - Move Raphael path with png fill image, without breaking image in IE or moving image relative to element? -

there 3 basic ways move path in raphael. if path has fill image has png transparency, , need ie8 (vml), 3 flawed. jsbin demo if use simple transform... path1.animate({transform: 't20,100'},1000); ...then in ie8, png transparency in fill breaks , translucent pixels turn black . edges become pixelated , ugly, , depending on image might scuffy black outline around translucent edge of image. not good, , there doesn't seem reliable way fix after event. sometimes, inconsistently, background image doesn't stay relative element (more on below). if animate path attribute, example this: path2.animate({path: raphael.transformpath( path2.attr('path'), 't100,20') },1000); ...ie8 doesn't wreck image background. however, fix making background images relative element not paper not work method (and various ways i've tried bodge using improved background image offset additional "m-20,-20" element don't seem work), , can...

ios - UIViewController lifecycle calls in combination with state restoration -

i'm trying implement state restoration in app uses ios 6+ , storyboards, having problems finding way prevent duplicate calls heavy methods. if start app, need setup ui in viewdidload : - (void)viewdidload { [super viewdidload]; [self setupui]; } this works fine in normal, non-state-restoration world. i've added state restoration , after restoring properties need update ui properties: - (void)decoderestorablestatewithcoder:(nscoder *)coder { [super decoderestorablestatewithcoder:coder]; // restore properties , stuff // [...] [self setupui]; } so happens first setupui method called viewdidload , , again decoderestorablestatewithcoder: . don't see method can override that's called last. this normal order of method calls: awakefromnib viewdidload viewwillappear viewdidappear when using state restoration, called: awakefromnib viewdidload decoderestorablestatewithcoder viewwillappear viewdidappear i can't place c...

soa - Communicating between Servers using Websockets -

so let's in service oriented architecture, have 3 layers: the web/external layer - user sees application logic - generates layer 3. handles users, sessions, forms & etc... internal api - data, , how access data now 1 , 2 live in same network latency our least thought of problem. essentially, layer 2 consumes data layer 1 using rest. thinking of alternatives how data can consumed. what pros , cons of making layer 1 , 2 communicate websockets instead of rest? assuming, have multiple servers , layer 2 applications. this question purely out of curiosity. there old discussion on restfull http vs websockets. think of them being different. in general, websockets give finer control. comes perhaps more efficiency --imagine if you, say, define own protocol. downside have less standard approach. rest less flexible more standard , more loosely coupled. stefan tilkov summarized pretty in blog post . there related discussion here .

.net - OutOfMemoryException even when app doesn't seem to consume max amount of memory -

Image
i developing .net based application (.net 4) crashes after running time on system.outofmemoryexception when examining app's process in task manager or attempted use other tools such clr profiler , ants memory profiler, doesn't seem application maxing out on available ram or other limit may (i believe windows has limit per process .net limited in way). here's screenshot ants profiler time shortly before crash. total amount of unamanged memory (in case it's not seen in image ~ 285 mb, , total size of objects in heaps ~76mb) i checked "handles" count in taskmgr, looks around ~8120 handles app's process @ time of crash. how can further examine going on? possible causes can cause such exception? it's image (bitmap). not "very large" in size (around 50kb). can underlying native exception in disguise? (like coming gdi) yes, cause. gdi throws outofmemoryexception s when there error has nothing related memory consumption...

android - How to test localized prices with In-app billing v3 -

my app displays prices reported getskudetails() api. confirm working i'd setup device display prices different locales. i've tried logging in google accounts different countries , setting system language prices still appear in own locale. how can setup device can see prices reported in different locales? i guess that's not easy. in case experienced same issue. according information read, looks there several procedures google uses locate user. 1 of them consist of check procedence of credit card registered in google play, if users has one. if case, shown prices of locale corresponding credit card. second check, made thru sim card of mobile phone. if don't have sim card or device tablet without sim card, next step looking wifi connection. localization of wifi spot, , ipaddress, used geolocate user. finally if nothing of works, locale settings in device used. in way, google show prices according place are, couldn't match locale settings in device....

performance - The uncertainty principle of computer science -

when work on algorithm solve computing problem, experience speed can increased using more memory, , memory usage can decreased @ price of increased running time, but can never force product of running time , consumed memory below palpable limit . formally similar heisenberg's uncertainty principle: product of uncertainty in position , uncertainty in momentum of particle cannot less given threshold. is there theorem of computer science, asserts same thing? guess should possible derive similar theory of turing machines. i not familiar description of parallels heisenberg's uncertainty principle, per se , sounds me closely related computational complexity theory . problems can classified according inherent, irreducible complexity, , think that's you're getting @ limit of "the product of running time , consumed memory".

graph - Recreate plot in MATLAB using figure handle -

is there anyway create same plot twice saving type of axis handle? my plotting code creates special symbols each point in scatter plot. want create figure 2 subplots. first plot want set specific part of axis (0 10), second plot want (90:100). know recreate plot copy , pasting code, seems cumbersome , hassle manage if change else plots. is there anyway can create plot once, save handle , replot it? here functionality looking for: figure; hold on; x = [1 10 20 10 2000 3000]; y = [10 30 40 20 100 200 ]; // create plot 1 point @ time = 1:4 subplot(2,1,1); plot(x(i),y(i),'r'); // redacted code // there bunch of code here adjust of first plot each point // in order define of each marker in scatter plot, // has done 1 point @ time // redacted code end // adjust axis axis([1 60 0 50]); // figure handle handle = gcf; // create second plot same characteristics first plot different axis boundaries subplot(2,1,2); plot(handle); axis([90 250 1000 4000]); ...

c++ - Merge Sort and Queue -

im working on review sheet pretty got except not sure these two. please? q benefit of using queue merge sort? q suppose in mergesort replace queue stack (i.e. push instead of enqueue, pop in place of dequeue). explain effect replacement have. with queues things automatically added end of list; thus, when lowest level of mergesort 's recursion (individual elements), sorted array can enqueue largest of these elements new list. using stack should reverse list since elements added put @ front, you'd have search smallest element instead of largest.

jQuery Mobile doesn't load on JSON ajax result -

i'm trying load jquery mobile 'styles' (in case buttons). here html code (ajax): <!-- jquery + mobile (local) --> <link rel="stylesheet" href="../../jquery.mobile/jquery.mobile-1.3.2.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.js"></script> <script src="../../jquery.mobile/jquery.mobile-1.3.2.min.js"></script> <script> $.ajax({ type : "get", url : "http://localhost/asistencia/mant/scripts/s_m_zona.php?id_zona="+id_zona, async : true, success : function(datos) { var datajson = eval(datos); ( in datajson) { // code hede // guardar nombre zona $("#btn_guardar").html("<button data-ajax='false' onclick='guardarnombrezona("+datajson[i].id_zona+...

javascript - Jquery.Validate not working for file upload -

i'm using jquery validation in asp.net mvc project. working textbox . not work file upload. code shown below: @model ffyazilim.management.model.credential.createmodel @{ viewbag.title = "create"; layout = "~/areas/management/views/_managementlayout.cshtml"; } @section scripts { <script type="text/javascript"> $(function () { $('#form').validate({ rules: { title: { required: true, maxlength: 45, minlength: 5 }, description: { required: true, maxlength: 250, minlength: 5 }, order: { required: true, maxlength: 10, minlength: 1 }, fileinput: { required: true } ...

PHP: check if an element belongs to an array -

i know php 4 , php 5 supports built in function in_array determining element in array or not. but, using prior version of php reason , wanted know alternative it. use custom function. future compatibility, use function_exists check if current version of php you're using indeed have in_array . function inarray($needle, $haystack) { if (function_exists('in_array')) { return in_array($needle, $haystack); } else { foreach ($haystack $e) { if ($e === $needle) { return true; } } return false; } }

excel - Removing duplicates from large sheet -

i want remove rows based on duplicate cells in column large sheet, without leaving duplicate sample (like "remove duplicates" excel command does). if have: 1 2 2 3 i want, result: 1 3 this can accomplished conditional formatting, filtering or sorting duplicates , deleting filtered data, process slow large sheet. conditional formatting takes second, clicking on filter takes around 5min display filter context menu , additional 20-30min actual filtering based on color. tried process on different pcs 4 cores , plenty of ram , 100.000 rows sheet i thought write vba, iterate column cells , if cell colored, delete entire row (this possible in excel 2010, cells().displayformat ) processing takes more time. can suggest faster way remove duplicates on large sheet? edit: note have used 2 functions. of this, test function test whether function works (which have modify per scenario). also, filled cell a1 a100000 test values. please modify per needs. option e...

java - Syntax of Serializing a LinkedList<Object> -

as exercise, creating list of books linkedlist , using comparator interface sort them author or title. first, create class of books , ensure print screen way want to: class book { string title; string author; public book(string t, string a){ title = t; author = a; } public string tostring(){ return title + "\t" + author; } } next, created linkedlist takes object book: linkedlist<book> booklist = new linkedlist<>(); a class implements comparator created sorts according title/author , displays them on jtextarea inside of main frame. of working fine, there's 1 glaring bug...i cannot save file! i've tried class implements serializable takes linkedlist argument , writes .obj file. when load it, fails. creates file, notserializableexception. tried saving file .ser told make easier save it, failed on loading, well. does know method serializing linkedlist using bufferedreader? or there approach this? ...

selenium - PHP Webdriver - target pages don't load in browser -

new selenium 2. here's issue: each time run test, browser opens refuses load urls. blank page. here's example using Łukasz kolczyński's bindings: require_once "phpwebdriver/webdriver.php"; $webdriver = new webdriver("localhost", "4444"); $webdriver->connect("chrome"); $webdriver->get("http://google.com"); $element = $webdriver->findelementby(locatorstrategy::name, "q"); if ($element) { $element->sendkeys(array("php webdriver" ) ); $element->submit(); } $webdriver->close(); i "data:text/html;charset=utf-8," in address bar. script closes. i'm sure i'm doing wrong. appreciated. notes: i'm running chromedriver, chrome 28, php 5.4.9, , openjdk 64-bit server vm (build 23.7-b01, mixed mode) i had same problem. not work , opted use facebook version of web driver. just make sure using latest version of php otherwis...

sql server - Java/.NET Developer moving towards Data Warehouse -

i understand concept of data warehouse after reading questions this: what data warehouse? . familiar olap , mdx (mdx limited extent). i have .net application connects fifteen different databases search information , manage information i.e. java application connects fifteen databases oracle/sql based. believe data warehouse meet needs. have 2 questions data warehouses: do copy data needed make decision data warehouse (using ssis) or leave in oltp systems , query or bit of both? what use user interface? java app/vb.net perhaps a data warehouse reformatted version of transactional database intended fast access, providing business insight end users (technical , non-technical). example, datawarehouse in kimball model denormalized (think tall , skinny) version of transaction database in star schema. data taken oltp database, goes through etl process (extract, transform, load), , made available business users (for end-user ui querying la business objects, example). ...

internet explorer 10 - Canvas.toDataURL() working in all browsers except IE10 -

i'm working on project uses canvas automatically crop image, return data url. uses images external server, has appropriate cors headers allow images converted data uris after cropped though cross-origin. the code works (and without security errors!) in browsers except ie 10, in throws 'script5022: securityerror' when canvas.todataurl() called. is bug in ie or need differently in code make work in idiot exploder? thanks. -scott edit here (most of) code i'm using create , draw canvas; var canvas = document.createelement('canvas'); var ctx = canvas.getcontext('2d'); var img = new image(); img.src = imageserverurl + '?id=' + imageidtoget; // imageserverurl points different domain server has headers allowing requests domain /* code here defines cropping area, in variables ulx, lry, etc. */ ctx.beginpath(); ctx.moveto(ulx, uly); ctx.lineto(urx, ury); ctx.lineto(lrx, lry); ctx.lineto(llx, lly); ctx.closepath(); ctx.clip(); ctx.drawimage...

netbeans - "Simply" determining Java Radio Button id -

i'm hoping java not in-elegant efforts lead me believe. i working jradiobuttons, , want programmatically determine "id" associated them. this, trying read "name" listed in netbeans properties. in ide, when right-click component, given option of "change variable name..." use set values such rb1, rb2, etc. but in properties panel, there "name" entry can set different value. use set "id"-s such 1, 2, etc. working radio buttons, know can have series of if-statements that, in handler, ask object src = evt.getsource(); int val=-1; if (src == rb1) { val=1; } else if (src == rb2) { val=2; } else if (src == rb3) { val=3; } else { val=4; } but, besides requiring me hard code id value control name myself, i'm prone make transcription error, want believe there simpler single-statement means achieve this, like: string name = rbgroup.getselection().getname(); .get...

Map a page to a subdomain in wordpress -

i'm trying map specific page subdomain in wordpress. for example, have wordpress page: www.mysite.com/mypage i want when enters mypage.mysite.com content of www.mysite.com/mypage shows (not redirect). can't find way this. i've tried rewrite rules in .htaccess file no luck. i tried this: rewritecond %{http_host} mypage.mysite.com rewriterule ^(.*)$ http://mysite.com/mypage$1 [r=301,l] but redirects instead of invisible showing content of page. is possible achieve subdomain? i've tried solutions i've found here no luck. many thanks. [r] @ way. [r=301,l] means redirect permanent new location. try using reverse proxy rewritecond %{http_host} mypage.mysite.com rewriterule ^(.*)$ http://mysite.com/mypage$1 [p]

Use jquery to put sub menus in new div -

i have menu sub menus. want use jquery move sub menus (unordered lists) expanding div. example, have menu looks this: <ul id="menu"> <li> <ul class="sub-menu">...</ul> </li> <li> <ul class="sub-menu">...</ul> </li> <li> <ul class="sub-menu">...</ul> </li> </ul> and each .sub-menu moved containing div below. able 1 .sub-menu with: var put = jquery( ".sub-menu").html(); jquery('#nav-expand').html(put); but each one. tried using .each() either using incorrectly or need solution. you should use appendto method in jquery move element http://api.jquery.com/appendto/ $( ".sub-menu" ).appendto( "#nav-expand" ); http://jsfiddle.net/qtwbb/

How to rollback one particular commit in Git? -

here's situation: about 10 commits ago, accidentally did bad commit. switching between unix/windows, , long story short, did commit every file changed, due line endings. i had done 10 commits after that. i realize in order push remote repository, need undo commit step (1) (there's setting in .gitattributes i've modified normalize). how go point in time , not commit every file? , need re-commit other 9 changes after that? if haven't pushed 10 commits yet, or remote repo private , not shared other people, can try using interactive rebase: $ git rebase -i head~10 # go 10 commits in time. in todo list of commits, choose edit 1 @ top of list: edit d6627aa commit message 1 pick 0efdaca commit message 2 pick 9ec752f commit message 3 pick c84bf57 commit message 4 pick d4bcd50 commit message 5 pick c0110c9 commit message 6 pick 6606d13 commit message 7 pick 22933be commit message 8 pick cab2453 commit message 9 pick 05add41 commit message 10 then a...

Git how do i rebase out certain commits? -

here tree: c (featureb) | | - h (master) | | |- h - d (featurea) i make become c - d (featureb) | | - h (master) | | |- h - d (featurea) how do in git? you can cherry-pick d onto featureb : $ git checkout featureb $ git cherry-pick d

opengl - Spot light effect does not work correctly using GLSL shaders -

Image
i'm working on personal graphic engine , started develop spot lights. problem rendering not logical. sake of simplicity cleaned informations light , texture managing inside shaders example below. here's vertex shader code : #version 400 layout (location = 0) in vec3 vertexposition; uniform mat4 modelviewmatrix; uniform mat4 mvp; out vec3 vposition; void main(void) { vposition = vec3(modelviewmatrix * vec4(vertexposition, 1.0f)); //eye coordinates vertex position gl_position = mvp * vec4(vertexposition, 1.0f); } and fragment shader code : #version 400 in vec3 position; //in eye coordinates layout (location = 0) out vec4 fragcolor; uniform int lightcount; struct spotlight { vec4 position; //already in eye coordinates vec3 la, ld, ls; vec3 direction; float exponent; float cutoff; }; uniform spotlight lightinfos[1]; vec3 getlightintensity(void) { vec3 lightintensity = vec3(0.0f); (int idx = 0; idx < lightcount...

Duplicity backup script for S3 fails on CentOS 5 -

hi have not been able setup backup s3 using guide: http://www.cenolan.com/2008/12/how-to-incremental-daily-backups-amazon-s3-duplicity/ i error when run script: command line error: expected 2 args, got 0 enter 'duplicity --help' screen. the duplicity log file: 2013-08-07_17:43:20: ... backing filesystem ./duplicity-backup: line 60: --include=/home: no such file or directory my script this: !/bin/bash # set variables logging logfile="/var/log/backup.log" dailylogfile="/var/log/backup.daily.log" host='hostname' date=`date +%y-%m-%d` mailaddr="user@domain.com" # clear old daily log file cat /dev/null > ${dailylogfile} # trace function logging, don't change trace () { stamp=`date +%y-%m-%d_%h:%m:%s` echo "$stamp: $*" >> ${dailylogfile} } # export env variables don't have type export aws_access_key_id="xxxxx" export aws_secret_access_key="xxx" export p...

c# - how to load a datagridview with my data from xml -

i have xml: <container_1 attr1="..." attr2="..." attr3="..."> <rekord_1> <type_1 attr1="..." attr2="..." ... /> <type_2 attr1="..." attr2="..." ... /> </rekord_1> <rekord_2>... </rekord_2> . . <rekord_n> ... </rekord_n> </container_1> i can parse way want , show in console app (using xmlelements , xmlnodelists , few loops) want make app gui , table view. form app read xml, can handle 1 tag right now. example, if container_1 tag, outputs container_1 's attributes itself, want show records under container_1 in table view also. i want make view-able older program in console. how can out data xml able work elements/attributes? because want set place in table view. documentation should read? or there example useful me? edited(aug. 20): here main part of code: private void button1_click(object sender, eventargs e) {...

javascript - jquery delay/animate start bugging after some time and overlapping -

i got work on piece of jquery code runs simple slider of 3 images, shows , hides them 1 one, , should repeat process indefinitely. here code: $(document).ready(function () { function start_slider() { $('#slider_img_1').animate({ top: '-=495' }, 1000).delay(4000).animate({ top: '+=495' }, 1000); $('#slider_img_2').delay(6000).animate({ top: '-=495' }, 1000).delay(4000).animate({ top: '+=495' }, 1000); $('#slider_img_3').delay(12000).animate({ top: '-=495' }, 1000).delay(4000).animate({ top: '+=495' }, 1000); settimeout(function () { start_slider(); }, 18000); } start_slider(); }); now far understand this, animates first picture 1s, holds 4s , animates 1s. same other 2. math fits in? last 18s in total , starts again. proble...

c# - Renaming a Field name by accepting values from textboxes...It shows "Unclosed quotation mark after the character string '' -

i using text boxes, textbox1 accepts value existing field , textbox2 accepts new field name. when click on button, corresponding field name entered in textbox1 in d/b should change entered in textbox2. protected void button1_click(object sender, eventargs e) { //str = "sp_rename 'book.author','au_name','column'"; str = "sp_rename 'book.'" + textbox1.text + "','" + textbox2.text + "','column'"; sqlconnection con = new sqlconnection("data source=.;initial catalog= library;integrated security=true"); con.open(); sqlcommand cmd = new sqlcommand(str, con); sqldatareader dr = cmd.executereader(); //("select * imslogin uname = '" + uname + "' , pwd= '" + pwd + "'", con) } thanks much, thanks in advance!! the first , obvious problem user input sent directly db. the second problem, may s...

facebook - How does an iOS app keep a FBSession from expiring? -

i have read fbsession automatically renews/refreshes it's token, looking through sdk time seems extend life of token when session open request returns new token expiration. will session/token renewed result of other actions? edit: in 'facebook' class there 'extendaccesstoken' method following comment: /** * attempt extend access token. * * access tokens typically expire within 30-60 days. when user uses * app, app should periodically try obtain new access token. once * access token has expired, app can no longer renew it. app has * ask user re-authorize obtain new access token. * * ensure app has fresh access token active users, it's * recommended call extendaccesstokenifneeded in application's * applicationdidbecomeactive: uiapplicationdelegate method. */ but method seems separate fbsession. by using fbsession token, token extended automatically newest sdk: https://github.com/facebook/facebook-ios-sdk/blob/master/src/fbsessi...

php echo different content on different dates -

i using date format echo example: thursday 8th august 2013 $day = date("l js f y"); i echo different content on different dates for example if wednesday 25th december 2013 can echo "merry christmas" this have tried, time format (y-m-d = 2013-25-12) have tried adding wednesday 25th december 2013. what date format should $day = if im using $day = date("l js f y"); <p><?php if( $day == '2013-25-12' ) echo 'action="merry christmas"'; ?></p> use strtotime() , date() formatted date compare $day: <?php if( $day === date("l js f y", strtotime('2013-25-12'))) { echo 'merry christmas!'; } ?> check out php documentation on date function. includes formatting specifications: http://php.net/manual/en/function.date.php

c# - How to Invoke the overloaded method in place of actual method -

i have mocking.sln has 2 projects: student (class library) , studentstat (console application) student project has below details: private static dictionary<int, int> getstudentdata() { // key: student id value: total marks(marks in math + marks in physics) dictionary<int, int> studentresultdict = new dictionary<int, int>(); using (sqlconnection con = new sqlconnection("data source=.;initial catalog=mydb;integrated security=true")) { con.open(); string cmdstr = "select * student"; using (sqlcommand cmd = new sqlcommand(cmdstr, con)) { using (sqldatareader reader = cmd.executereader()) { while (reader.read()) { studentresultdict.add((int)reader["id"], (int)reader["marksinmath"] + (i...

jquery - Append Button into a collapsible content -

i trying append button collapsible content not showing normal button. demo: http://jsfiddle.net/76buh/1/ how make button proper jquery mobile button? $('#eventlist').listview('refresh'); $('#ev2').empty(); $('#ev2').append('<button id="settotrue">more events</button>'); just let application know created element triggering event, , framework rest: $('#ev2').append('<button id="settotrue">more events</button>').trigger('create');

python - How can I match input in a case insensitive manner? -

i making mud, or sud can call (singleplayer) way navigate through game type commands. def level_01_room_01(): choice = raw_input('>: ') if choice == 'north': level_01_room_02() in case, if user enters north, capital n, code not perceive command. big mess if have enter: def level_01_room_01(): choice = raw_input('>: ') if choice == 'north': level_01_room_02() if choice == 'north': level_01_room_02() if choice == 'north': level_01_room_02() etc. is there way can fix this, player can type word or wants to? always lower() user input before comparing against known strings (and use lower case). if choice.lower() =='north': ...

mysql type varchar versus text and blob -

i have form has text area in it. user types comment , gets inserted database. problem arises when comment has apostrophe in it...when go retrieve comment , display on screen apostrophe doesn't show up, , seems transformed weird character. need choose mysql data type (varchar, text, blob) avoid this? the easiest way fix problem can encode data before store them database, after encoding, there no special character, , when retrieve it, can decode, such urlencode ,urldecode. hope helps!

vb.net - VB .net Context/ToolStripMenu at runtime -

i have contextmenu in this picture. want add says ".rtf" more menuitems @ runtime. cant seem make it... dim mycontextmenu contextmenustrip = form1.mnuoptions dim mymenuitem toolstripmenuitem = mycontextmenu.items("sendto") dim mysubmenuitem new toolstripmenuitem = mymenuitem.dropdownitems("file").subitems this how imagine doing it, not work of course because there no ".subitems". take accomplish such easy job? and how can set addhandlers each subitem procedure? assuming 'file' name of menu item text, can access directly it's name, , add dropdown item collection: file.dropdownitems.add("pdf") one of add overloads allows indicate event handler click fire.

ruby on rails - How to pass parameters through link_to and have them as preset values in a form_for? -

i beginner rails , appreciate guidance! here link_to in first view: <%= link_to micropost.user.name, micropost.user %> | <%= link_to "send message", new_conversation_path( target: micropost.user.name, reason: micropost.c1 ) %> and here conversations controller: def new @target = params[:target] @reason = params[:reason] end def create recipient_names = conversation_params(:recipients).split(',') recipients = user.where(name: recipient_names).all conversation = current_user. send_message(recipients, *conversation_params(:body, :subject)).conversation redirect_to conversation end as can see, i'm using mailboxer gem not have conversation model. finally, here form in second view: <%= simple_form_for :conversation, url: :conversations |f| %> <%= f.input :recipients, @target %> <%= f.input :subject, @reason %> <%= f.input :body %> <div class="form-actions">...

Gdb Pretty Printer: *(char*){hex_address} equivalent in python -

i have c++ classes in following format (copying important parts): class my_stringimpl { public: static sample_string* create(const char* str, int len) { my_stringimpl* sample = static_cast<my_stringimpl*>(malloc(sizeof(my_stringimpl) + len*sizeof(char))); char* data_ptr = reinterpret_cast<char*>(sample+1); memset(data_ptr, 0, len); memcpy(data_ptr, str, len); return new (sample) my_stringimpl(len); } private: int m_length; }; class my_string { public: my_string(const char* str, int len) : m_impl(my_stringimpl::create(str, len)) { } ~my_string() { delete m_impl; } private: my_stringimpl* m_impl; }; for my_string class adding pretty printer. added following defs in python script (which including in .gdbinit file) - func defs copied here: def string_to_char(ptr, length=none): error_message = '' if length none: length = int(0) error_message = 'null string' else: ...

regex - Could anyone give an explain on following javascript RE code? -

could give explain on following example code? it's last example here . not sure why there's no '\' before '.' , can same result adding '\' . javascript: var url = "http://xxx.domain.com"; print(/[^.]+/.exec(url)[0].substr(7)); // prints "xxx" note paragraph here regarding metacharacters inside character classes note special characters or metacharacters inside character class closing bracket (]), backslash (\), caret (^) , hyphen (-). usual metacharacters normal characters inside character class, , not need escaped backslash.

Why data exist in multiple locations in 8086 in the same physical memory? -

in 8086 more 1 logical addresses (segment:offset) can have same physical address (001f:000f , 000f:010f same address ,like 001f:000f = 01f0+000f = 01ff in same way 000f:010f = 01ff).in physical memory ,any program sees logical memory address.so more 1 program can have data (byte) same physical address (though logical addresses different) position.why don't collide each other ? why don't lose data ??? the 8086 can address 1mb of memory, requiring 20 bits specify address of particular byte. since 8086's registers hold 16 bits, segment model developed gives each of 1m addresses many different names. number 4 can named 0+4 , 1+3 , 2+2 , etc., address 12345 can expressed 1234:0005 , 1233:0015 , 1230:0045 , , on. in other words, each physical address has 64k different logical addresses. means if 1 program accessing 1234:0005 , program accessing 1233:0015 , 2 programs accessing exact same memory address. so how prevent different programs "colliding" ...

javascript - Content switch in drag and drop using HTML5 -

i have drag , drop code need switch content in drag , drop. when drop tr on tr append new tr want these 2 tr should change position instead of append it. not interested in plugin , if can done using jquery gr8. html code: <table> <tr> <td id="tblrw1" draggable="true" ondragstart="drag(event)" ondrop="drop(event)" ondragover="allowdrop(event)"> dummy text1 </td> </tr> <tr> <td id="tblrw2" draggable="true" ondragstart="drag(event)" ondrop="drop(event)" ondragover="allowdrop(event)"> dummy text2 </td> </tr> <tr> <td id="tblrw3" draggable="true" ondragstart="drag(event)" ondrop="drop(event)" ondragover="allowdrop(event)"> dummy text3 </td> ...

java - Trying to achieve dynamic lighting in a tiled 2D isometric environment using Java2D -

Image
i trying write lighting code java2d isometric game writing - have found few algorithms want try implementing - 1 of found here: here the problem sort of algorithm require optimal pixel-shading effect haven't found way of achieving via java2d. preferably method via graphics hardware if isn't possible - @ least method of achieving same effect in software. if isn't possible, direct me more optimal algorithm java2d in mind? have considered per-tile lighting - find drawpolygon method isn't hardware accelerated , performs slowly. i want try , avoid native dependencies or requirement elevated permissions in applet. thanks i did lot of research since posted question - there tons of alternatives , javafx intend (on later release) include own shader language interested. there ofcourse lwjgl allow load own shaders onto gpu. however, if you're stuck in java2d (as am) still possible implement lighting in isometric game 'awkward' because cannot pe...