Posts

Showing posts from August, 2012

multithreading - Lua 5.2.2 Broken Threading System -

ey, i'm making threading system in lua , have crash when resume lot threads... i'm noob in c lua , don't know or bad i'm doing in next codes... i flagged crash places "//maybe here" #include<cstdio> #include<ala_lua.h> extern"c"{ void __stdcall sleep(unsigned long); }; int main(){ lua_state*l=lual_newstate(); lual_openlibs(l); luaa_libs(l); lua_state*t=lua_newthread(l); lual_loadfile(t,"c:/clua.lua"); co_resume(t); do{ sleep(1); }while(co_update()); lua_close(l); gets(new char[1]); return 0; }; #ifndef ala_lua_h #define ala_lua_h #include<ala_lua_co.h> void luaa_libs(lua_state*); static int luaa_sleep(lua_state*handle){ co_sleep(handle,lua_tointeger(handle,1)); return 0; }; static int luaa_rthread(lua_state*handle){ if(lua_isthread(handle,1)){ co_resume(lua_tothread(handle,1)); }; return 0; }; static int luaa_mthr

oop - search php object for empty value -

looking best way accomplish below. want return true if empty in user object, don't care 1 empty. think i've done before searching empty values in array can't think of best way objects. i know can loop thru object , break once find empty value in object, checking first see if there better way of doing this, thanks! function is_it_empty($user) { $is_it_empty = false; if( isset($user->first_name) ) $is_it_empty = true; if( isset($user->last_name) ) $is_it_empty = true; return $is_it_empty; } also: function name($user) { foreach($user $u): if( isset ($user->value) ): // or should isset? return true; break; endif; endforeach; return true; } $user = new stdclass(); $user->firstname = 'mark'; $user->lastname = 'baker'; $user->sanity = null; function is_it_empty($user) { foreach($user $property) { if (empty($property)) { return true; } } return false; }

text - How can I convert probability into score? -

i working on document recommendation program , kinda stuck here. each document, have score assigned according user's actions. then, when new document comes in, need predict how user , rerank whole documents again according scores. solution use threshold divide scores "recommend" , "not recommend". naivebayes or other classification models can either give me label or return possibility of label (i using nltk package text analytics). on right way? question when possibility, how can convert score use ranking? or should use logistic regression in scikit instead? thanks! i suggest trying out svm-rank algorithm. takes input set of "recommended" , "not recommended" vectors , learns how rank them recommended ones come first. there simple python tool in dlib can use it. see here example: http://dlib.net/svm_rank.py.html

java - how can i use request parameter in struts2 if tag -

i have link : http://localhost:8080/esa/login.jsp?login=failed in end of above link set parameter name login , value failed . how can use parameter in jsp page struts if tag. use following code don't work. <s:if test="%{#parameters.login='failed'}"> <div class="error"> <s:text name="user.login.failed"></s:text> </div> </s:if> try with <s:if test="%{#parameters.login[0]=='failed'}"> the 2 problems in code: the = sign assignment, not equals == ; parameters saved in map<string, string[]> , each parameter have multiple values , accessed specifying index. the last option described here: why doesn't if tag evaluate params properly .

Actionscript 3, adding an audio slider to my game -

so i've been struggling trying add audio slider game last couple days , i've had it, so, let me preface saying have tried extremely hard , love understand solution, @ point want solution, more specific can better. i've thought of number of approaches, actionscript skills have been faulty pull of them off. let me explain setup bit. have functional class audio slider. plays music, slides, perfect. now, i'm sticking in document class. thought easiest call function right @ beginning (as title screen shows up), though don't want music playing right @ title screen. thought call it, not play music yet. have called document class. now, want able click on options button , addchild audio slider. have accomplished , works. finally....the hard part. want click play game button , have music start playing while being linked options slider has possibility of being moved. really...just standard audio slider. i'm stuck on linking options screen audio slider music playing

linux - move stdout out of the console, in portable C -

