Posts

Showing posts from April, 2014

mysql - retrieve unique ID from aggregate function MAX/GROUP BY -

i'm getting error when using aggregate function. guys can me, explained situation below. in football/soccer game player gets red card after second yellow card. query qry1twiceyellow gives unique id of players have 2 yellow cards. query written down below , works fine. select player_id (select player_id, count(id) total yellowcards game_id=29 , homeoraway=1 group player_id) total=2; now want retrieve information last card: the unique id of last yellow card. minute offence happened. the player id . i wrote following query causes error (below query). select y.id, y.player_id, max(y.minute) lastyellow qry1twiceyellow q inner join yellowcards y on q.player_id = y.player_id y.game_id=29 , y.homeoraway=1 group y.player_id; your query not include specified expression 'id' part of aggregate function. i tried following solutions: by adding id group error disappears max(minute) aggregate function useless since id unique. leaving out unique id. inner joi...

How to fetch all the image names from other table PHP - MySQL -

mates have problem using other table data. please @ code: $sql = mysqli_query($con, "select * properties category '$property_for' , property_type '$property_type' , search_radius >= '$area' , price >= '$price_min' , price <= '$price_max' , bed_rooms '$beds' , bath_rooms '$baths' order date_added desc") or die(mysqli_error($con)); $productcount = mysqli_num_rows($sql); if ($productcount > 0) { while($row = mysqli_fetch_array($sql)) { $pid = $row["property_id"]; $agent_id = $row["agent_id"]; $property_name = $row["property_name"]; $category = $row["category"]; $location = $row["location"]; $propert...

shell - Portable way to resolve host name to IP address -

i need resolve host name ip address in shell script. code must work @ least in cygwin , ubuntu , openwrt ( busybox ). can assumed each host have 1 ip address. example: input google.com output 216.58.209.46 edit: nslookup may seem solution, output quite unpredictable , difficult filter. here result command on computer ( cygwin ): >nslookup google.com unauthorized answer: serwer: unknown address: fdc9:d7b9:6c62::1 name: google.com addresses: 2a00:1450:401b:800::200e 216.58.209.78 if want available out-of-the-box on modern unix, use python: pylookup() { python -c 'import socket, sys; print socket.gethostbyname(sys.argv[1])' "$@" 2>/dev/null } address=$(pylookup google.com) with respect special-purpose tools, dig far easier work nslookup , , short mode emits literal answers -- in case, ip addresses. take first address, if more 1 found: # bash-specific idiom read -r address < <(dig +short google.com |...

jquery - Using scrollTop() to get position but it is also scrolling the page -

having issue when getting page position using scrolltop(). getting position correctly causing underlying page scroll top (see below). have tried 2 ways: var page_position = $(document).scrolltop(); $('#main-body').prepend(data.image).css('margin-top', page_position + 'px'); and: $('#main-body').prepend(data.image).css('margin-top', $(document).scrolltop() + 'px'); what data.image is div along image (large screenshot) returned ajax call. div image positioning correctly mentioned above underlying page scrolling top. btw, using foundation , jquery came packaged it, tried using jquery-1.11.3.min.js same results. plain javascript, want: var page_position = window.pageyoffset || document.documentelement.scrolltop

java - jTSS "There seems no TCS running" -

i want use jtss on ubuntu 14.04 64bits, have hardware tpm in version 1.2. installed .deb said in section 4.3 http://trustedjava.sourceforge.net/index.php?item=jtss/readme started daemon : jtss (tcs running) but if want run tests in packages (run_tests_simple.sh or run_test.sh) have error : "error! no tsp-tcs binding initialized. both jtss wrapper , jtss tried. check tsp configuration file." and command 'jtt tpm_version', have same error : --------------------- iaik java tpm tools --------------------- 16:34:56:631 [error] tctcsbindingsoap::connect (116): there seems no tcs running 16:34:56:647 [error] tctcsbindingsoap::connect (116): there seems no tcs running iaik.tc.tss.api.exceptions.tsp.tctspexception: tss error: error layer: 0x3000 (tsp) error code (without layer): 0x0103 error code (full): 0x3103a error message: core service connection failed. @ iaik.tc.tss.impl.java.tsp.tcsbinding.soapservice.tctcsbindingsoap.connect...

google cloud datastore - I get a 401 error when accessing GCD via a URL -

i have tried access following url when typed browser message: "not found" when use in talend rest component error message: 401 error. https://www.googleapis.com/datastore/v1beta2/datasets/my-project/runquery?key=aizasyca_j4wyyen-3q0nzwncmcoqcrrw17ec1y an idea? all cloud datastore api methods expect post requests. that's why error when access url via browser. the 401 error because need provide credentials access cloud datastore api. can find more information client libraries on cloud datastore getting started page or google apis client libraries page .

objective c - IOS crash only in release -

Image
i have crash can't reproduce , don't understand crashlog. managed symbolize crashlog should bit useful. error when building release (archiving , uploading hockeyapp). can point me in right direction? objective-c , ios knowledge bit lacking: exception type: exc_crash (sigabrt) exception codes: 0x0000000000000000, 0x0000000000000000 triggered thread: 0 ___exceptionpreprocess + 122 _objc_exception_throw + 34 +[nsexception raise:format:] + 108 -[uinib instantiatewithowner:options:] + 852 -[nsbundle(uinsbundleadditions) loadnibnamed:owner:options:] + 160 0x43a2e -[uitableview _delegateviewforheaderinsection:] + 36 ___96-[uitableview _sectionheaderview:withframe:forsection:floating:reuseviewifpossible:willdisplay:]_block_invoke + 82 +[uiview(animation) performwithoutanimation:] + 68 -[uitableview _sectionheaderview:withframe:forsection:floating:reuseviewifpossible:willdisplay:] + 542 -[uitableview _sectionheaderviewwithframe:forsection:floating:reuseviewifpossible:willdispla...

jquery - Multiple javascript selected from dropdown cannot seem to co-exist -

i building dynamically created string in multiple dropdown downs being looked @ values etc.. html: <div id="codesnip">where ... </div> then on button click javascript function called: function applyfilters(val) { var x = document.getelementbyid("codesnip"); var newdiv = document.createelement("div"); var newcontent = document.createtextnode("hi there , greetings!"); //var column = []; //$('[id^=selectnumber] :selected').each(function(i, selected){ //column[i] = $(selected).text(); var conditions = []; $('[id^=condition] :selected').each(function(z, selected){ conditions[z] = $(selected).text(); //newcontent = document.createtextnode(column[i]); //x.appendchild(newcontent); //add text node newly created div. newcontent = document.createtextnode(conditions[z]); x.appendchild(newcontent); newcontent = document.createtextnode(...

Intellij 14.1.4 CE spring boot 1.3.0.M1, spring-dev-tools hot reload not working -

just started spring boot application using spring initializer spring-dev-tools , imported intellij 14.1.4 ce. can run application fine gradle bootrun cannot hot reload working. follow intro on here spring dev tools . missing? you should give try spring loaded : reference guide - 72. hot swapping (or github project )

Can you change the android keyboard text font programmatically? -

to frank title says really, i'm trying change input method service, keyboardview key font. of course.. it's not simple android:keytextfont="sans-serif" . import java.lang.reflect.field; import android.content.context; import android.graphics.typeface; public final class fontsoverride { public static void setdefaultfont(context context, string statictypefacefieldname, string fontassetname) { final typeface regular = typeface.createfromasset(context.getassets(), fontassetname); replacefont(statictypefacefieldname, regular); } protected static void replacefont(string statictypefacefieldname, final typeface newtypeface) { try { final field staticfield = typeface.class .getdeclaredfield(statictypefacefieldname); staticfield.setaccessible(true); staticfield.set(null, newtypeface); } catch (nosuchfieldexception e) { e.printstacktrace(); } catc...

javascript - what is differeces between var a = b = 2 and var a = 2; var b=2; -

when declare variable in function, face problem. var b = 44; function test(){ var = b = 2; } but works fine: var b = 44; function test(){ var a; var b = 2; } variable b on rides global b variable. i cannot find documentation behavior. is there documentation ? demo : http://jsfiddle.net/uq4nxk1k/1/ i don't know can find documentation, here's explanation result obtained : local > global when declare global variable, it's available anywhere in file. inside "test()", when write : var = b = 2; you creating new variable a, take value of global variable b , changing, @ same time, value of b 2 -> overriding value. when write (inside test()) : var a, b; or var a; var b; you're declaring 2 more variables, known inside function and, local > global, if write b = 2, can face 2 situations : if console.log(b) inside test(), obtain 2 if console.log(b) outside test(), obtain 44 declaration != assig...

excel - Formula To Remove Some, But Not All, Duplicates From A List -

i have list containing different words , numbers, sample of follows: green blue 14 green yellow 11 yellow green green 14 i create parallel list removes every unique word/number every second instance of word/number - removes duplicates not all. continue above example, final list follows: green 14 yellow green as there 4 'green' in original list, there 2 in final list. there 2 'yellow' in original , 1 in final, , there single instances of blue , 11, these removed final list. is there formula or methodology so? unfortunately haven't been able think of clever myself. many in advance! =or(countifs($a:$a,$a2)=1,int(countifs($a$2:$a2,$a2)/2)*2=countifs($a$2:$a2,$a2)) if it's either duplicate or unique, marked true . make sure delete true values @ once/disable automatic calculation, otherwise it'll mark odd duplicates after deleting prior occurrences.

math - What does the fancy R symbol mean as written here? -

Image
this assigned question have, , i'm not sure how interpret r-like symbol in exponent position. mean turing machine should accept variable numbers of repetitions of w ? the notation w r means “ w reversed.” problem asks turing machine shall, if starts word w on tape, append # , w reversed. afterwards, shall accept (i.e. terminate). instance, if tape contains example in beginning, should contain example#elpmaxe after turing machine ran.

php - How to move a Symfony project from web hosting to localhost? -

i tried solutions (ex: transfer symfony2 site onto localhost web server ), never works, result blank page. the project on symfony 2.3 , php version 5.5 thanks when accessing symfony2 site locally need reference 1 of routing files in web folder directly. try http://localhost/app_dev.php/ , might give error message telling going wrong. can check log files in /app/logs folder see problem might be. edit: there several command line tools might needed set project. app/console doctrine:schema:update --force this check database in sync code , update database if necessary. app/console assetic:dump app/console assets:install app/console cache:clear these used install css, javascript , other static assets clearing cache.

javascript - angularjs-google-maps - info-window does not work with ng-repeat -

i use google maps ng-map , use markers , info-windows attached these markers added map ng-repeat. angular view following: <div id="mapwrap" map-lazy-load="https://maps.google.com/maps/api/js"> <map center="current-location" zoom="9" on-bounds_changed="getlocations()"> <marker ng-repeat="mymarker in mymarkers" clickable="true" on-click="showinfowindow(event, '{{mymarker.infowindowid}}')" id="{{mymarker.id}}" position="[{{mymarker.lat}},{{mymarker.lon}}]" title="{{mymarker.title}}" draggable="false" opacity="{{mymarker.opacity}}" visible="{{mymarker.visible}}" icon="{{mymarker.icon}}"> </marker> <info-window ng-repeat="infowindow in infowindows" id="{{infowindow.id}}" vis...

c# - send query string more than two hundred thousand characters in json to api - c # -

i want send jpeg image converted base64 json. image 660kb in size , characters after conversion approximately 2 million in length. need send api ?? in query string, if possible. the error string long. there alternatives? httpclient client = new httpclient(); string uploadjson = "http://mylink/webapi/api/uploadphoto?jsonimage=" + jsonimage + "&idodl=" + idodl + "&sndevice=" + sndevice + "&cod=" + cod + "&idtechnician=" + idtechnician + "&id_producer=" + id_producer + "&pdr=" + pdr; client.baseaddress = new uri(uploadjson); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); task<httpresponsemessage> response = client.getasync(uploadjson); httpresponsemessage res = response.result; if (!res.issuccessstatuscode) ...

spring security - How to override class in grails -

i using spring security rest plugin authenticate user. in this, there class named restauthenticationfilter . want call methods of custom class customrestauthenticationfilter (which extends restauthenticationfilter ) instead of restauthenticationfilter . how this? is there way define in resources.groovy or somewhere else use customrestauthenticationfilter instead of restauthenticationfilter ? i believe filtering nicely described ... in documentation! https://grails-plugins.github.io/grails-spring-security-core/guide/filters.html just amend grails.plugin.springsecurity.filterchain.filternames value in config.groovy file contains restauthenticationfilter instead of restauthenticationfilter , should go.

python - How do I allow cxfreeze to import colorama? -

i'm incredibly new, , wondering if package colorama cx_freeze, i've seen people similar question yet not understand how choose colorama. please, explain i'm 10 years old. coding in setup.py file cx_freeze: from cx_freeze import setup, executable`` setup(name = "popcarventure" , version = "0.1" , description = "" , executables = [executable("theadventure.py")]) can please post how import colorama? appreciated! note: using python 3.4 on windows, not python 2. i started in python , came across same problem, aparently latest version of cxfreeze has difficulties include compressed modules (.egg, similar .zip files). so i'm going try explain in easiest way can, how managed working. i assume installed python in c:\python34 . close python command line or idle gui. go python34 installation folder , should on c:\python34 . once there open "lib" folder , locate "si...

What is the time and space complexity of a Scala's head/tail extractor? -

what time , space complexity this: def ispalindrome[a](x: seq[a]): boolean = x match { case h +: middle :+ t => h == t && ispalindrome(middle) case _ => true } does depend on implementation of seq ? since indexedseq should have o(1) tail vs o(n) linearseq s? space complexity o(n) because of recursive call stack or scala tail call optimization automatically? import scala.annotation.tailrec @tailrec def ispalindrome[a](x: seq[a]): boolean = x match { case h +: middle :+ t => h == t && ispalindrome(middle) case _ => true } does depend on implementation of seq? since indexedseq should have o(1) tail vs o(n) linearseqs? i assume extractor o(n) . extractor seq scala.collection.:+ has o(n) list last , o(n) last. code 2 following: def init: repr = { if (isempty) throw new unsupportedoperationexception("empty.init") var lst = head var follow = false val b = newbuilder b.sizehint(this, -1) ...

javascript - status 143 error in Heroku for MEAN JS app -

this app works fine in development locally breaks in production. heroku docs not help. here logs. ideas? other file need see in order gather required info? 2015-07-08t19:43:20.171096+00:00 heroku[slug-compiler]: slug compilation started 2015-07-08t19:43:20.171178+00:00 heroku[slug-compiler]: slug compilation finished 2015-07-08t19:43:20.122153+00:00 heroku[api]: release v10 created 2015-07-08t19:43:20.122153+00:00 heroku[api]: deploy 6c5a2eb 2015-07-08t19:43:20.229087+00:00 heroku[web.1]: state changed starting 2015-07-08t19:43:22.728050+00:00 heroku[web.1]: stopping processes sigterm 2015-07-08t19:43:23.765850+00:00 heroku[web.1]: starting process command `./node_modules/.bin/forever -m 5 server.js` 2015-07-08t19:43:24.379905+00:00 heroku[web.1]: process exited status 143 2015-07-08t19:43:25.625194+00:00 app[web.1]: recommending web_concurrency=1 2015-07-08t19:43:25.625166+00:00 app[web.1]: detected 512 mb available memory, 512 mb limit per process (web_memory) 2015-07-08t19:4...

oracle - Get the DDL for a function in a package -

is there way ddl function in package under different user in oracle? can see package in sql developer under 1 of users listed under 'other users'. i've tried using dbms_metadata.get_ddl function: select dbms_metadata.get_ddl('package', 'my_package', 'other_user') dual but following error: ora-31603: object "my_package" of type package not found in schema "other_user" for first parameter of get_ddl function tried package_spec, , package_body didn't seem help. not sure if anyone, old question, use query (from java) rip procedures , functions off our server can put them in git. i'm using 12c. with x ( select owner, object_name, object_type dba_objects owner 'owner_name_here' , object_type in ('procedure', 'function') ) select dbms_metadata.get_ddl (x.object_type, x.object_name, x.owner) ddlcode x;

how can sort my dates by php/mysql? -

i'm trying change sorting date of stores localized in map (wp plugin: store-locator-le) php , mysql. insert date in phone field, before have change field in date. can me? $this->dbquery = apply_filters('slp_mysql_search_query', "select *,str_to_date(sl_phone, '%d-%m-%y') date ". "from store_locator ". 'order date asc' ); if write sql code in mysql phpmyadmin, works! the problem apply_filter function. using %%d-%%m-%%y query

javascript - React Native, NavigatorIOS, undefined is not an object (evaluating 'this.props.navigator.push') -

Image
i'm trying use navigatorios in index.ios.js got: 'use strict'; var react = require('react-native'); var home = require('./app/components/home'); var { appregistry, stylesheet, navigatorios } = react; var styles = stylesheet.create({ container:{ flex: 1, backgroundcolor: '#111111' } }); class exampleapp extends react.component{ render() { return ( <navigatorios style={styles.container} initialroute={{ title: 'example', component: home }} /> ); } }; appregistry.registercomponent('exampleapp', () => exampleapp); module.exports = exampleapp; and in home.js : 'use strict'; var react = require('react-native'); var park = require('./park'); var { view, stylesheet, text, touchablehighlight } = react; var styles = stylesheet.create({ ... }); class home extends react.component{ onpress() { this.prop...

r - Issue installing rJava on aix7.1.3 -

i have installed 32bit version of r 3.1.1 on aix 7.1.3 i in step of installing rjava package r shell using command: install.packages("rjava") however, getting error: warning: unable access index repository http://cran.utstat.utoronto.ca/src/contrib warning messages: 1: in open.connection(con, "r") : unable resolve 'cran.r-project.org' 2: package 'rjava' not available (for r version 3.1.1) it seems r unable connect internet download package. have tried several mirror sites. any idea how resolve issue in aix? there alternative option install rjava manually not through install.packages() r command? you try compile package devtools: install.packages('devtools') devtools::install_github('s-u/rjava') make sure have correct javac in path.

c++ - getline() not opening text file -

hi using codeblocks 13.12 on osx. i trying open following .txt file line 1 line 2 line 3 my code just: #include <iostream> #include <fstream> #include <string> using namespace std; int main() { cout<<'\n'; std::string line; ifstream myfile("textex.txt"); if(myfile.is_open()) cout << "file open"; else cout << "file not open"; cout<<'\n'; return 0; } i have included file in project folder , have tried linking , compiling it. when run code, displays"file not open" , i'm not sure why? i'm new c++, can please explain why isn't working? instead of ifstream myfile("textex.txt"); try ifstream myfile; myfile.open("/users/name/code/textex.txt"); // use full path

Coverting PPTx to HTML in java (with or without using Apache POI) -

i trying render office files in html page without uploading them online. want show them in html page local host only. after failing on decided convert office files html , display them in separate iframe. ppt,docx , doc have used this uses apache poi not able find can pptx files. there simple way it?

asp.net mvc - MVC Kendo UI Grid - call function after all the rows have been expanded -

i using asp.net mvc kendo grid. on click of button, need expand rows. here code same: var row = $(this).closest("tr.k-master-row"); grid.data("kendogrid").expandrow(row); where , grid have been defined. works well. on expand of each row, following event called (for each row), detail template bound: .events(events => events.databound("oninnergriddatabound")) function oninnergriddatabound(e) { //do here } my requirement after initiate call expand rows, have few lines in code, should executed after rows have been expanded. so, function expandall() { var row = $(this).closest("tr.k-master-row"); //step1 grid.data("kendogrid").expandrow(row);"); //step2 //do after oninnergriddatabound event called every expanded row. .................................. //ideally should step 4 executed, executes //after step2 } //ideally step 3 execute, executes last function oninnergriddatabo...

fullcalendar - Text displayed on the vertical axis of the calendar -

i want in the left frame of calendar (where hours shown) put letters or titles. instance a1, a2, a3 etc. in calendarview.js axisformat: userdefaulttimeformat, and var userdefaulttimeformat = jquery('#time_format').val(); if(userdefaulttimeformat == 24){ userdefaulttimeformat = 'h(:mm)'; } else { userdefaulttimeformat = 'h(:mm)tt'; } i have changed userdefaulttimeformat = 'h(:mm)'; to userdefaulttimeformat = 'a1 h(:mm)'; this changes first quarter.. i want same o remaining quarters (9.15) a2, (9.30) a3, (9.45) a4. (only characters no time) how can that?

What is the difference between creating a new date using momentJS versus using Javascript new Date()? -

if console log 2 same result reason result of third console false means there difference! appreciated. console.log(new date()); console.log(moment(new date()).todate()); console.log(moment(new date()).todate() == new date()); the following result on console: wed jul 08 2015 15:55:30 gmt-0500 (central daylight time) wed jul 08 2015 15:55:30 gmt-0500 (central daylight time) false you comparing date objects, should comparing values : console.log(moment(new date()).todate().gettime() == (new date()).gettime()); console.log(+(moment(new date()).todate()) == +(new date())); more discussion on here: compare 2 dates javascript

php - Wordpress - Show all child categories associated to post ID within loop -

i'm looping through posts , i'm trying output category nicename related each post. if there categories a,b , c post x associated categories , c want output category , c's nicename. here's loop: <?php $subs = new wp_query( array( 'post_type' => 'case-study' )); if( $subs->have_posts() ) : while( $subs->have_posts() ) : $subs->the_post(); ?> <?php the_title(); ?> <p>associated child categories</p> //show nicenames of each child category associated each post <?php $category = get_categories($post->id); foreach(($category) $cats) { echo $category->category_nicename; }?> <?php endwhile; endif; ?> it sounds get_the_category() ideal situation, since you're doing within loop: $post_cats = get_the_category(); if ( $post_cats ) { foreach ( $post_cats $cat ) { // show child categories (exclude parents) if ( ! $cat->category_parent === '0...

wordpress - WooCommerce programmatically add order for a specific user -

i working on custom woocommerce plugin. in 1 of function want add order system/database wc_create_order() . the code beneath works fine, can't find way dedicate order specific user (so shows in backend , on accountpage of user). (db field is: '_customer_user' ???) my code: // $productid, $userid, $price passed in function $user = get_userdata($userid); $address = array( 'first_name' => get_user_meta( $userid, "billing_first_name", true), 'last_name' => get_user_meta( $userid, "billing_last_name", true), '......' ); $order = wc_create_order(); $args['totals']['subtotal'] = $price; $args['totals']['total'] = $price; $order->add_product( get_product( $productid ), 1, $args ); $order->set_address( $address, 'billing' ); $order->set_address( $address, 'shipping' ); $order->calculate_totals(); you can update_post_meta u...

Access( or declare) an object member with an illegal character in PHP -

i'm working personal weather station upload protocol on weather underground. creating class attributes pws may contain, , use http_build_query() create request. my problem is : weather underground has 2 fields invalid identifiers names php. check out: aquv-aeth -uv-aeth (second channel of aethalometer @ 370 nm) ug/m3 aqpm2.5 - pm2.5 mass - ug/m3 my class can not contain these property names, can do? erro: class foo { public aquv-aeth = null; public aqpm2.5 = null; } php supports dynamically added properties object,so: class foo{ } $foo = new foo(); $foo->{'aquv-aeth'} = 'data1'; // add , init new porperty object $foo->{'aqpm2.5'} = 'data2'; echo $foo->{'aquv-aeth'}; // access special porperty name $obj->{'name'}

ajax - js object only partially getting passed to controller -

Image
i submitting js object via ajax controller. 3 of 4 children passing passing correctly. can tell why 4th (action) null in controller? it appears correctly when debugging js. but null when stepping controller. object, post, subject passed correctly. failed locally me well, know sure "action" not sort of js or c# reserved word... changing model property name "action1" (and in js object) did trick. odd!

osx - Compiling with SDL1.2 on mac -

i have code i'm trying compile using sdl. my code simple , have followed steps in sdl's ready add sdl mac under /library/frameworks. yet when i'm trying compile cannot find header reason. here code ( bit around include of sdl header): #include <sdl.h> and way compile code: g++ [mycppfiles] -o a.out -framework glut -framework opengl -framework sdl -std=c++98 -l /library/frameworks/sdl.framework/headers/ would know why cannot find sdl header? finally got working. apparently shouldn't add -framework sdl , tell compiler in correct directory sdl.h here command line use compiling: g++ [myfiles.cpp] -o a.out -framework glut -framework opengl -std=c++98 -i/library/frameworks/sdl.framework/headers/ `sdl-config --cflags --libs` if don't add bit sdl-config --cflags --libs cannot find definition of functions used in sdl.

objective c - Translating cURL request to NSMutableURLRequest -

i'm new objective-c developer , i'm interacting api in curl format. i'm used making calls using urls, pieced request found on internets. i'm still not able pull data in app. this original curl request (with dummy keys of course): curl -v -h "app_id:12345" -h "app_key:abcdefg" -x post "http://data.host.com/object" -d '{"page":0,"take":10}' this attempt: //request nsurlsession *session = [nsurlsession sharedsession]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"http://data.host.com/object"]]; //set method request.httpmethod = @"post"; //set parameters nsdictionary *parameters = @{ @"page": @(0), @"take": @(10) }; nsmutablestring *parameterstring = [nsmutablestring string]; (nsstring *ke...

algorithm - Is it efficient to read, process and write one line at a time? -

i working on project requires reading file, making manipulations on each line , generate new file. bit concerned performance. algorithm more efficient? wrote pseudocode below. store array, close file, manipulate each line , store new array output file: openinputfile() linearray[] = readinput() closeinputfile() (i in linearray) // i:current line manipulate newarray[] += // store manipulted line new array openoutputfile() writeoutput(newarray) closeoutput() get each line in loop, after manipulation write new line output openinputfile() openoutputfile() (i in inputfile) // i:current line manipulate print manipulated line output closeinputfile() closeoutputfile() which 1 should choose? it depends on how large input file is: if small, doesn't matter approach use. if large enough, overhead of holding entire input file , entire output file in memory @ same time can have significant performance impacts. (increased paging load, etcetera.) if...

vba - Calling SubForm routine from another Form -

i have form x contains subform y. there routine defined in y form. need call routine form z (which opens whenever user click on button on subform y) on closing event of form z. form x open. have tried till not working: // in form z call forms("x").someroutine call forms("y").someroutine but every time getting runtime error 2450 access can't find form. my x form includes subform control named child1 . y form contained subform in child1 . form y includes public vba procedure: public sub someroutine() debug.print "this someroutine in form " & me.name end sub with parent form ( x ) open in form view, can go immediate window ( ctrl + g ) , call someroutine ... forms!x!child1.form.someroutine someroutine in form y the key point used name of subform control contains y subform. (notice letter y not present in forms!x!child1.form.someroutine ) the subform control name may same name of form contains ... not have...

ios - show loader while downloading data from web services and updating the tableview using objective C -

i want show loader while downloading data web , loading table , code should placed in common place can call view controller. please me if 1 knows on this. you can create uiactivityindicatorview in storyboard. , can use startanimating , stopanimating functions. you can use uiprogressview , can use function setprogress show how progress done

Assembly code elements of array -

i want write assembly code, following commands:array of 4 elements, read elements user , store them, display array proper message , multiply each element 2 , have problems, first of all: wrote code: .model small .stack 100h .data arr db 1,2,3,4,4,4,3,1,2 msg1 db 'the elements of array : $' msg2 db 0dh, 0ah,'the value after multiply 2: $' .code main proc mov ax, @data mov ds, ax mov cx, 9 mov bx, 0 mov ah,9 lea dx, msg1 int 21h display1: mov al, arr[bx] mov ah, 2 add al, 30h mov dl, al int 21h inc bx loop display1 mov ah,9 lea dx, msg2 int 21h xor cx, cx xor bx, bx mov cx, 9 mov bx, 0 multiplay: mov al, 2 mul arr[bx] mov ah, 2 add al, 30h mov dl, al int 21h inc bx loop multiplay mov ah, 4ch int 21h main endp end main output: the elements of array : 123444312 value after multiply 2:246888624 it running well, when i'm trying ask user enter number result isn...

python - PyQt QMovie will not loop GIF -

Image
i have working example of playing gif , isn't looping gif. changed movie.setcachemode(qmovie.cacheall) any idea? -->animated gif from pyqt4 import qtcore, qtgui pyqt4.qtgui import * pyqt4.qtcore import * import sys class imageplayer(qwidget): def __init__(self, filename, title, parent=none): qwidget.__init__(self, parent) # load file qmovie self.movie = qmovie(filename, qbytearray(), self) size = self.movie.scaledsize() self.setgeometry(200, 200, size.width(), size.height()) self.setwindowtitle(title) self.movie_screen = qlabel() # make label fit gif self.movie_screen.setsizepolicy(qsizepolicy.expanding, qsizepolicy.expanding) self.movie_screen.setalignment(qt.aligncenter) # create layout main_layout = qvboxlayout() main_layout.addwidget(self.movie_screen) self.setlayout(main_layout) # add qmovie object label self.movie.setcachemode...

Converting String value to Date and adding 200 minutes in javascript -

i have string date value returned database. date ="2015-06-26 13:23:04" . how add 200 minutes in javascript? not able convert date. want same format. i want dispaly same format "2015-06-26 13:23:04". i used below code convert. var datevar = "2015-06-26 13:23:04"; var today = new date(datevar).toisostring().slice(0, 20); and cant correct hh:mm:ss value. getting : "2015-06-26to7:53:04" please me. thank you. if sure string that, can transform milliseconds , add 20*60*1000 corresponds 20minuts var yourstring= "2015-06-26 13:23:04", year=yourstring.substring(0,4), month=yourstring.substring(5,7), day=yourstring.substring(8,10), hour=yourstring.substring(11,13), minuts=yourstring.substring(14,16), secondes=yourstring.substring(17,19), mkdate= new date(year,month,day,hour,minuts,secondes), add200minutes =mkdate.gettime() + 200*60*1000, newdate=new date(add2...

sockets - Linux Kernel parameters which can be tuned when TCP backlog exceeds in WebSphere MQ server -

we facing issue see tcp backlogs gets exceeded default value (100) on our mq server (v7.5) running on linux (redhat) platform during high number of connection requests on mq server. listenerbacklog configured 100 in qm.ini default listener backlog value (maximum connection requests) linux. whenever have connections burst , tcp backlogs exceeds queue manager stops functioning , resumes when queue manager/server restarted. so looking whether there attributes in linux kernel related socket tuning can improve tcp backlog @ network layer , cause no harm queue manager.does increasing these values below in /etc/sysctl.conf resolve issue or improve performance of queue manager? net.ipv4.tcp_max_syn_backlog = 4096 net.core.somaxconn = 1024 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216

php - How to write data into .txt file in codeigniter -

i have folder in assets name login.my doubt how set path. $data=$id.'~'.$expense_type.'~'.$amount.'~'.$exp_date.'<br>'; $todate= date('y-m-d'); echo $todate; if ( ! write_file('.../assets/login/log_'.$todate.'.txt', $data)) { echo 'unable write file'; } else { echo 'file written!'; } no problem data path wrong set my path 'localhost/project/pro/application/assets/login/(specific .txt file)' output unable write file use apppath . path application folder if ( ! write_file(apppath."assets/login/log_$todate.txt", $data))

java - GLSL Moving Point Light -

Image
i have been writing point light shader lwjgl + java application. writing based off of this tutorial . problem when "walk around" camera, light moves well. also, when rotate sphere, light rotates it. believe problem in vertex shader , put fragment shader in in case. example 1 (no movement) example 2 (moved left , rotated camera) vertex shader #version 330 in vec4 in_position; in vec3 in_normal; in vec2 in_texturecoord; uniform mat4 projection; uniform mat4 view; uniform mat4 model; uniform mat3 normal; uniform vec4 light_pos; //set 0, 3, 0, 1 out data { vec3 normal; vec3 eye; vec3 ldir; vec2 st; } out; void main(void) { vec4 vert = view * model * light_pos; vec4 pos = model * view * in_position; out.normal = normalize(in_normal); out.ldir = vec3(vert - pos); out.eye = vec3(-pos); out.st = in_texturecoord; gl_position = projection * view * model * in_position; } fragment shader #version 330 uniform sampl...

Drag and Drop between two QListWidgets PyQt5 -

have 2 qlistwidgets. want able move items widget 1 onto widget 2 , vice versa dragging , dropping. must work multiselection mode. must moveaction not copy action. simple way achieve use: self.listwidget_2.setdragdropmode(qtwidgets.qabstractitemview.dragdrop) self.listwidget_2.setdefaultdropaction(qtcore.qt.moveaction) self.listwidget_2.setselectionmode(qtwidgets.qabstractitemview.multiselection) self.listwidget_2.setobjectname("listwidget_2") self.listwidget_2.acceptdrops() this achieves desired requirements 1 caveat. dragging , dropping item onto widget resides removes widget. definite no go. tried write own qlistwidget class achieve desired results no avail, class: class dragleavelist(qtwidgets.qlistwidget): def __init__(self, type, parent=none): super(dragleavelist, self).__init__(parent) self.setdragdropmode(qtwidgets.qabstractitemview.dragdrop) self.setselectionmode(qtwidgets.qabstractitemview.multiselection) self.setalternatingrowcolors(true)...

javascript - Input value is undefined even when ng-model is defined -

i have angularjs directive show or hide input labels. works fine when start empty input , start typing. when input pre-filled ng-model label should shown initially, , starting hidden. have checked value of input, , undefined. i'm sure there obvious reason/solution, cannot find it. plunker angular: var app = angular.module('plunker', []); app.controller('mainctrl', function($scope) { $scope.customer = { name: "patrick" }; }); app.directive('labeltoggle', function () { return { restrict: 'a', link: function (scope, element, attr) { var thislabel = element.find('label'); var thisinput = element.find('input'); scope.valuedefined = thisinput[0].value; thisinput.on('keyup', function () { if (this.value) { thislabel.addclass('show-label'); } else { thislabel.removeclass('show-label'); } scope.valuedef...

java - Apache tiles V3 includes in subpage -

i'm trying build web application apache tiles. use apache tiles v3 wild card support. my tiles.xml looks this: <?xml version="1.0" encoding="iso-8859-1" ?> <!doctype tiles-definitions public "-//apache software foundation//dtd tiles configuration 3.0//en" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd"> <tiles-definitions> <definition name="*" template="/resources/tiles/main-layout.jsp"> <put-attribute name="main" value="/resources/templates/{1}.jsp" /> <put-attribute name="head-content" value="" /> </definition> <definition name="*/*" template="/resources/tiles/main-layout.jsp"> <put-attribute name="main" value="/resources/templates/{1}/{2}.jsp" /> <put-attribute name="head-content" value="" /...

Count the number of pairs in SQL -

i have column , count number of unique pairings of elements within column in sql, example, in col 1 number of unique pairings should 6: ([1,2],[1,3],[1,4],[2,3],[2,4],[3,4]). thanks! col 1, 1 2 3 4 consider scenario in have dulpicates values in table col1 1 1 2 3 4 5 the total number of unique combinations 10:([1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[2,5],[3,4][3,5],[4,5]). but given query below giving me count of 14 because of dulplicate 1 counting 4 pairs [1,2],[1,3],[1,4],[1,5] twice. select count(*) table t1 join table t2 on t1.col1 < t2.col1; to modify defect have following query ensures duplicates removed , correct output.the table name have chosen countunique can store integer values in in column named col1. select count(*) (select distinct col1 countunique) t1 join (select distinct col1 countunique) t2 on t1.col1<t2.col1 sql fiddle reference sqlfiddle hope answers question.

how to write and read pgm p5 file in java -

i want read pgm file. kept image content in byte array. when accessed pixels, see values negative. so, applied "& 0xff" each byte. hope ok when write file, isn't same original image. how can read , write pgm p5 file? int = bytearray[index] & 0xff; //reading writer.write((char)(i)); //bufferedwriter keep in mind p5 format binary . using writer , cast value char . text, not binary data. instead, use outputstream , write value in i directly stream. int = bytearray[index] & 0xff; // reading stream.write(i); // outputstream ps: if don't feel implementing pgm format yourself, have created imageio plugin netpbm formats (pnm) use. it's open source (bsd license).

php - Problems with Facebook login on localhost -

Image
i'm using yii eauth plugin logging social networks , works on prod server. i'm having problem making work on local developer machine. i don't user http://localhost , http://my-domain.com i've created fb called myapp local, i'm unsure add in app domains , site url . when login, fb pop-up dialogue url looks this: https://www.facebook.com/dialog/oauth?client_id=12345678901515987&redirect_uri=http%3a%2f%2fmy-domain.com%2flogin%3fservice%3dfacebook&scope=email,%20public_profile,%20user_friends&response_type=code but nothing happens , i'm redirected login page. know i'm doing wrong? update js code localhost currently: (this placed in header) window.fbasyncinit = function() { fb.init({ appid : '12345678901515987', xfbml : true, version : 'v2.3' }); }; (function(d, s, id){ var js, fjs = d.getel...

android - LinearLayout weight choices -

why use weights 2:4 instead of weights 1:2 ? looking through udacity course layout. it's linearlayout 2 children views. , children given weights 2 , 4 respectively opposed 1 , 2. why that? because wanted to? actual values don't matter, ratios does. when see code evolved on time, had in there weight 1 , removed (while weights don't need whole number, people try keep them way).

python - cmd module: capture Ctrl+C -

this question has answer here: how capture sigint in python? 9 answers i using python's default cmd module create command-line-based app. according docs ctrl + d (which signals eof command line) can captured implementing function called do_eof , works pretty well. however, there way capture ctrl + c well? want execute specific function (which saves unsaved changes) before terminating python-script, main motivation doing this. currently, capture keyboardinterrupts using try-except-block following: if __name__ == '__main__': try: mycmd().cmdloop() except keyboardinterrupt: print('\n') i tried extend into: if __name__ == '__main__': try: app = mycmd().cmdloop() except keyboardinterrupt: app.execute_before_quit() print('\n') which leads following nameerror : ...