Posts

Showing posts from August, 2010

php - Rewrite URL from my form using get request in htaccess -

i want rewite url example.org/search.php?by_what=date&keywords=sample example.org/search/date/sample . here code : in search.php <form name="frmsearch" action="search.php" method="get"> <div class="row searchbox-container"> <div class="twelve columns"> <div class="row collapse"> <div class="nine columns"> <input type="hidden" name="by_what" value="manning_agency"> <center> <input type="text" placeholder="type agency name here" name="keywords" id="keywords" size="40" class="small-txtbox-search-inner" value="<? echo $keywords; ?>" /> </center> ...

setting "server name" when using kestrel with dotnet core -

i writing app using asp.net mvc right runs against microsoft's kestrel server. works fine, , pass values @ startup using hosting.json file defined follows; { "server": "microsoft.aspnet.server.kestrel", "server.urls": "http://localhost:5000;https://localhost:5001" } is there way give "server" name, isn't reporting localhost or undefined time? please replace localhost * . give below benefits: if give localhost , can access application through http://localhost:5000 , not using ip [ http://192.168.1.2:5000 , example]. using * , can access through ip. you can connect server other pcs or mobile devices. a few days back, had same requirements yours , got solution from: docs.asp.net . [the comments section hidden default. please click show comments , search localhost .] tip 1: view application mobile device, please check: viewing localhost website mobile device . tip 2: question , answer ha...

c# - MVC4 Razor template like -

hello have simple question think, i have cshtml like: <div id="box"> @if (model.view == "item1") { <div id="item1"> ... </div> } else { <div id="item2"> ... </div> } <div id="itemdescription"> ... </div> </div> where pass parameter via model display content depending on parameter, because rest of document same in both cases. is there better way achieve this? thanks! not really; way of doing things. if div id matches value of model.view , shorten this: <div id="box"> <div id="@(model.view)"> ... </div> <div id="itemdescription"> ... </div> </div> otherwise, approach fine. per von v's comment, might want partial views if contained markup long-winded (or need repeat ...

machine learning - How to change threshold for precision and recall in python scikit-learn? -

i have heard people saying can adjust threshold tweak trade-off between precision , recall, can't find actual example of how that. my code: for in mass[k]: df = df_temp # reset df before each loop #$$ #$$ if 1==1: ###if == singleethnic: count+=1 ethnicity_tar = str(i) # fr, en, ir, sc, others, ab, rus, ch, it, jp # fn, metis, inuit; algonquian, iroquoian, athapaskan, wakashan, siouan, salish, tsimshian, kootenay ############################################ ############################################ def ethnicity_target(row): try: if row[ethnicity_var] == ethnicity_tar: return 1 else: return 0 except: return none df['ethnicity_scan'] = df.apply(ethnicity_target, axis=1) print '1=', ethnicity_tar print '0=', 'non-'+ethnicity_tar # random sampling ...

Creating a schema in Cassandra using Phantom Scala DSL -

