Posts

Showing posts from August, 2011

sql - How to compare datatype of column to a given datatype -

i need create sql change script checks specific datatype of column , edits datatype if column of type. for example if (select data_type information_schema.columns table_name = 'table' , column_name = 'xml') = 'xml') i want above code return true if 'xml' column in 'table' of type xml. need change varchar(max) . for such scripts use sql server metadata/catalog views instead of views information_schema : for untyped xml columns: if exists( select * sys.columns c join sys.tables t on c.object_id = t.object_id join sys.schemas s on t.schema_id = s.schema_id join sys.types tp on c.user_type_id = tp.user_type_id s.name = n'dbo' , t.name = n'table1' , c.name = n'col2' , tp.name= n'xml' ) begin alter table dbo.table1 alter column ... end for typed xml columns: if exists( select xmlcol.* sys.columns c join...

c++ - vs 2013 : breakpoint into cppunittest test throws exception -

i testing c++11 static lib in vs 2013 environment. followed this nice tutorial , testing + code coverage working fine. now need step-by-step : added breakpoints , executed "debug selected test" command , following message : vstest.executionengine.exe has triggered breakpoint , callstack brings me @ cppunittest.h:465 : (static_cast<thisclass *>(this)->*method2)(); , eg @ root call of method want break into. no way see code inside call. my question : how break code during debugging ms cpp unit test ? i found problem. breakpoints activated inside static lib used test dll. seems breakpoints inside static lib generates wrong test framework. to reproduce : create c++ static lib project simple function, int foo(){ return 0;} create test-dll project add test function calls foo set breakpoint in foo execute "run selected test" : work execute "debug selected test" : block before calling test-method test-generated class. i st...

Entity Framework SQL Parameters not getting supplied -

this thread gives number of ways provide parameter stored procedure. none of them working me. this works: this.payrollcontext.database.sqlquery<csrrateentity>("ord_getcsrrate @csr_num = '4745', @ord_pay_period_id = 784").tolist(); this not: return this.payrollcontext.database.sqlquery<csrrateentity>("exec ord_getcsrrate @csr_num, @ord_pay_period_id", new sqlparameter("csr_num", "4745"), new sqlparameter("ord_pay_period_id", 784) ).tolist(); the error message parameter not supplied. have tried variations can think of , still same error message. this using code first, no import required. sp found, missing parameters. did import stored procedure edmx? in implementation have stored procedure creates parameters this: var inputidparameter = inputid.hasvalue ? new objectparameter("inputid", inputid) : new objectparameter(...

java - Descending Order for SortCursor Class -

so i've been using great resource class found online sort 2 cursors based on column: https://android.googlesource.com/platform/frameworks/base.git/+/android-4.4.4_r1/core/java/com/android/internal/database/sortcursor.java the onmove function of cursor seems doing sorting between 2 cursors: @override public boolean onmove(int oldposition, int newposition) { if (oldposition == newposition) return true; /* * find right cursor * because client of cursor (the listadapter/view) tends * jump around in cursor somewhat, simple cache strategy * used avoid having search cursors start. * todo: investigate strategies optimizing random access , * reverse-order access. */ int cache_entry = newposition % rowcachesize; if (mrownumcache[cache_entry] == newposition) { int = mcursorcache[cache_entry]; mcursor = mcursors[which]; if (mcursor == ...

linux - ltrace : only show direct calls from a program to a library, and no inter-library call -

when called no argument other program run, ltrace seems display calls made program shared libraries, , not inter-library calls. i'd filter down these results selecting library calls made into. -l option filters library, inter-library calls shown also. adding -e '@my_program not difference. ltrace 's man page states inter-library calls removed linking program -dsymbolic . is there way rid of inter-library calls without recompiling program? thanks

Dropbox, iOS, OAuth, Token embedded in app -

working on ios app use dropbox server side ( place store documents app needs access). work see around dropbox api asking user go , login ios app dropbox, , user token , save it, don;t ant that, want have token stored within app @ times. how can achieve that? possible or practice.

excel - Not Enough Arguments For an IF Statement...But There Are -

when run equation in excel tells me there 1 argument if statement. not sure why saying when have 3 arguments. within or statement have 2 different , statements. works fine if rid of second , statement. did mess parentheses somewhere? not sure wrong. appreciated. thanks! =if(or(arrayformula(sum(countif(b19:o19,{"i","ip","ia","it","ih","a","aa","ap","at","ah","x","r","rt","rx","rp","rh","k","kt","e","et","al","hl","tv*","ffsl","adm*"})))=10, and(arrayformula(sum(countif(b19:o19,{"r-10","rx-10*","rp-10","rt-10*","rh-10","i-10","ia-10","ip-10","it-10","ih-10","x-10*","a-10*","at-10"})))=4, arrayformula(sum(coun...

apache - Virtual Host ServerName without Port -

let's need setup virtual host server name text.dev, there way can enter test.dev in browser without port number? xampp running on port 8080. have run on port. currently, can test.dev:8080 go correct directory, there way can set test.dev automatically go port 8080. appreciated, thanks. this not possible directly way sketch it. has nothing virtual host configuration, browser behavior. if not specify port, browser connect port 80. nothing can against that. so bet listen on port 80. if cannot or not want http server, have forward requests port 1 virtual host listens on. there several options such port forwarding: firewall based, using simple socket listener acts proxy or means of tunnel, example setup using ssh tools.

swift - NSTimer.scheduledTimerWithTimeInterval() with variable delay -

i have function need called every x second. @ begining x = 5 everytime calls function x need decrement number. know how if x constant: override func didmovetoview(view: skview) { nstimer.scheduledtimerwithtimeinterval(5, target: self, selector: selector("function"), userinfo: nil, repeats: true) } func function(){ println("test") } how decrement delay between each function calls each time gets called? i change code this: var timeduration: nstimeinterval = 5 override func didmovetoview(view: skview) { nstimer.scheduledtimerwithtimeinterval(timeduration, target: self, selector: selector("function"), userinfo: nil, repeats: false) } func function(){ println("test") timeduration -= 1 if timeduration > 0{ nstimer.scheduledtimerwithtimeinterval(timeduration, target: self, selector: selector("function"), userinfo: nil, repeats: false) } } this should work, have not tested it.

c++ - Pretty printing a parse tree to std out? -

i have written simple recursive descent parser in c++. i need way print std out cannot figure out how this. i have class node , has function printsymbol() print symbol. it has std::list <node*> m_children children. given this, how can pretty print parse tree std out? thanks add overload printsymbol takes indent-level, or default value, either works: void printsymbol(unsigned indent = 0) const { std::cout << std::string(indent,' ') << m_symbol << '\n'; (auto child : m_children) child->printsymbol(indent+2); } given single node direct call printsymbol() should output symbol, newline, , children if has any, indented. given root pointer should dump entire parse hierarchy stdout. can extraordinarily creative regarding ascii art, console-dependent line chars if you're set on it, can tedious quickly, warn you. regardless, should @ least give picture can print. either or utterly misunderstood questi...

list - Finding an index in range of values between 0-100 in Python -

this 2 part question, have make selection of 2 indexes via random range of number of integers in list. can't return both if they're both in same range well selection1 = random.randint(0,100) selection2 = random.randint(0,100) for sake of argument, say: selection1 = 10 selection2 = 17 , list [25, 50, 75, 100] both return index of 0 because fall between 0-25 so both fall first index range, problem i'm having issues trying fit range (ie: 0-25) return first index (return list[0]) what syntax type of logic in python? i'm sure can figure out how return different indexes if fall in same range, loop reset loop if can advice on wouldn't hurt. i'll give code i'm working right guideline. @ bottom i'm struggling. code here def roulette_selection(decimal_list, chromosome_fitness, population): percentages = [] in range(population): result = decimal_list[i]/chromosome_fitness result = result * 100 percentages.appe...

Trouble with reading CSV file in R -

i'm newbie in r. have 24mb csv file. reads rstudio on macbook air os yoswmite, 4gb ram. r version 3.1.1 (2014-07-10). viewing contents of view (df) ok. attempting apply filter. not hits. attempting cast character number. r replacing charaters na in column casting done! happens here? seems r can not read contents of cells. there encoding? have done fare: first summary: r code: eiendommer <- read.csv("eiendommer.csv", sep = ";", quote = "", encoding="utf-8", stringsasfactors = false) view(eiendommer)# can view content of csv file filtereiendommer <- filter(eiendommer, kommune == "0101")# no match filtereiendom <- eiendommer [eiendommer$kommune == "0101",]#no match utvalg <- eiendommer[160567:161934,]#manual selection of rows work utvalgsortert <- arrange(utvalg, desc(jordbruksareal), desc(skogareal))# works view(utvalgsortert) ##try transform columns character number. transformedeiendom...

mysql - Trying to apply PHP date format -

i trying apply date format mysql. column field type 'date' , formatted in mysql example 2015-03-16, , fields without dates null . when apply following code, fields dates displayed correctly - 03/16/2015. however, null fields in mysql displayed in webpage 31/12/69. idea can do? if(!$rs = mysql_query("select vessel_name, builder, built, listing_price, date_listed, loa, price_original, price_previous, amt_reduced, amt_pct boats")) { echo "cannot parse query"; } elseif(mysql_num_rows($rs) == 0) { echo "no records found"; } else { echo "<table id=\"boatstable\" class=\"bordered\" cellspacing=\"0\">\n"; echo "<thead>\n<tr>"; echo "<th>vessel_name</th>"; echo "<th>builder</th>"; echo "<th>built</th>"; echo "<th>listing price</th>"; echo "<th>date...

linux - Avoid dumping information in a core file -

i want avoid dumping information program core file in case of crash. for that, can use coredump_filter ( http://man7.org/linux/man-pages/man5/core.5.html ) the man page provides following description the value in file bit mask of memory mapping types (see mmap(2)). if bit set in mask, memory mappings of corresponding type dumped; otherwise not dumped. bits in file have following meanings: bit 0 dump anonymous private mappings. bit 1 dump anonymous shared mappings. bit 2 dump file-backed private mappings. bit 3 dump file-backed shared mappings. bit 4 (since linux 2.6.24) dump elf headers. bit 5 (since linux 2.6.28) dump private huge pages. bit 6 (since linux 2.6.28) dump shared huge pages. i looking know bit set , reset in case. not clear these fields specially private , shared. i have buffer (unsigned char*) memory. not want dumped core file in case of c...

ios - Selecting and Deselecting UITableViewCells - Swift -

currently able tap cell , select using didselectrowatindexpath . however, unable deselect when tapped. wish toggle these 2 features. func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { var selectedcell = tableview.cellforrowatindexpath(indexpath)! selectedcell.backgroundcolor = uicolor.purplecolor() tableview.deselectrowatindexpath(indexpath, animated: true) } i have tableview in view controller . the datasource , delegate set up. multiple selection enabled in uibuilder table. i have sworn tried before , didn't work then. i decided use 2 functions.. func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { var selectedcell = tableview.cellforrowatindexpath(indexpath)! selectedcell.backgroundcolor = uicolor.purplecolor() } func tableview(tableview: uitableview, diddeselectrowatindexpath indexpath: nsindexpath) { var deselectedcell = tableview.cellforr...

How to accelerate a mysql query on vb6? -

i have table in mysql 6.000.000 records. i executing query: cmd.commandtext = "select * registro.cedcne trim(cedula) = '" & trim(txtcedula.text) & "' limit 1" the problem query slow. result in 15 minutes. when execute query using phpmyadmin result less 1 minute. thanks help!

html - How to parse code after it has been stripped of styles and elements in python -

this basic question regarding html parsing: i new python(coding,computer science, etc), teaching myself parse html , have imported both pattern , beautiful soup modules parse with. found code on internet cut out formatting. import requests import json import urllib lxml import etree pattern import web bs4 import beautifulsoup url = "http://webrates.truefx.com/rates/connect.html?f=html" html = urllib.urlopen(url).read() soup = beautifulsoup(html) # kill script , style elements script in soup(["script", "style"]): script.extract() # rip out # text text = soup.get_text() # break lines , remove leading , trailing space on each lines = (line.strip() line in text.splitlines()) # break multi-headlines line each chunks = (phrase.strip() line in lines phrase in line.split(" ")) # drop blank lines text = '\n'.join(chunk chunk in chunks if chunk) print(text) this produces following output: eur/usd14265522866931.056661.0567...

capitalization - Why does my ruby pig latin translator not capitalize the first word of a string properly? -

i trying write program translates string capitalized words , punctuation pig latin. here conditions: 1) words beginning vowel should tack on "ay". 2) words beginning single phoneme "sch" or "qu" or "squ" or "ch" should move of characters end, not first letter, , tack on "ay". 3) regular pig latin rules word beginning 1 consonant (i.e., "well," => 'ellway,"). 4) capitalization , punctuation should preserved, initial letter change if letter doesn't begin vowel. "well," become "ellway,". everything works, except first word of string. fourth condition never met first word of string. so, example, "well," becomes "ellway,". punctuation works, capitalization isn't working properly. edit: have realized issue occurs when word not begin vowel. so, "actually," becomes "actuallyay," (which should), "quaint," becomes "ai...

python - How to Apply Reverse Logic for Decoding? -

i'm on last part of decoding python exercise, , confusing me. encoding represents 376th 65912th word 3 chars: first char (0xfa), second ((code - 376) // 256), , third ((code - 376) % 256). for example, if code 30000, first output char 0xfa, second 0x73, , third 0xb8. (the code 376 fa 00 00.) now here's confusion, how can interpret 0xfa 0x73 0xb8 30000? because word 30000th word dictionary. appreciated, thanks. check first char, if 0xfa, code = second * 256 + third + 376

bash - How to extract numbers and special characters in a string in linux script -

i have string basedir=/cp/osp/peaker/1543.23. here want extract 1543.23, in linux script, tell me how here. may using sed, regex, unable do. here want 1543.23 (so want number , special character . also). you use awk . like echo $basedir | awk 'begin {fs="/"};{print $nf}' that begins setting field separator (fs) "/" , printing last field.

php - How to design database system for a feedback systems? -

hi i'm getting php , mysql , english second language excuse me while try describe question well. i'm trying create feedback system students can leave feedbacks teachers. student log in pick subject first, find teacher teaches subject , can leave feedback of teacher. feedbacks of teacher can seen public(no require login) , teacher can log in have @ feedbacks , mark them read, once feedback marked read won't shown publicly again . the problem i'm having not idea or login system etc, it's database structure. teachers feedback database, first teachers categorised subjects, each individual teacher need store feedbacks, , feedbacks can active(not read yet) or inactive (read). since i'm new php , mysql don't know how design database effective, let's give problem example "display numbers of active feedbacks of teacher" can think of few ways approach this, can't decide way best. solution 1, 1 massive database store , first need...

inkscape save image svg does not store curve -

Image
i have svg file xml code the code convert curve.svg curve.png works fine. but using inkscape: inkscape -e curve.png curve.svg background rrggbbaa: ffffff00 area 0:0:1000:600 exported 1000 x 600 pixels (90 dpi) bitmap saved as: curve.png gives me image no curve: inkscape not appear commas in d attribute value of <path> . don't know if bug, known limitation, or because of svg spec; don't know svgs--sorry. :-) however, if remove commas value of d , seems work fine. one possible way on linux simple awk command (not robust, works particular file--just tried in troubleshooting): awk '/<path /{gsub(", l", " l")}{print}' with-commas.svg > working.svg if find need massage xml in "production-grade" application, please use actual xml parser , remove commas appropriately, rather relying on silly awk script. :-)

Compile-time aspects throwing NoSuchMethodError in Spring Boot -

Image
i getting error when running "compile-time-weaver" classes maven on jar file included in spring boot 1.2.2 war. so, have jar, ctms-components.jar, run aspect (e.g., method timing profiler) on using maven. then, spring boot puts in embedded war (i'm using tomcat). see both aspectj woven classes ajc closures(), etc. , see logs maven weaving classes per pointcuts. <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>aspectj-maven-plugin</artifactid> <version>1.7</version> <configuration> <showweaveinfo>true</showweaveinfo> <source>${compiler.version}</source> <target>${compiler.version}</target> <xlint>ignore</xlint> <compliancelevel>${compiler.version}</compliancelevel> <encoding>utf-8</encoding...

windows - Batch file to recursively find files named a specific name and move to a directory -

so, hit cryptowall 3.0 ransomware virus. after decryption still left large amount of decrypt_help files in .txt, .html, .png , windows shortcut formats. i need batch script recursively find files containing name "decrypt_help" regardless of its' extension , move files directory delete. i linux guy, can't find , grep way through this. assistance appreciated. you can find files using dir /s *decrypt_help* dangerous command follows del /s *decrypt_help* will delete of files. use extreme caution

c++ - Object initialized with random numbers -

i'm pretty new c++ , oo, pretty silly. in code right after include statements. enum objtype { cube, cone, }; typedef struct { objtype type; float x; float y; float z; int selected; } object; static object objects[] = { { cube, rand()%11-4, rand()%-10-5, rand()%-65-55, 0}, { cone, rand()%11-4, rand()%-10-5, rand()%-65-55, 0}, } i make call srand, passing in current time, in main method. however, generating same random numbers every time program wrong. not understanding? as zenith says, initialization of globals happens before main() . srand() run first doing declaring global variable initialization calls srand() , , comes before initialization of static object objects[] : static int x = (srand(time(null)), 10); static object objects[] = { { cube, rand()%11-4, rand()%-10-5, rand()%-65-55, 0}, { cone, rand()%11-4, rand()%-10-5, rand()%-65-55, 0}, }; but global variables bad idea anyway, , relying on things initialization order (...

winapi - Windows API: write to screen as on screen display -

i writing (very) small application performs minor things @ start , should write message on screen similar on-screen-display: big letters, without window, above everything, visible moment , fade away. if possible not want create window it. what right way this? (i hope there no special toolkits directx, direct graphics access etc. required) as pointed out in comments, can draw directly screen. getdc offers return appropriate device context: hwnd [in] a handle window dc retrieved. if value null, getdc retrieves dc entire screen. rendering directly screen poses @ least 2 problems need addressed: the screen dc shared resource. whenever else renders screen (e.g. when window displayed), portion of screen gets overwritten. rendering destructive. when rendering device context, original contents overwritten. implement fade-out effect have save original contents (and update them dynamically other windows displayed). both issues can solved creating window ...

.net - Better pattern to pass third party exceptions to WCF service callers? -

i developing wcf solution consumes third party services. user inputs , actions validated third party services, meaning service knows has gone wrong when receives third party exceptions. i need set translate , pass such exceptions callers of own service, because original exceptions' messages technical callers though want them know has gone wrong. the solution thinking of, use microsoft enterprise library exception handling, custom handlers, catch third party exceptions, , replace original messages more friendly messages (from mapping table or alike) assign error code, throw soap faults. full list of third party exceptions unknown, know of them - unknown ones planning replace generic message , error code, , log original exception. i think solution work, there may better ways, posting question seek expertise. please share thoughts. main goals have third party exceptions handled elegantly (easy maintain handling code) , messages translated (easily configurable translation set...

image - Save list in Python -

i want save list of strings in python array. code below: import os images_list=[os.listdir("/home/metal-machine/pictures/new")] print images_list[0] it prints list in [0] , when use print images_list[1] it returns error as: indexerror: list index out of range i sure "index out of range" because elements of list not separated comma. for can use split() method in python. images_list.split() and above command splits files putting commas in-between of them, why python by-default not put commas in between elements? sunch kind of list valid in python? why not write code bit more error free for images in images_list: print images

.net - Can we use different storage engine in SQL Server -

i mysql proving different types of storage engine innodb etc. , every storage engine have different features others. i want know if have such type of mechanism in sql server also? if yes how can use these engines in sql server? and possible sql server provide nosql types storage engine in future?

perl - How to make an array containing strings in a file separated by space? -

i have file perl_script_2_out_2.txt , want put strings separated space in array @arr . i wrote code isnt working . open $file4, '<', 'perl_script_2_out_2.txt' or die $!; @array4 = <file4>; close($file4); open $file5, '>', 'perl_script_2_out_2.txt' or die $!; foreach $_ (@array4) { s/\s+/\n/g; print $file5 "$_"; } close($file5); open $file6, '<', 'perl_script_2_out_2.txt' or die $!; @arr = <$file6>; you must always use strict , use warnings @ top of every perl program write. in case have seen message name "main::file4" used once: possible typo which points statement my @array4 = <file4> and helps see have opened file handle $file4 tried read file4 , different. if fix code work, it's strange way things , it's better this. have used data::dump display final contents of array; it's not necessary program work. use strict; use warnings; open $fh...

android - Why isn't my EditText styled to match my AlertDialog? -

Image
i trying create alertdialog single text field prompt. here code using create it: final edittext url = new edittext(this); new alertdialog.builder(this, alertdialog.theme_device_default_dark) .settitle(r.string.mirror_title) .setview(url) .setpositivebutton(...) .setnegativebutton(...) .show(); when run against api level 22, buttons style using material expected, edittext not: what need new style edittext here? you specifying @android:style/theme.devicedefault alert dialog theme, edittext using whatever theme set on context represented this . to ensure consistency between alert dialog's decor , contents, should create contents using alert dialog's themed context. alertdialog.builder dialogbuilder = new alertdialog.builder(this, ...) .settitle(r.string.mirror_title) .setpositivebutton(...) .setnegativebutton(...); context dialogcontext = dialogbuilder.getcontext(); edittext url = new edittext(dialogcontext); dialogbuilder.set...

c# - How to find the paragraph node is within the table node in OpenXML -

i have tried in following code sample ancestor property find paragraph node within table node it's not working cases. using (wordprocessingdocument docx = wordprocessingdocument.open(docxstream, true)) { body docxbody = docx.maindocumentpart.document.body; list<openxmlelement> eachpara = new list<openxmlelement>();//paragraph element foreach (openxmlelement bodychild in docxbody.childelements) { if (bodychild paragraph) { if (bodychild.ancestors<table>().tolist().count > 0) { } } } // list<openxmlelement> eachpara = docxbody.childelements.tolist().where(eachchild => eachchild paragraph).tolist(); foreach (openxmlelement lstpara in eachpara) { if (lstpara.childelements.any(ch => ch.localname.tolower().equals("run"))) { } else { } } }

c++ - Reading data from a file and storing it into a vector -

i'm trying read list of items from file , store them vector. issue code adding last item vector twice , i'm not sure why keeps reading file though program has reached end. here's what's in text file. "oranges" line appears twice when display contents of vector. apples-pounds-10 2 oranges-pounds-5 6 here's code //read contents of list file while (!inputfile.fail()) { //extract line list getline(inputfile,item_name,'-'); getline(inputfile,item_unit,'-'); inputfile >> item_amount; inputfile >> item_price; //create instance of item object item new_item(item_name, item_unit, item_amount,item_price); //push list vector list.push_back(new_item); } //close file inputfile.close(); the problem "fail" flag not set until make attempt @ reading more data file. here quick way of fixing this: for (;;) { //extract line list getline(inputfile,item_name,'-...

java - Where to upload files in Tomcat? -

i have web application developed using servlet , jsp, hosting in daily razor privat tomcat hosting soon. but, have problem. have form users can upload files server, files images , pdf's. now, not sure in place should save these files in server. have seen lot of stackoverflow answers telling user use path "c:/upload/.." real product, not gonna work. i contacted hosting company matter , said give ftp logging details once purchased system, no word upload files. i thought uploading amazon s3, have create folders "dynamically" each user , subfolders uploaded content, therefor not sure s3. apart that, believe s3 drain wallet. any advice upload location in tomcat or alternate appreciated. but, have problem. have form users can upload files server, files images , pdf's. now, not sure in place should save these files in server. if you're talking long-term storage there's no correct answer here. you'd need find place on server ...

symfony - Goutte Scrape Login to https Secure Website -

so i'm trying use goutte login https website following error: curl error 60: ssl certificate problem: unable local issuer certificate 500 internal server error - requestexception 1 linked exception: ringexception and code creator of goutte says use: use goutte\client; $client = new client(); $crawler = $client->request('get', 'http://github.com/'); $crawler = $client->click($crawler->selectlink('sign in')->link()); $form = $crawler->selectbutton('sign in')->form(); $crawler = $client->submit($form, array('login' => 'fabpot', 'password' => 'xxxxxx')); $crawler->filter('.flash-error')->each(function ($node) { print $node->text()."\n"; }); or here's come code symfony recommends: use goutte\client; // make real request external site $client = new client(); $crawler = $client->request('get', 'https://github.com/login');...

php - Retrieve Results from DB with Foreach -

i thought easier thing do, i'm trying better coding practices , keep hearing while not way loop results, i'm trying switch , thought had down, no dice. original code have been public function getsitename() { $query = <<<sql select site_name site_details sql; $resource = $this->db->prepare( $query ); $resource->execute(); while($row = $resource->fetch(pdo::fetch_assoc)){ echo $row['site_name']; } } so i've tried changing foreach loop , i've gotten million different ways using mysql extensions. (i'm positive 99% of people it's better use while loop go mysql , use deprecated function) instead i'm trying isn't working public function getsitename(){ $query = <<<sql select site_name site_details sql; $resource = $this->db->prepare( $query ); $resource->execute(); $result = $resource->fetch(pdo::fetch_assoc); foreach($result $detail){ echo $detail->site_name; } } i'm not sure i'm...

python - GAE - Upload optimized image to cloud storage -

i'm working on simple app takes images optimizes them , saves them in cloud storage. found example takes file , uses pil optimize it. code looks this: def inplaceoptimizeimage(photo_blob): blob_key = photo_blob.key() new_blob_key = none img = image.open(photo_blob.open()) output = stringio.stringio() img.save(output,img.format, optimized=true,quality=90) opt_img = output.getvalue() output.close() # create file file_name = files.blobstore.create(mime_type=photo_blob.content_type) # open file , write files.open(file_name, 'a') f: f.write(opt_img) # finalize file. before attempting read it. files.finalize(file_name) # file's blob key return files.blobstore.get_blob_key(file_name) this works fine locally (although don't know how it's being optimized because when run uploaded image through http://www.jpegmini.com/ gets redu...

browser - Is there a way to uniquely identify a web user? -

i want identify every anonymous person accessing web portal uniquely (crazy, know!). using session id in combination ip, however, since session id cookie based, can cleared , identity can forged. browsing other thread , had said attribute named "pcrsa" can obtained browsers , can used uniquely identify user. ever since, i've trying locate further info regarding pcrsa no avail. have info regarding pcrsa or alternatively, better way uniquely identify anonymous connections?

c# - SQLite-Net Extensions how to correctly update object recursively -

i using sqlite-net pcl sqlite-net extensions development of application using xamarin. i have 1 many relationship between 2 classes a , b defined follows: public class { [primarykey, autoincrement] public int id { get; set; } public string name { get; set; } [onetomany(cascadeoperations = cascadeoperation.all)] public list<b> sons { get; set; } public a() { } public a(string name, list<b> sons) { name = name; sons = sons; } } public class b { [primarykey, autoincrement] public int id { get; set; } public string name { get; set; } [foreignkey(typeof(a))] public int fatherid { get; set; } [manytoone] public father { get; set; } public b() { } public b(string name) { name ...

asp.net mvc - <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> -

i following error below after opening , compiling mvc4 project in vs 2010. cs1705: assembly 'sdem, version=1.0.0.0, culture=neutral, publickeytoken=null' uses 'system.web.mvc, version=4.0.0.1, culture=neutral, publickeytoken=31bf3856ad364e35' has higher version referenced assembly 'system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' in web.config have <add assembly="system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> anyone have clue should solve version problem? it shows assembly referenced in project has different version(4.0.0.1) have in web.config(4.0.0.0). please check referenced assembly system.web.mvc same written in web.config. if not add reference appropriate assembly. right click references -> add reference -> ...

file io - C++ FileIO weird behaviour -

while writing program came accross strange behaviour of std::ofstream . please refer code below ofstream dire; dire.open("dir.txt", std::ios::out); // other code for(int i=0;i<dir.size();i++) { dire << dir[i] << "\t"; // dir integer vector containing values between 0-9 } now when open dir.txt contents are: ऴऴऴऴवववववववववशशशशशशशशशशषषषषषषषषरररररररऱऱऱऱऱऱऱऱऱललललललललललललळ.. , on if give space , tab(\t) works correctly or matter \n works correctly. dire << dir[i] << " \t"; and output is: 4 4 4 4 5 5 5 5 5 5.. , on i tried dire.flush() flush output buffer file, still same result. i can away using \t learn why happening. if using notepad @ file bug bush hid facts can problem. the bug occurs when string passed win32 charset detection function istextunicode no other characters. istextunicode sees thinks valid utf-16le chinese , returns true, , application incorrectly interprets ...

jquery - Parts of ajax function can just be reached by debugging -

i have asp.net application in user jquery. in jquery code have simple ajax request this: var allowdelete = true; $.ajax({ url: '...', datatype: 'json', type: 'post', data: { something...} }) .success(function (response) { if (response.passed) { //do } else { //do allowdelete = false; } }) .error(function () { // }); if (allowdelete) { //something } as can see want var set false when passed var has value false. when run code without breakpoints allowdelete var never set false. , when put breakpoint(in firebug) next row set allowdelete false never hits breakpoint. when put breakpoint @ beginnig of function , debug through whole ajax works fine , result wanted. idea mistake be? since asked question more 1 month ago, might...

java - Two jar files into one exe -

i've made tic tac toe in java , i've got 2 jar files. i want put them both 1 exe. is possible, or have convert main file , 1 way? i've never done before. need suggestions implementation. to make exe file need define 1 jar point of execution. jar must contain main() method. if have 2 jars , contain main method, can call first's jar's main method in second's main method , declare second jar point of execution. like this: class first { public static void main(string[] arg) { //excution code } } class second { public static void main(string[] arg) { first.main(arg); } } i hope help.

Git interactive rebase without opening the editor -

git allows commands create or modify commits without opening editor first, example: git commit --amend --no-edit git commit --fixup=head^ i have set rebase.autosquash true , todo list interactive rebase automatically reordered. there way perform rebase, without opening editor first, like: git rebase -i --no-edit head~3 tl;dr answer: git_sequence_editor=: git rebase -i head~3 you can't stop git rebase --interactive running "sequence editor" (that's edit command on "sequence file" containing various pick, etc., commands). however, if examine interactive rebase script: $ vim $(git --exec-path)/git-rebase--interactive you'll find code near line 230 or so: git_sequence_editor () { if test -z "$git_sequence_editor" git_sequence_editor="$(git config sequence.editor)" if [ -z "$git_sequence_editor" ] git_sequence_editor="$(git var git_editor)" || ret...

ios - Title in Settings bundle not showing in the Settings -

Image
i've pasted screen shot. text area visible title not showing in settings page. couldn't figure out. you need add new row, under default value key "identifier". should works ;) update 1: i've tested swift project, , works fine: next, code in appdelegate: finally, result in simulator:

caching - Glassfish 4.1 gzip and cache problems -

i have made following changes in configurations/server-config/network config/network listeners (and protocols)/http-listener-1/ http tab : compression: on, mime types: text/html,text/xml,text/plain,text/css,application/javascript,application/json,text/xml,text/javascript, minimum size: 1 b file cache tab : status: enabled, max age: 6000 seconds (or more) chome developer tools warns me leverage browser caching (the following resources missing cache expiration... .css, .js, images, etc. files) , pagespeed insights tool warns me compressing of .js files (and images) disabled (although have set application/javascript , text/javascript in mime types). warns me static resources (.css, .js, images, etc.) missing cache expiration chrome developer tools. want know need enable caching of static resources , gzip of files mime type have set. thank you.

c++ - How to read words instead of characters? -

i trying read bunch of words .txt document , can manage read characters , display them yet. i'd same whole words. my code: #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream infile("banned.txt"); if (!infile) { cout << "error: "; cout << "can't open input file\n"; } infile >> noskipws; while (!infile.eof()) { char ch; infile >> ch; // useful check read isn't end of file // - stops character being output @ end of loop if (!infile.eof()) { cout << ch << endl; } } system("pause"); } change char ch; std::string word; , infile >> ch; infile >> word; , you're done. or better loop this: std::string word; while (infile >> word) { cout << word << endl; }

javascript - How to hide the select value from the form -

i have form have select drop down. have disabled default , re enable based on conditions. don't want access select option values when disabled(now can viewed inspecting element browser). how make secure? i don't think can. might better off populating when it's needed instead of enabling it. ajax call.

File upload in PHP giving error -

i building web app using php.i creating file upload section in having problem. <form action="upload.php" method="post" enctype="multipart/form-data"> select image upload: <input type="file" name="filetoupload" id="filetoupload"> <input type="submit" value="upload image" name="submit"> </form> upload.php: <?php $target_dir = "images/"; $target_file = $target_dir . basename($_files["filetoupload"]["name"]); $uploadok = 1; $imagefiletype = pathinfo($target_file,pathinfo_extension); // check if image file actual image or fake image if(isset($_post["submit"])) { $check = getimagesize($_files["filetoupload"]["tmp_name"]); if($check !== false) { echo "file image - " . $check["mime"] . "."; $uploadok = 1; } else { echo "file not image."; $uploadok = 0; } ...

drupal - Get out an error message if noone of checkboxes selected -

i have set checkboxes form works perfect, have if statement works perfect want when user hasn't selectected checkbox list, when pushes save button out drupal error says "oh!you not select nothing"... how can thing? if (!$selected) { drupal_set_message(t('you have select @ least 1 option list.'), 'warning'); } you can set message manually code: https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_message/7 where have if logic add drupal_set_message() call.

git push to https repository from Intranet application with kerberos authentication -

first of all, i'm new https, ssl , authentication in general. i develop intranet application should realize "push" local git repository (hosted on web server) , remote repository (hosted on unix server). the web server windows 2003 server iis installed. installed windows git extensions on machine. remote git url looks : " https://username@server.domain.fr/team_folder/project.git ". on web server, when want push on remote repository git bash, openssh popup displayed , windows password asked. if enter correct password, push performed. caused "askpass" configuration. core.askpass = c:/program files (x86)/git/libexec/git-core/git-gui--askpass if remove configuration's parameter, git prompt password in command window. normal... my question : use kerberos authentication, possible realize push operation without asking password user ? , how ?. tried configure putty no success moment (like wrote, i'm not specialist of authentication). ...