the target application can used in "pipe" mode, means accepts input stdin, , can output stdout. however, there risk of user making mistake, directing output stdout, without directing stdout towards "something" (a file, or consumer program). consequence, console screen gets garbaged displaying binary data (since default, stdout outputs screen). bottom line : want avoid binary output displayed console, automatically. must done in portable c , , not depend on external script. a few potential ways of doing : 1) possible detect stdout going console, in order redirect somewhere else instead ? (including /dev/nul). note code must portable, , work windows , linux (and bsd, opensolaris, etc.) 2) alternative : possible redirect stdout "somewhere else" (such /dev/nul) default without harming correct usage of program, redirecting stdout valid consumer process ? on posix (e.g. linux , osx) system can use isatty function check if stdout goes co

Evaluating type identifiers (%d) in strings, in C -

i working on mac osx , using bash shell. working in c , trying create file renumber files. important part of code follows: int i; (i=0; i<numberoffiles; i++) { strcpy(filename,""); //set null char append[formatlength]; //string being appended sprintf(append,"%%0%dd", formatlength); //example output: %04d strcat(filename,fileprefix); //attached prefix strcat(filename,append); //attaches appended part //missing code: part equvaluates %04d int i, such 0023. } this gets me correct string format looking (say formatlength=4): fileprefix+%04d. however, need evaluate %04d in string , evaluate i , files like: file0001, file0002, etc. would have ideas. help. if understand question correctly, should able say char result[(sizeof fileprefix/sizeof (char)) + formatlength]; sprintf(result, filename, i); since filename looks "fileprefix%04d" . desired filename stored in result . not recommend re-storing in filename by say

ajax php pagination wont show active page -

i working on php ajax pagination. the problem wont ad class="highlightactivepage" proper. if click on 1 - 2 - 3 , works fine , highlight number 3 if im on page 3. but click on page 4 highlights page 5 instead, etc. not sure if loop wrong, here code: if (paginationhtml == "") { paginationhtml += "<ul>"; if (adresultsdata.show_first_text == 1) { paginationhtml += "<li><a href='#' onclick='fetchresults(1);'>first</a></li>"; } if (adresultsdata.show_previous_text == 1) { paginationhtml += "<li><a href='#' onclick='fetchresults(" + (adresultsdata.current_page - 1) + ");'>prev</a></li>"; } (var = 0; < adresultsdata.pages.length; i++) { if (adresultsdata.current

composer update "process killed" -

i tried execute: composer.phar update and received: fatal error: allowed memory size of 94371840 bytes exhausted (tried allocate 71 bytes) in phar:///home/xxxxxxx/bin/composer.phar/src/composer/dependencyresolver/rulesetgenerator.php on line 123 the xxxxxxx user. and tried execute: php -d memory_limit=256m ~/bin/composer.phar update and: php -d memory_limit=512m ~/bin/composer.phar update then received this: yikes! 1 of processes (php, pid 14331) killed excessive resource usage. please contact dreamhost support details.** how can execute composer update on dreamhost shared host? can had experienced situation me please? the context: laravel 4 run composer update command on development machine, generates composer.lock file you. upload composer.lock file , on shared host run composer install . use lot less memory!

javascript - Moving a div by its class inside another div with an ID -

i trying move div class="somediv" into/inside div id="parentdiv" if edit javascript move div id div diff id works. moving div class div id not working. missing something? html <div id="parentdiv"> <div id="childdiv"> <ul> <li>1</li> <li>2</li> </ul> </div> <!-- move somediv here --> </div> <div class="somediv">some content</div> js: document.getelementbyid('parentdiv').appendchild(document.getelementsbyclassname('somediv')); http://jsfiddle.net/9gvsa/1/ using jquery makes easier, @ updated version of jsfiddle , can see item has been moved, inspecting dom tree $(document).ready(function(){ $("#parentdiv").append($(".somediv")); }); example

pdo - PHP: Why functions can not avail the variables of a required file? -

this question has answer here: reference: variable scope, variables accessible , “undefined variable” errors? 3 answers this code made return name of chosen $id database, #db informations (username/password) require('/path/to/db_informations.php'); # function return 'name of $id db function getname($id){ $link = new pdo($dsn, $user, $pwd); $query = "select `name` `tables` `id`=$id"; $smt = $link->prepare($query); $smt->execute(); $name = $smt->fetch(pdo::fetch_assoc); return $name['name']; } # db_informations contain credentials connect database. ($dsn, $user, $pwd) mmh require(/path/to/db_informations.php') not working inside function if put `require();' function in body. not understand mistake, can please explain me: why /path/to/file not included php? , how to? this variable sco

android - Did GPS turned on when I saw blinking GPS icon on notification bar? -

when turn on gps code in android program, saw blinking gps icon in notification bar. mean gps has turned on successfully? android guidelines have changed above version 4.0. cannot change gps off on programmatically versions above 4.0. however, can change wifi off on programmatically android 4.1.2 how turn off gps programmatically

python - Jinja2 and Flask: Pass variable into parent template without passing it into children -

let's have base template header in it, , content of header needs passed template. <header> logged in {{ name }} </header> this base template gets extended many pages. how can pass in variable without passing each individual child? example, don't want have this: render_template("child1.html", name=user.name) render_template("child2.html", name=user.name) render_template("child3.html", name=user.name) etc... because knows how many child pages might have. doesn't feel dry enough. i never render base template, children, don't know how else pass in data. is there way this? should not using inheritance? may suggest use global variable 'g' in flask. default available in jinja templates. don't need worry passing anywhere in base template or children. make sure set first when login g.username = user.name then in templates, this: you logged in {{ g.username }}

c# - Export richtextbox to pdf -

i export contents of richtextbox inlineuicontainer inside pdf format or rtf or doc. need export keep getting blank document. i've been stuck on problem days. please help. similar this question asked earlier ok, got it. had set width , height of inlineuicontainer explicitly.

java - Am I not understanding ArrayList or am I missing something? -

i'm trying create very, simple program. want class called text print out string, specifically, 1 letter. in second class called window, want create arraylist of class, iterate through list , call method of text class print out string. not print anything. what doing wrong? public class text { private string a; public void printa() { = "a"; system.out.print(a); } } and other class.. import java.util.arraylist; public class window { private arraylist<text> string = new arraylist<text>(5); public window() { addtext(); } public void iterate() { (int = 0; < string.size() - 1; i++) { string.get(i).printa(); } } public void addtext() { (int = 0; <string.size() - 1; i++) { string.add(new text()); } } public static void main(string[] args) { window wind = new window(); wind.iterate(); } } i

intuit partner platform - Vendor Bill vs Vendor Credit / Ipp C# -

is there way using ipp (in c#) differentiate between bill , vendor credit? right when iterate through lines on bill payment (a check in case) show bills being paid vendor credits show not different bill (amounts positive, there no bill type etc). intuit.ipp.data.qbo.billpaymentquery qbbillpaymentquery = new billpaymentquery(); qbbillpaymentquery.docnumber = "143766"; list<intuit.ipp.data.qbo.billpayment> qbobp = qbbillpaymentquery.executequery<intuit.ipp.data.qbo.billpayment>(context).tolist<intuit.ipp.data.qbo.billpayment>(); foreach (billpayment b in qbobp) { response.write("bill payment amount: " + b.header.totalamt + "<br>"); foreach (billpaymentline x in b.line) { intuit.ipp.data.qbo.billquery qbbillquery = new billquery(); qbbillquery.resultsperpage = 1; //qbbillquery.pagenumber = 1; qbb

shell - Any way to see the number of lines in a file without opening the file? -

i have rather large text file (~45mb) , want know how many lines total has. since file large, takes long open text editor , check manually way. wondering if there shell command/shell script (i'd prefer tcsh answer since that's use) or other way "quickly" (meaning, more opening file , checking out end) determine how many lines text file has? i in *nix environment. wc -l filename it won't fast, since has read entire file count lines. there's no other way, since unix doesn't keep track of anywhere.

html - Jquery div not centering on page refresh -

i using following script centre main content div in centre of viewing area, appears work fine on page load or page resize, when page refreshed content div drops left hand side of page. the problem can seen here upon pressing refresh : http://www.twin-focus-photography.co.uk/ <script> $(document).ready(function(){ var positioncontent = function () { var width = $(window).width(); // window width var height = $(window).height(); // window height var containerwidth = $('.container').outerwidth(); // container div width var containerheight = $('.container').outerheight(); // container div height $('.container').css({position:'absolute', left: ($(window).width() - $('.container').outerwidth())/2, top: ($(window).height() - $('.container').outerheight())/2 }); }; //call when window first loads $(document).ready(positioncontent); //call whenever window resizes. $(window

ssis - Data from SQL Server table to Web API -

is possible use integration services project in vs2012 pull data database table , push in json or xml format on http web server? haven't had luck searching internet; signal-to-noise ratio way low on results. i've tried looking use http connection manager, i've seen examples of being used in conjunction wsdl. any ideas? thanks! i think try using httpwebrequest in script component. here link blog post sending json service: making json service request using c#

java - ClassCastException on cargo running solr with a dataimport-handler -

i'm having issues on getting solr 4.3.1 run using cargo-maven2-plugin. after fixing classpath issues, i've ended following error: error org.apache.solr.core.corecontainer - null:org.apache.solr.common.solrexception: unable create core: collection1 @ org.apache.solr.core.corecontainer.recordandthrow(corecontainer.java:1450) @ org.apache.solr.core.corecontainer.create(corecontainer.java:993) @ org.apache.solr.core.corecontainer$2.call(corecontainer.java:597) <...> caused by: org.apache.solr.common.solrexception: requesthandler init failure @ org.apache.solr.core.solrcore.<init>(solrcore.java:821) @ org.apache.solr.core.solrcore.<init>(solrcore.java:618) @ org.apache.solr.core.corecontainer.createfromlocal(corecontainer.java:949) @ org.apache.solr.core.corecontainer.create(corecontainer.java:984) ... 10 more caused by: org.apache.solr.common.solrexception: requesthandler init failure @ org.apache.solr.core.requesthand

jquery - Simple Javascript Calling function not working/don't know how to get it to work -

i'm trying call function , not alert , thought easy doing this: functionsname(); , delete alert(''); it's not working me :( can please @ code have below , tell me wrong ? thank much!! <script type="text/javascript"> var comper; function checkcomper() { var onresponse = function(compernow) { if (comper === undefined) { comper = compernow; return; } if (comper !== compernow) { // show message visitor alert("new info added"); // <--*** want take out , call $("#append").click(function(e) comper = compernow; } }; $.get('getlastupdate.php', onresponse); } var tid = setinterval(checkcomper, 2000); $(function() { var $table = $("table.tablesorter"); $("#append").click(function(e) { e.preventdefault(); $.get('updatetable.php', function(data) {

python - Performing calculations on a tab-delimited file -

i'm still learning python , still don't know how work arrays. i'm want read tab-delimited file example (but in case have 400 rows): col1 col2 0.0001 0.6 0.0001 0.5 0.000006 0.8 0.0001 0.0003 0.002 1 0.002 3 i want following output: col1 col2 0.0001 0.36676667 0.000006 0.8 0.002 2 so wanna keep same value in col1 taking mean of values in col2 corresponds same value in col1 . i can read array using : arr = np.genfromtxt('test.csv', dtype=none, delimiter='\t', skiprows=1) but don't know how make these operations , making new file new generated data. thanks lot help! use collections.defaultdict list default argument. take value first column key, , append second value. import csv collections import defaultdict # gather data csv file d = defaultdict(list) open('data.csv', 'r') csvfile: reader = csv.reader(csvfile, delimiter='\t') row in r

html - Return Different PHP Array Values Based on A User ID-Related Constant -

i working array of tokens html template. 2 of them ('{sys_menu}' , '{sub_menu}') used generate control buttons web application. right buttons show on login page before user's credential's validated, , need change code buttons hidden until after users login , reach main menu. when types http: address browser , arrives @ login page system starts session them in mysql sessions table user_id = 0. after login user_id changes whatever number assigned them @ initial registration (example: user_id = 54), , after logout @ end of session 0. tying constant buttons seems best solution , have found work in past under similar circumstances. here original array: $template_vars = array( '{lang_dir}' => $lang_text_dir, '{title}' => theme_page_title($section), '{charset}' => $charset, '{meta}' => $meta, '{gal_name}' => $config['gallery_name'], '{gal_description}' => $co

The array data type in C -

by reading details pointer , arrays in c got little confused. @ 1 hand array can seen data type. @ other hand array tends unmodifiable lvalue. imagine compiler replacing arrays identifier constant address , expression calculating position given index @ runtime. myarray[3] -(compiler)-> ae8349f + 3 * sizeof(<type>) when speaking array data type, mean? hope can me clarify confused understanding of array , how treated compiler. when speaking array data type, mean? a data type set of data values having predefined characteristics. examples of data types are: integer, floating point unit number, character, string, , pointer an array group of memory locations related fact have same name , same type. if wondering why array not modifiable best explanation have ever read is; c didn't spring formed mind of dennis ritchie; derived earlier language known b (which derived bcpl). 1 b "typeless" language; didn't have different types integer

.htaccess - htaccess rewrite rule for multiple pages -

this seems simple, it's not working me. trying have both show.php?id=$1 , producer.php?id=$1 rewrite friendly urls. first 1 works perfectly, second not. if remove first, second works fine. what doing wrong here? my code: <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]*)\.html$ /show.php?id=$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]*)\.html$ /producer.php?id=$1 [l] </ifmodule> thanks in advance! your problem quite simple. you cannot have more 1 rewrite rule same directory, need have separate folder each ie. have folder called "show" , have htaccess file contains rewrite data show. .htaccess show folder: <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]*)\.html$ /show.php?id=$1

javascript - Get current field name in to change display option? -

i've looked afternoon try , find one. basically, want name of current text field , change display value noprint if text field value "--". i'm running validation script in pdf. appreciated! if(event.value == '--') { event.target.name.display = event.target.name.display.noprint; } else { event.target.name.display = event.target.name.display.visible; } you have couple of things bit off. event.value doesn't exist (you can check available event properties ) if want value of element triggered event can do: var elemvalue = event.target.value; if want name same element can do: var elemname = event.target.name; to hide element printing, can see this answer .

Spring MVC: how to indicate whether a path variable is required or not? -

i doing spring web. controller method, able use requestparam indicate whether parameter required or not. example: @requestmapping({"customer"}) public string surveys(httpservletrequest request, @requestparam(value="id", required = false) long id, map<string, object> map) i use pathvariable such following: @requestmapping({"customer/{id}"}) public string surveys(httpservletrequest request, @pathvariable("id") long id, map<string, object> map) how can indicate whether path variable required or not? need make optional because when creating new object, there no associated id available until saved. thanks help! there's no way make optional, can create 2 methods 1 having @requestmapping({"customer"}) annotation , other having @requestmapping({"customer/{id}"}) , act accordingly in each.

R Studio: Why A Function Argument is Considered A Function Name -

i newcomer in r language. far have made 1 r language's function works properly. have main function (nsbeta) calls 2 functions, when arrives second function, called "pnsjacob", responses: error: not find function "vperiodyear" 1 of "pnsjacob"'s argument nsbeta <- function() { #postgresql connection #data sourced postgresql con <- dbconnect(postgresql(), user= "postgres", password="luthf1had1", dbname="my dissertation") rs <- dbsendquery(con,"select * tscf") tscf <- fetch(rs, n=-1) #disconnect dbdisconnect(con) # initiate variables vertices <- tscf$vertex vfreq <- vertextally(vertices) vlength <- length(vfreq) vcf <- tscf$cashflow_amount vparam <- c(0.5,0.5,0.5,1) # prices , jacobian after initial parameters # names(tscf)[9] <- "years" # vperiodyear <- tscf$years vperiodyear <- tscf$period_year vjacoboutput <- pnsjaco

jquery - how to enable telerik dropdownlist -

i have telerik dropdownlist disables default: <%= html.telerik().dropdownlist().name("yesno").enable(false) .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); })%> now want enable when selects "no" telerik dropdown: <%= html.telerik().dropdownlist().name("validate") .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); }) .clientevents(events => { events.onchange("validate_onchange"); })%> so tried jquery method enable, not enabling ddl: funct

Grails Spock integration test redirectedUrl different between localhost test-app and build server test-app -

i have spock integration test looks this: class pricetiercontrollerintegrationspec extends integrationspec { pricetiercontroller controller def setup() { controller = new pricetiercontroller() } def "applydiscount() method redirect user success view"() { when: controller.applydiscount() then: controller.response.redirectedurl == '/pricetier/success' } then in controller, logic simply: class pricetiercontroller { def applydiscount() { redirect action: 'success' } def success() { } } when run spock test on local machine, test passes. however, on build server, following error: controller.response.redirectedurl == '/pricetier/success' | | | | | | /test/success false | | 8 differences (46% similarity) | | /(t---)e(st--)/success | |

php - Find out how often a value is between 2 dates in mysql -

hi follow code request dates in database without duplicates. save array. in array need other value. the value need how users in 1 day in database without duplicates. example array must later lookslike 23.07.2013 - 10, 24.07.2013 - 50 (users). search several hours don't find mysql query. $query = "select id, user, timestamp stat timestamp between '$datum1' , '$datum2' group timestamp"; $result = mysql_query($query,$db); while($row = mysql_fetch_assoc($result)) { mysql_num_rows($result); $dataset1[] = array(strtotime($row['timestamp']),$number_of_users_on_this_day); } try: $query = "select id, user, count(*) count stat timestamp between '$datum1' , '$datum2' group timestamp"; this return number of entries in value 'count' if want distinct data, in place of * use count(distinct id) with whatever field want unique in place of 'id'

App Engine Python module Basic and Manual scaling not working -

my google app engine application needs run lengthy calculation. automatic scaling on module returns deadlineexceedederror , tried switching manual , basic scaling. for basic scaling, added yaml file. instance_class: b2 basic_scaling: max_instances: 5 idle_timeout: 10m but when send url request module, logs flooded 56: /_ah/start 404 no handlers matched url. then returns: httperror: http error 503: service unavailable for manual scaling, added yaml file: instance_class: b2 manual_scaling: instances: 1 but when send url request module, after while get: httperror: http error 503: service unavailable but nothing in logs. what missing? need put handler /_ah/start ? thought 404 acceptable start module. figured out. had add handler module. i added: - url: /_ah/start script: colors.handler.app to handlers: , worked.

The term 'Cleaning' in Django -

class enhancedarticleform(articleform): def clean_pub_date(self): this example djangobook. when 'clean' in django, mean? having difficulty trying understand it. it's naming convention doing custom validation on 1 or more form / model form fields. see https://docs.djangoproject.com/en/1.5/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other more information.

android - auto open searchin action bar only shows keyboard -

Image
i trying have search bar in actionbar auto open when search page launched. use attempt open search bar automatically on page open: @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); searchview searchview = (searchview) menu.finditem(r.id.menu_search).getactionview(); searchview.seticonified(false); searchview.setonquerytextlistener(this); return true; } the problem when page opens, keyboard pops search bar not expand user can start typing search. looks this: use searchitem.expandactionview(); and in menu file, use showasaction="ifroom|collapseactionview" if query, feel free comment.

objective c - How to fade in and fade out a label. continuously -

in xcode project have put label on xib. i want fade label in , out continuously until user taps screen. when happens want new view appear. can suggest how fade-in/out? you put pair of chained animation in loop or call function holds chained animation everytime until encounter user tap. by chained animation, mean (you can set animation duration suit needs): mylabel.alpha = 0.0; [uiview animatewithduration:1.0 delay:0.0 options: uiviewanimationcurveeaseout animations:^{ mylabel.alpha = 1.0; } completion:^(bool finished){ [uiview animatewithduration:1.0 delay:1.0 options: uiviewanimationcurveeaseout animations:^{ mylabel.alpha = 0.0; }

.net - Adding Custom Metadata to TIFF file -

i trying encode , digitally sign tiff image. use psicom.dll (library provided medicare australia encode , sign images). far good. trying is, add metadata information tiff file (eg timestamp before file encoded). @ moment being done appending timestamp information end of file, , removing information appended when image decoded. here pseudocode this: ' read image byte array file.setattributes(imagepath, fileattributes.normal) dim temp() byte = system.io.file.readallbytes(imagepath) dim datekey() byte = encoding.ascii.getbytes((datetime.parse(datetime.now).tostring("dd/mm/yyyy hh:mm:ss tt") ' copy data array dim data() byte = new byte(((temp.length + (datekey.length + 1))) - 1) {} temp.copyto(data, 0) 'temp has timestamp. this rather cumbersome @ decoding end, because 1 needs know exact number bytes remove off end of file. not know tiff files, , haven't worked on image files before, reading found 1 use custom tags within tiff file. can please thr

php - Set a separate file as home page in Wordpress -

i've noticed there lot of similar posts, can't seem sift through pile right one. i'm creating custom theme. have separate file, "foo.php", want un-editable homepage or front page of the site. then, want use different file/template rest of site. how do this? at top of foo.php template, insert following code: <?php /* template name: home page template */ ?> in wordpress, create page called "home" (or really, whatever like). don't need add content using editor if it's in foo.php file. right of editor you'll see dropdown lets choose template - pick 1 created, "home page template". last, go "reading" section of wordpress dashboard , set newly created page, "home" static front page .

onmouseover not working not sure what is wrong -

i have been working following fiddle , cannot seem onmouseover function work properly! can tell me wrong? http://jsfiddle.net/hm25t/ <div id="box" onmouseover="alert();"></div> function alert(){ alert("i alert box!"); } in jsfiddle, switch drop down onload no wrap - in <head> have jquery 1.9.1 set on left under frameworks & extensions . function nextpoem being put inside jquery onload , won't work. changing work. see updated fiddle: http://jsfiddle.net/hm25t/4/

windows - Search line by line in file for a string -

i need search line line ensure word appears on every line of .text file. working on batch script ideal if batch has capabilities this. otherwise, options? echo lines have not search word: findstr /n /v /c:"theword" thefile.txt

canvas - Text Render Effect as if individual glyphs are being written by ink pen on a paper by hand, Need to do this in C# and HTML5 -

i working on project create font render displays text if individual glyphs being written hand. individual glyphs in text string rendered if being written of ink pen. freetype or glyph classes of c# starting point. can outline of glyph how fill glyph create handwriting effect (ie how direction starting fill glyph)? consider letter e, h. these have rendered several strokes (like when write using ink pen on paper). how individual directed strokes glyph outline? need in c# , if possible in html5 using canvas or svg. thanks.

C++ enum of type char, ignored by the compiler or unexpected behaviour? -

i did little test enum, here have: enum anyoldname : char { aa = 'a', ab = 'b', ac = 'c', ad = 'd' }; int main() { anyoldname i_have_an_enum_here = aa; // expect i_have_an_enum_here of type char? std::cout << i_have_an_enum_here << std::endl; return 0; } output is: 98 , unless cast explicitly char so: std::cout << (char)i_have_an_enum_here; or change anyoldname char . why value 98 printed instead of b ? by way sizeof() returns 1 , ie; 1 byte, char . without cast, compiler first searches appropriate member function of std::ostream , , finds 1 -- 1 int . implicitly converts 1-byte number of type anyoldname int , calls member function. compiling program g++ 4.8.1, 2 definitions ostream::operator<< seen: u std::ostream::operator<<(std::ostream& (*)(std::ostream&))@@glibcxx_3.4 u std::ostream::operator<<(int)@@glibcxx_3.4 the first 1 endl , second

c++ - GetMenuItemInfo does not set fType with MIIM_TYPE -

i have been working winapi little bit, making project owner draw on menus. when called getmenuiteminfo , sets text of menu item, not ftype uint variable flags. have declared: menuitem->fmask = miim_type and msdn says: miim_type retrieves or sets ftype , dwtypedata members. i don't know if got confused miim_type flag. here code: void setownerdrawmenu(hmenu * menu) { menuif * menu_item_information; hmenu sub_menu_ocational; uint uid_menuitem; int nmenucountitems = getmenuitemcount(*menu); menuiteminfo * menuitem = (menuiteminfo*)malloc(sizeof(menuiteminfo)); for(int i=0;i<nmenucountitems;i++) { menu_item_information = (menuif*)malloc(sizeof(menuif)); menu_item_information->isseparator=false; menu_item_information->max_width=0; sub_menu_ocational = 0; uid_menuitem = getmenuitemid(*menu,i); memset(&menuitem,0,sizeof(menuitem)); menuitem = (menuiteminfo*)malloc(sizeof(menuiteminfo)); menuitem->cbsize = sizeof(menuit

asp.net mvc - How to make HttpClient relay traffic show up in Fidder or Charles? -

i have simple web api project based on example: http://aspnet.codeplex.com/sourcecontrol/latest#samples/webapi/relaysample/program.cs however, in above sample relay working local server, in project relay working external web server real address; companyx.com i using relay service (or, web proxy service) through browser, example, in browser request relayservice.com/companyx. relay service responds data external companyx.com site. the relay works great, headers not correct , need see httpclient sending remote companyx.com server. in fiddler or charles, request/response browser relayservice.com listed, request/response httpclient relayservice.com never shows up. the relayservice.com running locally on machine, in iis7, i'm using hosts file direct traffic relayservice.com. i have tried several variation of following when creating httpclient: var clienthandler = new httpclienthandler { cookiecontainer = cookies, usecookies = tru

turn off auto-renaming of html elements' id in visual studio 2012 -

Image
in situation when have conditional server code, visual studio keeps auto-renaming duplicate id's. here's valid example: <% if x = 1 %> <input type="hidden" id="hello" value=""/> <% else %> <input type="hidden" id="hello" value=""/> <% end if %> when visual studio's live error checking finds this, change code without confirming me following: <% if x = 1 %> <input type="hidden" id="hidden1" value=""/> <% else %> <input type="hidden" id="hidden2" value=""/> <% end if %> how turn off? don't mind turning off whole live error checking even. don't know toggle "feature" though. thank reading question, go tools -> options scroll down text editor. expand it, select html , expand it. click miscellaneous , should see following. deselect first option , try i

JSON response issues c# -

i have return json string in c# api follows like: { "model" : 4 , "lang" : "en_us", "parts" : [ { "id" : 1545, "name" : "part 1", "part_types" : { "type 1" : { "url" : "part.com/type1", "desc" : "has 6 bits" }, "type 2" : { "url" : "part.com/type2", "desc" : "has 7 bits." } } } ] } i have basic structure like: public class inventory { public int model { get; set; } pub

jQuery - Proper way to rebind existing function after new item added to DOM -

i want rebind existing function after draggbale item dropped, like: .item draggable item, , .droppable droppable area. i running function .droppable s .item on .ready() , if drop .item .droppable existing function not work newly dropped .item , put event inside function, like: function my_event(){ jquery('.droppable').on('mouseover.mine mouseout.mine', function (e) { if ($(this).is(".active")) { e.stoppropagation(); e.preventdefault(); jquery(this).toggleclass('highlight'); } }).on('click.mine', function(e){ if ($(this).is(".active")) { e.stoppropagation(); e.preventdefault(); show_data(this); } }); }); } now, can call function on .ready() , .droppable() event stop . working fine, but want ask right call , rebind function after every .item dropped

Sum values in one mysql column and group by values of other column (using php foreach) -

started write question, while wrote question, answer. not delete content, post answer (possibly may useful). , may there improve. based on https://stackoverflow.com/a/15048890/2465936 answer trying sum values in 1 column , group values in other column for example, table named 2_1_journal transactionpartnername | amount ------------------------------- name 1 | 1 name 2 | 2 name 1 | 3 name 3 | 10 name 2 | 7 name 1 | 150 as result want this name 1 = 154 name 2 = 9 name 3 = 10 mysql query $query_select_all =" select transactionpartnername, sum(amount) 2_1_journal group transactionpartnername"; then $sql = $db->prepare($query_select_all); $sql->execute(); $sql = $sql->fetchall(); with print_r($sql); get array ( [0] => array ( [transactionpartnername] => name 1 [0] => name 1 [sum(amount)] => 154.00 [1] => 154.00 ) [1] => array