i have written code case class user(id: int, gender: string, age: int, occupation: string, zipcode: string) object defaults { val hosts = seq("172.17.0.9") val connector = contactpoints(hosts).keyspace("movies") } class mydatabase(val keyspace: keyspacedef) extends com.websudos.phantom.db.databaseimpl(keyspace) { object users extends users keyspace.connector } object mydatabase extends mydatabase(defaults.connector) class users extends cassandratable[users, user] { object id extends intcolumn(this) partitionkey[int] object age extends intcolumn(this) index[int] object gender extends stringcolumn(this) index[string] object occupation extends stringcolumn(this) index[string] object zipcode extends stringcolumn(this) index[string] def fromrow(row: row) : user = { user( row(id), row(gender), row(age), row(occupation), row(zipcode) ) } } object users extends users rootconnector { def store(user: user)...

c - "ld returned 1 exit status" and "incompatible implicit declaration of built-in function 'exit' " -

i bored, started study new, in case, c. i trying basic script in c i'm having error, , don't know wrong. //tablas #include <stdio.h> int main() { double i, j, p; int x, y; printf ("tablas del: "); scanf ("%i", &x); printf ("hasta el: "); scanf ("%i", &y); file *f; f = fopen("tablas.txt", "w"); if (f == null) { printf("no se ha podido abrir/crear/reemplazar el archivo\n\a"); exit(1); } printf ("espere mientras se calcula los resulatdos.\n"); system ("del tablas.txt"); (i = x ; <= y ; i++) { (j = x ; j <= 10 ; j++) { fprinf(f, "%f x %f = %f\n", i, j, i*j); } } printf ("\nfin\n\a"); system ("pause"); return 0; } you need #include <stdlib.h> exit work.

reusability - How to reuse form in codeigniter for update and add -

hello want reuse form in codeigniter problem update form populated 1 page has load. here sample form. <?php $attributes = array('class' => 'form-horizontal', 'id' => 'addpersonnel'); echo form_open($form_submission, $attributes); ?> <input type="text" name="name" value="<?php echo set_value('name')?"> > <input type="text" name="rank" value="<?php echo set_value('rank')?"> > <button type="submit" class="btn btn-primary">save</button> <?php echo form_close()?> my problem here lies in set_value() method of form_validation class since have conflict populating form if updating. in controller update function add condition like: if ($this->input->server('request_method') === 'post') { $th...

javascript - How to pass routeparams value in model window angularjs? -

in project trying implement modal window edit screen. have listed screen users need select 1 row list , click modify button. need open edit screen in modal window. if call normal screen using this: $location.path(url) (i.e) url -- > page1/:id --> page1/3 which working fine. it's redirecting corresponding page data. but in modal window call this: exdialog.openprime({ scope: $scope, template: urlappbase+templateurl, controller: controllername, width: '1120px', animation: false, graybackground: false }); how send params value controller? or how open modal window based on url? in stateparams .state('users', { url:'/users/:userid', .... }) if url = '/#/users/2', in controller follows var usrid = $stateparams.userid; in routeparams, .when('/users/:userid', { .... }) if url = '/#/users/2', in controller follows var usrid = ...

intuit partner platform - Fetch Data from Quickbook -

hello guys i'm new quickbooks. there data in quickbooks i'm trying retrieve quickbooks returning nothing. can figure out i'm doing wrong. i'm trying retrieve data quickbooks. php $servicetype = intuitservicestype::qbo; $realmid = $this->ci->session->userdata('realmid'); $token = unserialize($this->ci->session->userdata('token')); $requestvalidator = new oauthrequestvalidator($token["oauth_token"], $token["oauth_token_secret"], $this->ci->config->item('oauth_consumer_key'), $this->ci->config->item('oauth_consumer_secret')); $servicecontext = new servicecontext($realmid, $servicetype, $requestvalidator); $dataservice = new dataservice($servicecontext); $entities = $dataservice->query("select * salesreceipt"); error_log(print_r($entities , true)); can tell me i'm doing wrong. the first thing ...

iphone - Enabled UIBarButtonSystemItemSave not blue on iOS 7 -

i have problem uibarbuttonitem of type uibarbuttonsystemitemsave . on app i'm working on, test on compatibility mode xcode 4 on ipad has ios 7, colour of uibarbuttonitem of type uibarbuttonsystemitemsave not blue should. if change type uibarbuttonsystemitemdone , button looks normal("done" button blue background colour). did had problem on apps while testing compatibility ios 7?

C++ Declare array whose size value from const array -

i'm trying define stack c-style array size taken const array , known in compile-time. const int size[2]={100, 100}; int ar[size[0]]; //error: expression must have constant value it fails. how can fixed? "array size taken const array , known in compile-time " with c++11 can have : constexpr int size[2]={100, 100}; // size[0] compile-time constant use -std=c++11 or -std=c++0x compile

css - Regular Expression - replace urls in style tags -

i have searched on google , stackoverflow didnt find answer. tryed myself, iam no regex guru. my goal replace relative urls in html style tag absolute version. e.g. style="url(/test.png)" style="url(http://mysite.com/test.png)" style="url("/test.png")" style="url("http://mysite.com/test.png")" style="url('/test.png')" style="url('http://mysite.com/test.png')" style="url(../test.png)" style="url(http://mysite.com/test.png)" style="url("../test.png")" style="url('http://mysite.com/test.png')" style="url('../test.png')" style="url('http://mysite.com/test.png')" and on. here tryed poor regex "skils" url\((?<url>[^\)]*)\) gives me url in "url" function. thanks in advance! well, can try regex: style="url\((['"])?(?:\.\.)?(...

design patterns - state sharing with push & pull via redis -

i share state via redis following requirements: decoupling: uncoupled publishers , subscribers single ownership: each state set single publisher push: once state changes relevant subscribers must notified pull: once subscriber initializes should pull relevant states if push required without pull pub\sub optimal if pull required without push simple redis key , value work well what best design pattern support requirements? one solution use both pub\sub publish (push) state changes , hash keep latest published state of each kind subscriber can read (pull) the hurdle need handle race conditions follows: publisher should notify , update state subscriber should first subscribe , read state

unicode - How to programatically identify the character set of a file? -

this question has answer here: how detect character encoding of text file? 8 answers from detailed perspective how 1 identify character set of file? information found checking magic number of file, other articles found strayed away this. i have tried opening different files encoded in different character sets (ascii/utf8 example) hexdump , there no file identifier on character set file is. it practically impossible identify arbitrary character sets looking @ raw byte dump. character sets show typical patterns can identified, still doesn't make clear match. best can typically guess exclusion, starting character sets have rules. if file not valid in utf-8, try shift-jis, big-5 etc... problem any file valid in latin-1 , other single byte encodings. that's makes fundamentally impossible. it's virtually impossible distinguish 1 single-byte charset...

java - Using thread Executors in SWT? -

is there way manage (start/stop) threads using executors / threadpools within swt app? threads need update ui thread changes can reflected when / done. possible? display.asyncexec() takes runnable thread option, i'm not sure how best accomplish this. just create runnable want in thread: display.getdefault().asynchexec(new runnable() { public void run() { ... code update ui here } });

max - What is maximum size of file we can store in inode -

what maximum size of file handled single indirect , double indirect? block size 2k address size 4 bytes 12 slots direct disk blocks one slot each single indirect , double indirect. note: kindly explain learning great if explain it check out doc 1 of old eng courses: http://classes.engr.oregonstate.edu/eecs/winter2011/cs311/inode.pdf

android - could not access WakefulBroadcastReceiver that is in present in external library -

i doing push notification using gcm written in sdk,developer needs add sdk library project ,my sdk uses context developer , creates registeration id ,but when push server using id not receive notification in fact receiver class not invoked manifest file in sdk has <receiver android:name=".gcmbroadcastreceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <!-- receives actual messages. --> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="com.mysdk" /> </intent-filter> </receiver> <service android:name=".gcmintentservice" /> permission has <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.get_accou...

python - Solving minimum set cover using available libraries -

i solve instance of minimum set cover . 1 possibility, there way of formulating problem bipartite graph , using networkx? update using dlx (dancing links) suggested in comments. can give small working example of how solve minimum set cover problem using dlx? set cover can mapped np-complete problem on graph, doesn't mean you'll able solve efficiently. there reason don't focus directly on problem @ hand (ie, set cover)? maybe like: pypi.python.org/pypi/dlx this can installed using: pip install dlx or easy_install dlx

java - How to port a Gradle based Android Studio project to Eclipse? -

i trying port couchbaselite project android studio eclipse uses maven. how can achieve this? if needed, project's link here. http://docs.couchbase.com/couchbase-lite/cbl-android/#getting-started android studio uses gradle, not maven, artifacts downloaded maven repositories. question not related maven. gradle has support eclipse, add eclipse plugin apply plugin: "eclipse" and invoke gradle eclipse more options described here: import existing gradle git project eclipse other option use gradle integration eclipse

plasticscm - Is there a public Plastic SCM test server I can connect to? -

is there public plastic scm test server can connect make sure client working? you can follow evaluation guide here: http://www.plasticscm.com/evaluation-guide/index.html that being said, there several ways check ready: go command line type cm lrep yourserver:port sample: cm lrep localhost:8087 if returns repositories, working alternatively can run the: cm cc command stands "check connection" against server configured default. i prefer cm lrep though.

PHP File renaming gone wrong -

i have 12 css files in system, , rename them whenever users want change style. store current style in database, , rename style.css style $color .css, renaming style $requestedcolor .css style.css right after that. here's code: if ($_post['blue'] == "blue") { if(file_exists('./css/styleblue.css')) { $old = './css/style.css'; $new = './css/style'.$color.'.css'; $old1 = './css/styleblue.css'; $new1 = './css/style.css'; rename($old, $new); rename($old1, $new1); $newcolor = "blue"; $idnum = "1"; mysql_query("update company set color = '$newcolor' id = '$idnum'"); } } problem is, (not always, finding hard diagnose when , why) end loosing file, while system grabs random .css file, renames style.css , writes correct $newcolor database. maybe renaming goes fast? or should grab each of these ifs (there's 12) info $color v...

java - how to return an entity from restful client -

i have been days. trying return persistent entity restful web resource using jersey client. there r 2 entities in 1 many relation each other. seem work fine when part of getting collection entity relationship goes burst. while jersey client can lookup xml representations of related entity bad job of getting entity collection of related entity..how go this. examples b appreciated. assume have restful web service across globe , being access jersey restful client

jQuery how to take the href of a link in a child element and use it somewhere else -

my page has link @ bottom i've assigned id to... <a id="nbwalink" class="learn-more"> learn more </a> above this, there rss feed inserting page outputs it's first link as... <div id="rssincl-box-767647"> <div class="rssincl-content"> <div class="rssincl-entry"> <p class="rssincl-itemtitle"> <a target="_blank" href="http://something.com/somesubfolder/somepage.html"> description of link </a> </p> ...you idea. i trying use jquery this... var nbwahref = $('.rssincl-itemtitle').children('p').eq(0).attr('href'); $('#nbwalink').attr('href',nbwahref); ...to steal link rss link , apply the learn more button. there way this, can't work? =t your selector wrong because p not child of rssincl-itemtitle element, p rssincl-itemtitle element,...

wordpress - Redirect www to non-www and prevent 301 for 404 Errorpage -

i have problems htaccess , hope can me: have wordpress installation in /wordpress directory. if accesses "www.mysite.com" or "mysite.com" want redirect /wordpress . i had on server sites /deleted.html added 404-errorpage: errordocument 404 /wordpress/404.php . works 404-page if access mysite.com/deleted.html not if access www.mysite.com/deleted.html . in case there @ first 301 redirect , 404 page loaded. problem google because can't detect page deleted. how looks like: curl -i -l http://www.mysite.com/deleted.html http/1.1 301 moved permanently date: tue, 24 sep 2013 16:02:18 gmt server: apache/2.2.25 (unix) location: http://mysite.com/deleted.html content-type: text/html; charset=iso-8859-1 http/1.1 404 not found date: tue, 24 sep 2013 16:02:18 gmt server: apache/2.2.25 (unix) x-powered-by: php/5.2.17 expires: wed, 11 jan 1984 05:00:00 gmt cache-control: no-cache, must-revalidate, max-age=0 pragma: no-cache x-ua-compatible: ie=edge,chrome=1 cont...

document.write from external script not executed in an iframe created with javascript / jQuery -

i want add , remove iframe document using javascript / jquery (actually iframe should added , removed if user chooses close it). in iframe, have include external script using element, script contains generated content displayed using document.write (ad rotator). the problem have when iframe loaded, element included content not "interpreted", content not write document.write. i don't know missing here. here tried (inspired other answers on so): html: <!doctype html> <html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="jquery-10.2.js"></script> <script src="frame.js"></script> </head> <body> <div>some content</div> <div id=myframecontainer>​</div>​​​​​​​ </body> </html> frame.js: $(docum...

c# - Pass Parameters to ClickOnce Using ShellExecute -

i attempting use blog pass argument offline click-once application. near bottom of blog there example programs download. downloaded , published program "testrunningwithargs" c# version. now trying pass argument application not working. keeps saying no "no arguments passed in". i trying use following code pass argument: shellexecute("file path\my applicaiton.application","myargument") this code runs application sample application states did not receive argument. language visual basic (maybe 4 or 6?). the code below works , allows internet explorer run , specific file opened sharepoint , wondering if there difference missing. shellexecute("c:\program files\internet explorer\iexplore.exe",filelocation) the 1 see click once .application file vs .exe , there way work? below code click once application, copied supplied example program on blog public partial class mainform : form { public mainform() { initialize...

php - PDO insert record issues -

the insert statement using pdo displays following errors fatal error: call undefined function now() in c:\xampp\htdocs\copytimeline\timeline1\insert.php it seems now() belongs in sql statements not in array. can me fix that. thanks $statement = $db->prepare('insert tb ( session_id,timing) values ( :session_id,:timing)'); $statement->execute(array( ':session_id' => $session_id, ':timing'=> now() )); the mysql function now() can't passed variable. need include in query. $statement = $db->prepare('insert tb (session_id, timing) values (:session_id, now())'); $statement->execute(array( ':session_id' => $session_id )); see mysql pdo now() assigned value - possible?

unity3d - Mecanim alternative to curves -

i'm using mecanim animation system right , don't have pro license using 'curves' option isn't possible. there alternative solution using curves reduce gravity's effect on character during animation, or modify character's collider height , position during animation?

iphone - What is the proper way to show a UIViewController/UIView over a UIView? -

Image
i have uiviewcontroller uitableview , buttons in each cell, 1 button show comments , make comments. need show "bubble view" facebook comments on current view, if user taps in other side need hide bubble (just facebook comments in photos). i have bubble view, no problem that, question proper way show it, , create in storyboard, because have tableview comments , few buttons make new comments. if want display viewcontroller have creating custom container view controller . tableview rootviewcontroller , make child's viewcontroller ("bubble view") frame smaller. necessary forward events "bubble view". additional readings/tutorials http://mobile.tutsplus.com/tutorials/iphone/implementing-container-containment-sliding-menu-controller/ https://developer.apple.com/library/ios/documentation/uikit/reference/uiviewcontroller_class/reference/reference.html#//apple_ref/occ/instp/uiviewcontroller/childviewcontrollers

scala - "Not Implemented" error when testing a Scalatra route with ScalaTest -

i writing tests several scalatra routes. i'm using scala 2.10.2, scalatra 2.2.1, , scalatest 1.9.2; i'm new @ using 3 of these. i'm using eclipse scala ide 3.0.1 scalatest plugin. for scalatrabootstrap have context.mount(new accountscontroller, "/accounts") context.mount(new profilescontroller, "/profiles") inside profilescontroller have following route val addimage = (apioperation[int]("addimage") parameters (pathparam[string]("context").description("profile context"), pathparam[int]("id").description("profile id"), parameter("body", "body data", datatype[scalatrarecord], paramtype = paramtype.body))) post("/:context/:id/images", operation(addimage)) { ... } this tested with test("add profile image") { val json = jobject("name" -> jstring("asdf")) merge jobject("image_file_url" -> jst...

c# - smtp mailSettings from -

is possible use "from" in config file mailmessage.from when creating email in .net. having trouble accessing it. whenever try referring configurationmanager not exist error referencing them, see below. <mailsettings> <smtp from="test@test.org" deliverymethod="network"> <network host="smtpsend" defaultcredentials="true"/> </smtp> </mailsettings> using system.net.mail; using system.net; using system.configuration; using system.net.configuration; mailmessage msg = new mailmessage(); msg.from = ***~~** msg.subject = string.format(subject); msg.isbodyhtml = true; msg.body = body; msg.priority = mailpriority.normal; msg.to.add("me"); smtpclient client = new smtpclient(); client.send(msg); good afternoon have added actual reference system.configuration dll library? can ch...

mime - How to specify multipart HTML code so it's downloaded with 1 GET request -

i want render web page using content type multipart, sniffer logs show multiple requests images on web page. here test code: <!doctype html> <html> <head> <title>multipart/form-data</title> <header><h2>testing multipart/form-data</h2></header> <meta http-equiv="content-type" content="multipart/related; charset=iso-8859-1"/> </head> <body> text outside &lt;form&gt; tag. <form enctype="multipart/form-data" method="post" action="/php/showpostget.php" > <!-- enctype attribute can used if method="post". --> text inside &lt;form&gt; tag.<br /> <input type="submit" value='test'/><br> <form enctype="multipart/text/plain"> name1: <input type="text" name="fname" value=...

What is the application error:6 in Android licensing -

here code: some time application error :3 or :6 , time application not licensed dialog. public class mainactivity extends activity { private static final string base64_public_key = "my public key"; // generate own 20 random bytes, , put them here. private static final byte[] salt = new byte[] { -43, 12, 76, -124, -101, -57, 74, -64, 51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64, 89 }; private textview mstatustext; private button mchecklicensebutton; private licensecheckercallback mlicensecheckercallback; private licensechecker mchecker; // handler on ui thread. private handler mhandler; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_indeterminate_progress); setcontentview(r.layout.main); mstatustext = (textview) findviewbyid(r.id.status_text); mchecklicensebutton = (but...

java - Reading all the RDF files in a directory -

i trying read rdf files in directory, seems reading first file. first file names using file object , try iterate through them, reading each one. dont know if have like model = modelfactory.createdefaultmodel(); after each iteration or close input , output streams or else. code far follows: string inputfilename = ""; model model = modelfactory.createdefaultmodel(); stringwriter out; file folder = new file("d:/filepath"); file[] listoffiles = folder.listfiles(); string result=""; (int = 0; < listoffiles.length; i++) { inputfilename= listoffiles[i].getname(); inputfilename = "d:/filepath/" +inputfilename; system.out.println(inputfilename); inputstream in = filemanager.get().open( inputfilename ); if (in == null) { throw new illegalargumentexception( "file: " + inputfilename + " not found"); } model.read(in, ""); string syntax = "rdf/xml-abbrev"; out...

c# - How to get the Activities of a Workflow from within the rehosted WorkflowDesigner -

in rehosted workflow, if have variable of type of workflowdesigner, , create workflow within (from ui), how list of activities later programmatically? so input instance of workflowdesigner , desired output programmatically list of activities within workflow in c# of course. i take book, url , hints. confused between modelservice , modelitem , sequence , activity , activitybuilder. have been looking @ msn documentation no avail. thanks. found answer : ienumerable<modelitem> xyz = modelservice.find(modelservice.root, typeof(activity)); http://social.msdn.microsoft.com/forums/vstudio/en-us/124c9199-c23c-469c-93c5-309f097dc92e/how-to-get-modelitem-collection-from-the-workflowdesigner

jsf - My p:dialog is never called -

well, problem no dialog inside main page called. i.e: have commandbutton should call "vardialogfindpacientes" don't work. don't know can fix it. look main page: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"> <h:head> </h:head> <h:body> <ui:composition> <p:dialog id="dialogcadastrar" width="900px" height="500px" header="cadastrar orçamento" widgetvar="vardialogcadastrar" modal="true" showeffect="fade"...

javascript - Why can't I trigger default click after acquiring more parameters for an href via AJAX? -

i trying search vendors within mileage radius, in order need coordinates address i'm searching. it's not feasible grab these coordinates front because map search isn't used often. so, want grab coordinates google maps when link clicked (if haven't gotten them already), then continue default browser behavior. code have accomplish this: html <a href="/vendors/search" target="_blank" class="vendormapsearch" data-miles-radius="50" data-address="@model.address.singleline()" data-customer-name="@model.customername" data-customer-id="@model.customerid" data-service-on="@model.serviceon">vendor map search</a> javascript $(document).on('click', 'a.vendormapsearch', function (e) { console.log('handle click'); var $target = $(e.target), data = $target.data(); if (!data.latitude || !data.longitude) { console....

sql server - SQL Subtruct Quantity from the MAX Calculated Value Row with values from another table -

please resolve this, i trying figure out how update table2 using qtytosubtract , product_id table1, recalculating currentqty , balance every time row updated. for each row in table1 need update current qty , balance in table2 subtracting currentqty using row max balance product_id. means same record can updated several times if after subtracting holds max balance still. table1 holds qty subtract: product_id qtytosubtract 11111111 2 11111111 2 11111111 2 22222222 6 22222222 6 table2 needs updated product_id originalqty currentqty balance = initial+ current 11111111 46 12 58 11111111 15 40 55 22222222 6 1 7 22222222 24 6 28 22222222 15 8 23 result should : product_i...

Right syntax of SQL query -

i have 2 tables in sql db: subject(idsub,namesub); topic(idtop,nametop,idsub); all want is: + select count(*) topic numtopic group idsub--> temp table + join 2 table temp , subject --> new table(idsub,namesub,numtopic) but i've tried many time dont know syntax of sql query. help! you can use left join join subject topic . select a.idsub, a.namesub, count(b.idsub) numtopic subject left join topic b on a.idsub = b.idsub group a.idsub, a.namesub

javascript - What is the benefit of using === operator to test for undefined instead of using == operator? -

i test whether javascript variable defined or not, using following test: if (typeof == 'undefined') = 'default value' however, have seen many people suggesting safer use following instead: if (typeof === 'undefined') = 'default value' i aware of difference between == , === operators unable understand why typeof == 'undefined' unsafe. could please scenario in first code example unsafe or lead issues? also, advantages of using latter syntax on first? i unable understand why typeof == 'undefined' unsafe it's not unsafe, it's fine. typeof operator guaranteed return string , you'll comparing 2 strings. abstract equality algorithm behave strict equality .

Multi-file C++ compilation -

(hopefully) quick question can't find answer to: i have been given brief assignment in c++. write 3-file program. there function file, header file, , driver file. here's i've got far: header (test.h): #include <iostream> using namespace std; #ifndef test_h #define test_h int foo (int bar); #endif function (test.cpp): #include <iostream> #include "test.h" using namespace std; int foo (int bar){ bar++; } driver (drive.cpp): #include <iostream> #include "test.h" using namespace std; int main(){ int x = foo(2); cout << x << endl; return x; } when try compile drive.cpp, following error: drive.cpp:(.text+0xe): undefined reference `foo(int)' so...what doing wrong? for small project this, compile .cpp files @ once: g++ main.cpp driver.cpp for larger project, separate compile , link steps: compile: g++ -c main.cpp -o main.o g++ -c driver.cpp -o driver.o link: g++ ma...

why python json.dumps complains about ascii decoding? -

i have following lines in code outs = codecs.getwriter('utf-8')(sys.stdout) # djson contains json message non-ascii chars outs.write(json.dumps(djson,encoding='utf-8', ensure_ascii=false, indent=indent_val)) i getting following exception: outs.write(json.dumps(djson,encoding='utf-8', ensure_ascii=false, indent=indent_val)) file "/usr/lib/python2.7/json/__init__.py", line 238, in dumps **kw).encode(obj) file "/usr/lib/python2.7/json/encoder.py", line 204, in encode return ''.join(chunks) unicodedecodeerror: 'ascii' codec can't decode byte 0xc3 in position 27: ordinal not in range(128) i through specifying encoding='utf-8' in json.dumps statement, avoid type of problem. why still getting error? my guess djson object not contain pure unicode contains mix of unicode , strings encoded utf-8 e.g. fails >>> d = {u'name':u'पाइथन'.encode(...

mysql - Is PHP and SQL enough to count page views and number of downloads? -

can this, if php , mysql enough count page views/number of downloads precisely? need count how many times wallpaper being downloaded. if yes, how can that? lot help. there number of online tutorials creating page hit counters. there several on phpacademy.org alone. you might find 1 helpful: https://phpacademy.org/course/unique-hit-counter and here tutorial video setting google analytics on site: http://www.youtube.com/watch?v=zutnlzzde60 as an article beginners

objective c - UIImageview shadowpath -

i've noticed when set shadowpath on uiimageview's layer property, kills image quality. can tell me why happens , correct way of doing is? imageview.layer.shouldrasterize = yes; imageview.layer.shadowpath = [uibezierpath bezierpathwithrect:imageview.bounds].cgpath; update it rasterization scale. need set screen's scale. else uses non retina image when creating bitmap! when set should rasterize on layer yes causes layer draw out contents bitmap. thats why image becomes blurry. if omit first line graphic quality won't change, if have lot of content hurt performance.

xpath - Append Base Template to Template using Sitecore Powershell -

Image
i'm new sitecore powershell (and powershell in general), , generate script adds template base template list of childitem templates under context folder. since __base template standard value , not regular field, i'm not sure if there syntax available append guid multilist field uses (pipe delimited). here's i've tried $master = get-database master; $translationtemplate = $master.templates["path/to/template/needed/translatable"]; $callouttemplate = $master.templates["path/to/example/callout"]; #$translationtemplate; $callouttemplate += $translationtemplate; i'm able of children recursively get-childitem -recursive, test run, want try on 1 template item called callout. here's view of $callouttemplate, showing has basetemplates section , fields section (which should include __base template): if there no solution in powershell sitecore, sitecore rocks query analyser crud operations possibly work? basically script you...

ruby on rails - Migrating from Carrierwave local to S3? -

our server ran file limit issue carrierwave. on 36000 files. going move s3. is there way migrate files on s3? when launched code on production none of images showed , there duh moment. it's trying grab files s3 when locally stored on server still. how migrate files over? you can upload files s3 via s3 console in s3 file manager. or using plugin such s3fox firefox. you'll need make sure pathing , s3 bucket such carrierwave know how point image via right set of subfolders, etc.

multithreading - How to shut down gobject main loop properly in python? -

i find myself confronted gobject first time while trying listening dbus. found piece of code teaching me how set main loop. how can listen 'usb device inserted' events in linux, in python? but need way stop it. main loop has quit function , know how call keyboard interrupt exception. how make stop, when put main loop thread? or more general: proper way make loop run independently, exit when main function exits? i appreciate help. don't know python in general should pass loop variable calling thread (your main function) , loop.quit() there when done. to pass loop variable have 2 options: the easy way: initialize loop gobject.mainloop() before forking, available both threads; the hard way: pass value main thread after having initialized in loop thread. an example (in c) of passing data between threads shown gcond documentation ( push_data() , pop_data() ).