Posts

Showing posts from August, 2015

php - Two compares in one if / else statement -

i trying find answer pretty simple question. is possible ask 2 things in 1 if / else statement? for example: if($a>$b , isset($c)) return true; i understand possible write like: if ($a>$b) { if (isset($c)) return true; } i looking easier , less messy code. advises. thanks. with of && operator : if($a > $b && isset($c)){ return true; } note : check both conditions true, if yes if block works. if want of them true lead if block execution go || operator.

c# - Ignoring items in collection with Automapper when mapping collection -

i mapping collection of items var list<a> mycollection = new list<a>(); public class { bool haschanges {get;set;} } var mappedcollection = map(mycollection); then want map items haschanges == true is possible? with linq: var mappedcollection = map(mycollection.where(x => x.haschanges == true).tolist());

Why the syntax for defining sigils in Elixir doesn't use "defsigil"? -

i reading page sigils in elixir tutorial. expected syntax defining sigils uses "defsigil" "defstruct", "defprotocol", , on. not so. why? the original sigil syntax def __s__ s character used sigil (this def sigil_s .) can see in initial commit started work on sigils. believe work started before macros implemented. this syntax required hack allow them imported can read in this issue. today, when writes %f"foo", translates f ("foo", []). proposal change translation to: sigil_f("foo", []). this change brings 2 benefits: 1) name more explicit; 2) allows remove hack in our importer. today, import hello brings functions hello not start underscore makes exception sigils; you can see in discussion other suggestions such defmodule sigil.s suggested, def sigil_s syntax chosen. the actual commit implements these changes https://github.com/elixir-lang/elixir/commit/c6284557e792efd67f13f421b

php - Retrieving value of a select box populated by an ajax call -

here 2 select boxes. trying value of c pass on in form. select box c populated ajax call below can't seem useable value pass on form. (in simplest form looking var a= 'select box c') can send 'a' in form: many in advance people x <select name="list-select" id="list-select"> <option value="">please select..</option> <option value="chemical">chemical</option> <option value="hardware">hardware</option> </select> <select name="c" id="c"></select> here jquery bit: <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).ready(function ($) { var list_target_id = 'c'; //first select list id var list_select_id = 'list-select'; //second select list id var initial_target_html = '<option value="">please

opengl - Qt Use ShaderEffect for QImage rendering -

i wondering if possible via qt quick or c++ use shader effect on image , save effect applied. the reason doing achieve opengl assisted image effect manipulation (ie. emboss, pixelize, etc) i tried this: import qtquick 2.4 import qtquick.controls 1.3 import qtquick.dialogs 1.2 applicationwindow { id: root title: qstr("hello world") width: 640 height: 480 visible: true image { id: effectimage width: 200 height: 200 sourcesize.width: width sourcesize.height: height anchors.centerin: parent source: "qrc:/myimage.png" layer.enabled: true layer.effect: shadereffect { fragmentshader: " uniform lowp sampler2d source; // item uniform lowp float qt_opacity; // inherited opacity of item varying highp vec2 qt_texcoord0; void main() { lowp vec4 p = texture2d(source, qt_tex

I want to search files and folder in directories and sub directories php -

i want search files , folders in directory or sub-directories. i'm using code: <?php $a = new regexiterator( new recursiveiteratoriterator( new recursivedirectoryiterator('files') ), '/desi indian/', regexiterator::match ); foreach ($a $v) { echo "$v\n"; //$v filename } ?> but, problem is, file name 'wayne' , if search string 'wayne', doesn't show search result. ideas? but, problem , file name 'wayne' , if search string 'wayne', not show search results. this sounds question of searching case insensitive. regular expressions can given additional processing flags, amongst them i purpose @ hand. replace pattern '/desi indian/i' , should match file names regardless of cases. you may want read bit flags, or modifiers how called: http://php.net/manual/en/reference.pcre.pattern.modifiers.php

python - Is there a way i can use np.array in the code -

i wanted know if there way can covert code np.array code. add link . wanted add angle ball launches from. import numpy np import scipy sp scipy.integrate import ode import matplotlib.pylab pl import matplotlib.pyplot plt import math matplotlib import* matplotlib.pyplot import * __future__ import division import math def projectile_xy(initpos,g,initvel): data_xy = [] inittime = 0.0 while true: now calculate height y y = initpos + (inittime * initvel * math.sin(theta)) - (g * inittime * inittime)/2 projectile has hit ground level if y < 0: break calculate distance x x = initvel * math.cos(theta) * inittime append (x, y) tuple list data_xy.append((x, y)) use time in increments of 0.1 seconds inittime += 0.1 return data_xy g = 9.8 #h = float(raw_input("enter height ")) initpos = float(raw_input("enter height ")) der = float(raw_input("enter angle ")) #v = flo

cordova - Receive URL in Ionic for ios -

i using ionic framework. i'm trying set way receive url app. like, in browser, click share, , send link app (my app). found cordova plugin, , have integrated in app. pulgin android . need same functionality in ios. any idea plugin need use ios. i think looking custom url scheme plugin. this plugin allows start app calling url mycoolapp://path?foo=bar maybe article in interest (about deeplinking ionic ionic app).

pagespeed - How to Eliminate render-blocking JavaScript and CSS in above-the-fold content -

i have speedup desktop 82/100, mobile speed still 60/100. can recommend me tips improving mobile speed 80/100. here link current google pagespeed insights: https://developers.google.com/speed/pagespeed/insights/?url=http%3a%2f%2fwww.lutonairporttaxis.co.uk%2f&tab=mobile there number of things improve score of application. pagespeed insights suggests, turn on compression. easy win , make difference files sizes on wire. in terms of render-blocking css, why don't try , automate process. there great plugin called grunt-critical automatically extract , inline critical css you. more information, recommend reading this article critical css.

android - Floating action button no longer transparent -

i trying make floating action button in android project. so far have this , looks good. the problem when go other part of app , go fragment floating action button of sudden looks this . transparency gone. my layout xml looks this: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="net.lightningworks.freek.hourkeeper.jobfragment"> <android.support.v7.widget.recyclerview android:id="@+id/my_recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent"/> <imagebutton android:layout_margin="15dp" android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/ic_new" android:

linux - Find out when file was added to system or placed in directory -

on ubuntu: want able determine when file added system or in other words when placed/copied directory. time stamp 'last modified' when 1 installs apt timestamp not same when placed on system. thanks you can use inotify . from manpage: "the inotify api provides mechanism monitoring filesystem events. inotify can used monitor individual files, or monitor directories." watching file or directory change can done int inotify_add_watch(int fd, const char *pathname, uint32_t mask); where mask can in_modify see modifications on file/directory.

c# - AccessViolationException occured using P/Invoke with Media Foundation Interface in Multithread application -

i'm using p/invoke in c# call native function c++ dll below: c++ dll: extern "c" { // function: create wmv video sequences image. codec: wmv3 (vc-1) __declspec(dllexport) bool __stdcall createwmv(...) { ... } } c# wrapper class. create c# wrapper class function map native c++ code: [dllimport("aviencoder.dll", entrypoint = "createwmv", charset = charset.unicode, callingconvention = callingconvention.stdcall)] [return: marshalas(unmanagedtype.bool)] public static extern bool createwmv(...); i'm sure parameters marshaling correctly in c#, because run when called directly in client c# code. issue occurred when put function in background thread. private void test() { .... createwmv(...); // call processed without issue thread backgroundthread = new thread( new threadstart(()=> { createwmv(...); // call causes accessviolationexception } } the functi

asp.net - Localization of Custom Controls in a redistributable assembly -

Image
i'm trying build redistributable assembly containing several custom controls ( commoncontrols ). my environment: msvc 2010, asp.net (webforms) .net 2.0/3.0/3.5 the problem: compiling web deployment project won't work if localize commoncontrols via app_globalresources . here how build commoncontrols assembly: i use website containing .ascx , .ascx.cs files: and web deployment project following settings: this create "commoncontrols.dll". assembly used in different asp.net webapplication follows: web.config: first (minor) problem: adding commoncontrols dependency not automatically copy satellite assemblies languages. copying them manually correct output path seems work though (for debugging). main problem: main web application localized via app_globalresources , built web deployment project : that build process fail with aspnetcompiler : error aspruntime: object reference not set instance of object. both deployment projects cr

javascript - Summation using for loop -

i want find total input field , set total value particular text field. here html: <table id="table" border="1"> <tr> <td></td> <td colspan="4">injuried</td> <td colspan="4">killed</td> <td colspan="4">died</td> </tr> <tr> <td></td> <td>adult</td> <td>young</td> <td>children</td> <td>total</td> <td>adult</td> <td>young</td> <td>children</td> <td>total</td> <td>adult</td> <td>young</td> <td>children</td> <td>total</td> </tr> <tr> <td>number</td> <td><input type="text" size="5" /></td> <td><input type="text" size="5"/>&l

cassandra - Limiting columns per record in CQL -

i've problem has been bothering me quite while now. i'm scaling down simplification. i've column family in cassandra defined as: create table "test" ( key text, column1 text, value text, primary key (key, column1) ) if run query in cql as: select * "test" key in ('12345','34567'); it gives me like: key | column1 | value -----------------------+--- 12345 | 764 | 764 12345 | 836 | 836 12345 | 123723 | 123723 12345 | 155863 | 155863 key | column1 | value -----------------------+--- 34567 | 159144 | 159144 34567 | 159869 | 159869 34567 | 160705 | 160705 now question how can limit results 2 rows max per record. tried use following didn't work. select first 10 'a'..'z' "test" key in ('12345','34567'); - not available in latest cql version. select * "te

vba - Visual Basic: Multiplying strings/SendKeys? -

ok, i've got this: sendkeys.send("blah" + "{bs}") and want backspace "{bs}" multiple times, eg have variable multiply "{bs}" have backspace amount of times, how go doing this? i know possible in python by: "string" * variable , not sure how in vba. sending same key several times, try appending number inside brackets application.sendkeys "{bs 6}

How to check java compilation error in intellij -

it clear see compilation error in eclipse, found not clear in intellij, miss here ? thanks to see list of files compilation errors, click project on title bar of project tool window and, under scopes, select problems. other alternative use problems tool window (view | tool windows | problems). from 'intellij idea q&a eclipse users': https://www.jetbrains.com/idea/documentation/migration_faq.html

android - How to set circle progress bar on image using custom adapter -

hello creating social app whats app... want show circle progress bar on every image or video while uploading , downloading same whats app. please me how can using custom adapter. here code <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <relativelayout android:id="@+id/main_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" > <relativelayout android:id="@+id/imageview_layout" android:layout_width="150dp" android:layout_height="150dp"> <imageview android:id="@+id/displayimg" android:layout_width="150dp" android:layout_height="150dp" android:layout_alignparentleft="true" android:

java - How to produce zip data from rest easy -

i using rest easy in java application. end goal if request content-type of type zip, example application/x-gzip, response should zipped. i read in rest easy document can using gzip annotation. rest easy take care of it. but problem is, have quite lot web api calls, therefore adding annotation in methods not right solution. i looking solution in such way, define annotation @ 1 place instead of adding annotation(gzip) on every method, , if user has specified content type of zip, response zipped , sent user. filter or something. able find known dynamicfeature in documentation not know how achieve or implement this. can suggest how achieve or other way if exists.

java - Where are the attributes stored, which are set by servlets? -

below servlet: public class servletexample extends httpservlet { private static final long serialversionuid = 1l; protected void service(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { if(request.getparameter("firstname") == null || request.getparameter("lastname") == null){ this.getservletcontext().getrequestdispatcher("/index.jsp").forward(request, response); return; } string firstname = request.getparameter("firstname"); string lastname = request.getparameter("lastname"); request.setattribute("firstname", firstname); request.setattribute("lastname", lastname); this.getservletcontext().getrequestdispatcher("/output.jsp").forward(request, response); } } below index.jsp : <?xml version="1.0" encoding="iso-8859-1" ?> <%@ page

php - I want to know the difference between print two integer 204 and 0204 -

this question has answer here: int variable leading zero? 5 answers i want know difference between echo integer 204 , 0204 without quote. echo 204; // output : 204 echo 0204; // output : 132 refer #example 1 echo 204; // output : 204 because decimal number echo 0204; // output : 132 because octal number

java - How to build only once using Maven for CI -

im reading continius delivery , in book author says crucial build binarys once, , use same binarys every deployment. im having problem understanding how can done in practice? examaple in order run mocked unit tests there special build? im refering scope tag in maven. if @ maven life cycle you'll see have 1 compile task. tests, compiled , executed right after source compilation. mocked unit tests, same : 2 separated compilation 2 objectives. i think author of book refers problem may appear when deploy automatically on several environment : create more environment debug. compulsory have 1 final binary environment. if have several binaries split on environment, can assured forget difference there between 2 of them, argument give first 1 , not other. continuous delivery, has same everywhere. let's come on maven. maven has lot of possibilities during life cycle. you'll have run several build complete (as code coverage example). may useful in continuous integrat

unable to insert json object inside another in node.js -

usersmodel.findone({"username":username}).exec(function (err, users) { if (err) { logger.info("my error "+err); return res.status(500).send(err); } else if(!users) return res.status(404).send('no user found'); else { users["account"]="xxxxxxxxx"; return res.status(200).send(users); } }); i want insert account key pair value inside users json.but return users json not contain account fields.where issue ?

apache - Why does page hang/timeout with apache2, mod_wsgi, django, in virtual environment and under non-privileged user -

when go 52.1.65.249, page hangs or times out. have django project located under non-root user @ /home/usrbkto/bkto/projbkto. i have same problem on 2 servers running ubuntu 14.04 , python 2.7.8 , ubuntu 15.04 , python 2.7.9. believe mod_wsgi on pypi compiled using python 2.7.8, server running python 2.7.9 downloaded github , compiled using version of python on server. working fine until updated packages @ once, i'm not sure package update broke things. suspect has fact i'm not using new version of mod_wsgi correctly, i'm not sure , want keep django project under non-root user without access apache files. my custom conf file @ /etc/apache2/sites-available/bkto.conf is: wsgiscriptalias / /home/usrbkto/bkto/projbkto/projbkto/wsgi.py wsgipythonhome /home/usrbkto/vent wsgipythonpath /home/usrbkto/bkto/projbkto loglevel info <directory /home/usrbkto/bkto/projbkto/projbkto> <files wsgi.py> require granted </files> </directory> alias /media

ios - PFUser.currentUser vs String -

i'm working on ios swift parse. i've code snippet following: override func viewdidload() { super.viewdidload() var curruser = pfuser.currentuser() var prefquery = pfquery(classname: "preferences") prefquery.wherekey("username", equalto: curruser) ... the above codes gives me nothing although i've 1 record in 'preference' table current user. returns row when use : ... prefquery.wherekey("username", equalto: "kale") i'm confused what's wrong using pfuser.currentuser() method compare string? thanks in advance, you need use: pfuser.currentuser()?.username but because optional need unwrap best way is if let user = pfuser.currentuser()?.username{ //query user println("found user \(user)") } else { //error handle println("no user logged") }

apache kafka - Storm KafkaSpout can't read offset when topic partition more than 1 -

my kafkaspout set spoutconfig spoutconf = new spoutconfig(brokerhosts, topic, zkroot,clientid); spoutconf.scheme = new schemeasmultischeme(new stringscheme()); spoutconf.forcefromstart = false; spoutconf.zkservers=... spoutconf.zkport = 2181; spoutconf.zkhost = ... spoutconf.zkroot = zkroot; failing write offset data zookeeper in kafka-storm , found,when topic partition bigger 1, kafkaspout can't read offset zookeeper , there no settings in zookeeper.

PHP Session Array - store same item with different values -

i'm working on php cart system , have got problem. the problem: when user adds item , again, adds same item different values (different size or quantity) cart updates entry new values that's chosen user. previous details gets deleted. solution have been looking for if users adds item, , wants add same item different requirements, should added separate entry int cart session.(only if specific variable gets changed, example: single product different sizes). how can in current code? the cart //add item in shopping cart if(isset($_post["type"]) && $_post["type"]=='add') { $product_code = filter_var($_post["product_code"], filter_sanitize_string); //product code $product_size = filter_var($_post["product_size"], filter_sanitize_number_int); //product size $product_qty = filter_var($_post["product_qty"], filter_sanitize_number_int); //product quantity $return_url = base64_de

ios - Using Apple Script to move multiple files from multiple folders to one -

found forum while googling question, can't find answer for. i'm not programmer, i'm trying find out how can use applescript move multiple files 1 folder. have folder containing 900 images , corresponding text files which, after downloading, each contained within individual folder inside first folder (so 1 image file , 1 text file per folder x 900.) want these individual files out of individual folders , have 900 image files plus 900 corresponding text files in 1 single folder, can @ of images @ once. correct script doing this? tried: tell application "finder" move (every file of every folder of window 1) (get target of window 1) end tell that's on forum suggested, i'm getting error signs. let's original folder containing images called "single images" , folder want move them called "single images 2." both folders on desktop. right command this? or there application can more if apple script editor isn't right one?

html - How to center two square blocks in page? -

Image
i have page i'm displaying status of 2 websites -- in if they're , running, or not. if site up, want block have light green background, , if not, light red one. , site's name should centered inside block. this i've tried far: body { font-family: sans-serif; } #container { width: 800px; height: 600px; margin: 0 auto; border: 1px solid #ccc; } #smallcontainer { width: 208px; height: 100px; margin: 200px auto auto; } .status { height: 100px; width: 100px; background: #efefef; float: left; margin-left: 2px; border: 1px solid #ccc; } <div id="container"> <div id="smallcontainer"> <div class="status"></div> <div class="status"></div> </div> </div> it works (see full screen output ), feel i'm way off. how do sim

URLClassLoader Memory Leak Java -

i have been going through lot of urlclassloader memory leak solutions on internet, haven't found working code , precise solution. closest solution found this any functional code or link it, uses weakhashmap() or other definite way of eliminating memory leak problem on multiple redeploys? just add dependency of class loader leak preventer in build path. maven dependency : <!-- classloader leak protection --> <dependency> <groupid>se.jiderhamn</groupid> <artifactid>classloader-leak-prevention</artifactid> <version>1.8.0</version> </dependency>

polling - Invoke a python script on a remote server and poll the status -

i'm looking best way invoke python script on remote server , poll status , fetch output. preferable me have implementation in python. python script takes long time execute , want poll status intermediately on actions being performed. suggestions? there many options. 'polling' bad idea, assumes cpu occupation. you have script send status changes. you have script write it's actual status (remote) file (wither overwriting or appending log file) , can file. easiest way. can monitor file tail -f file on link and many more - , more complicated - other options.

ios - NSDate Organization -

Image
i'm attempting display timestamps in s, m, h format negative numbers on accounts of minutes format. better shown said: the tweet chris supposed 4m , tweet mina supposed 6m. here implementation code: // set timestamp nsdate *date = [nsdate datewithtimeintervalsince1970:[entry[@"created_time"] doublevalue]]; nsdate *currentdatentime = [nsdate date]; nscalendar *calendar = [nscalendar currentcalendar]; nsdatecomponents *instacomponents = [calendar components:(nscalendarunithour | nscalendarunitminute | nscalendarunitsecond) fromdate:date]; nsinteger instahour = [instacomponents hour]; nsinteger instaminute = [instacomponents minute]; nsinteger instasecond = [instacomponents second]; nsdatecomponents *realcomponents = [calendar components:(nscalendarunithour | nscalendarunitminute | nscalendarunitsecond) fromdate:currentdatentime]; nsinteger realhour = [realcomponents hour]; nsinteger realminute = [realcomponents minute]; nsinteger realsecond = [realcomponents secon

html - How to make a horizontal scrolling area for left-floating element? -

Image
i want outer <div> scroll in x-axis only, it's not working. .wrapper { width: 98%; height: 320px; padding-left:1%; padding-right:1%; white-space: nowrap; overflow-y: hidden; overflow-x: scroll; -webkit-overflow-scrolling: touch; background-color: #fff; float:left; position:absolute; } .internal { width:250px; height:320px; display: inline; background-color: wheat; float:left; position:static; } <div class="wrapper"> <div class="internal">item 1</div> <div class="internal">item 2</div> <div class="internal">item 3</div> <div class="internal">item 4</div> <div class="internal">item 5</div> <div class="internal">item 6</div> <div class="internal">item 7</div> </div> on screen, renders as: wh

json - Convert 2015-06-01T02:31:00+0000 to DateTime object c# -

i'm writting app consume webservice: http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json as can see there, json object comes utc datetime field. want save information in simple datetime object following format "yyyy-mm-dd hh:mm:ss". this code: datetime dateparsed = datetime.now; datetime.tryparseexact((string)resource.selecttoken("resource").selecttoken("fields")["utctime"], "yyyy'-'mm'-'dd't'hh':'mm':'ssz", cultureinfo.invariantculture, system.globalization.datetimestyles.adjusttouniversal, out dateparsed); i'm getting datetime object initialized in year 0001. what i'm doing wrong? thank in advance. you have error in format-string. working sample: using system; using system.globalization; public class program { public static void main() { datetime dateparsed = datetime.now; if ( datetime.trypars

angularjs - Can I develop an app for hybris with ionic? -

i know hybrid has provided these wrappers in form of android sdk , ios sdk. but if have use ionic develop app hybris? can use sdk provided hybris? yes can, 1 of nice things of hybris can create own extensions in hybris want, i.e. create custom ui, or make use of web services create ui outside of hybris. know there projects had front end using angular. might struggle find documentation on not ootb, hybris won't prevent sort of development. it's possible sure give go , try.

java - Array vs ArrayList: Dynamic Use -

both arraylists , vectors make use of typical arrays internally. however, leaves me thinking... why use arraylists when can technically same thing using arrays? convenience reason? performance-critical applications ever make use of arraylist? any tips appreciated. i believe there multiple reasons prefer lists on "implementing lists on arrays" or on "using arrays", here 2 think important: lists have better support generics arrays (you can, , should , read in "effective java" bloch - see item 25 ) if ask using arraylist vs. implementing - find hard believe you'll better job guys developed in openjdk ( josh bloch , neal gafter ).

sql - Insert (append) memo lines to database using a parameter -

how can append cxmemo1 text database field (which memo type) contains data ? if use : datamodule2.t2.params.parambyname('a3').value := cxmemo1.text; the prior text gets overwritten. how can append ? this part of update query. in update query may use : update table t set t.my_memo_field = coalesce(my_memo_field,'') || :a3 t.id = :pkey update: added coalesce in case of old value null.

How to detect HTTP request by analysing JavaScript & HTML? -

i'm wondering if can analysis on javascript code detect whether web page contains these js send http request other domain. for example, 1 put static web page files in web server(domain a), , don’t want file send http request other site(domain b, example). there’re ways can this: using img tag: <img src=“http://domain.b.com/statics”> using script tag. using form tag. using iframe tag. what’s more, can use js generate http request, example: var f = document.createelement('form'); f.action = "http://domain.b.com/statics"; ... javascript obfuscated, javascript above compressed as: eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,string)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new regexp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4 0=3.2(\'1\');0.5="9://8.7.6/10";',10,11,'f|for

Android Orientation Change: Different Layout, Same Fragments -

Image
this pretty classic android use case. say have 2 fragments: fragmenta , fragmentb. in landscape mode, fragmenta , fragmentb sit side side. in portrait mode, each take full screen when in use. (see image replace tablet->landscape , handset->portrait) as explained here ( supporting single-pane , multi-pane layouts ), there 2 ways achieve this: 1- multiple fragments, 1 activity: use 1 activity regardless of device size, decide @ runtime whether combine fragments in layout (to create multiple-pane design) or swap fragments (to create single-pane design). 2- multiple fragments, multiple activities: on tablet, place multiple fragments in 1 activity; on handset, use separate activities host each fragment. example, when tablet design uses 2 fragments in activity, use same activity handsets, supply alternative layout includes first fragment. when running on handset , need switch fragments (such when user selects item), start activity hosts second fragment. this

python - Is This a Valid HeapSort? -

for past 6 hours, i've been reading tutorials , academic material on constructing heapsort. have prototyped in python sorts list of integers. however, i'm not entirely sure whether or not solution constitutes valid heapsort. it's simplistic solution , can improved upon, i'm wondering whether valid @ all. confusingly, seems have own 'preferred' way of implementing algorithm. many in advance. def heapsort(array): array = heapify(array) array = insert(array, 9999) print(array) def heapify(array): end = len(array) = 0 j = 0 while < end: while j < end: if array[i] > array[j]: array = swap(array, i, j) j += 1 += 1 j = return array def insert(array, x): array.append(x) return heapify(array) def swap(array, a, b): temp = array[a] array[a] = array[b] array[b] = temp return array def main(array): heapsort(array) if __name__ ==

ios - Xcode Mass Multiplayer (Not What You're Probably Thinking) -

okay make game, i'm trying not divulge requires of level in game playing able see each other in sort of mmo style not really. for example: suppose have players bob, mary, , rob. suppose bob level 4, mary level 6 , rob level 4. these shown in leaderboards way. bob , rob , else level 4 , playing see each other in sprite kit seen. mary off other level 6's. i have little idea of start this. questions are: should use xcode or better off using unity? does gamecenter have capabilities or need use parse or that and also, please point me in right direction far concepts of how work? if can answer of awesome!!!!! if not that's cool too! in advance! xcode ide , unity game-engime. if need create own game since beginning, should use ide. long , sometime difficult. game-engime, big part of game programmed (physic, 3d animations...) can focus time program game. game center share game or score. not played online. for play online, should create own server

Which version of netCDF contains libnetcdf.so.6? -

it's in title. i have version 4.1.3 installed, , contains libnetcdf.so.7 . is question better fit different se site? version 4.1.1 contains libnetcdf.so.6 .

c - Confused with making an input into an empty array. -

say make input : "hello world" // hit new line "goodbye world" // second input how scan through 2 lines , input them separately in 2 different arrays. believe need use getchar until hits '\n'. how scan second input. thanks in advance. beginner in c please it'd helpful without pointers haven't covered topic. try code out : #include<stdio.h> int main(void) { int flx=0,fly=0; char a,b[10][100]; while(1) { a=getchar(); if(a==eof) exit(0); else if(a=='\n') { flx++; fly=0; } else { b[flx][fly++]=a; } } } here use 2 dimensional array store strings.i read input character character.first create infinite loop continues reading characters.if user enters end of file character input stops. if there newline character flx variable incremented , next characters stored in next array position.you can refer strings stored

python - How to run Flask app with Tornado -

i run simple app written in flask tornado. how do this? want use python 2.7 , latest tornado version (4.2). from flask import flask app = flask(__name__) @app.route('/') def hello(): return 'hello world!' if __name__ == '__main__': app.run() the flask docs used describe how this, has been removed due performance notes below. don't need tornado serve flask app, unless async code written in tornado. from tornado.wsgi import wsgicontainer tornado.httpserver import httpserver tornado.ioloop import ioloop yourapplication import app http_server = httpserver(wsgicontainer(app)) http_server.listen(5000) ioloop.instance().start() the tornado docs wsgi describe well. include big warning less performant using dedicated wsgi app server such uwsgi or gunicorn.

php - Sort grouped (by type) search results by date? wp -

i'm trying sort , split/group search results date order. have added sort post type functions already. posts in misc order, whist dates have been removed page results. thank if can me! tried methods below split posts/pages titles: wordpress group post type on search page , https://wordpress.stackexchange.com/questions/14881/seperating-custom-post-search-results if it's not possible both, i'd able sort date page results last. functions.php: <?php if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'sidebar1', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="title">', 'after_title' => '</div>',)); register_sidebar(array( 'name' => 'sidebar2', 'before_widget' => '<div id=

php - How to check for matching key value pairs -

i have sets of arrays key value pairs: $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 1, 'yellow' => 7, 'cyan' => 8); how check both arrays contain match key , value together ? want place condition if $array1 , $array2 have matching pair blue=>1 something? you can use array_intersect_assoc : php > var_dump(count(array_intersect_assoc($array1,$array2)) > 0); bool(true) php > $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); php > $array2 = array('green' => 5, 'blue' => 2, 'yellow' => 7, 'cyan' => 8); php > var_dump(count(array_intersect_assoc($array1,$array2)) > 0); bool(false)

javascript - How to store accumulated result of a scan with rxjs -

i have 2 merged observables scan after merge. first 1 simple range , other subject. whenever subject emits new value onnext concatenate value in scan , return new array accumulator. if dispose of subscription, , subscribe again replays values range have lost ones subject. in code below want second subscription have final value of [1, 2, 3, 4, 5] what best way this? right have subject store final value , subscribe that, feels wrong. here's simple version demonstrates happening: var rx = require('rx'); var source = rx.observable.range(1, 3); var adder = new rx.subject(); var merged = source.merge(adder) .scan([], function(accum, x) { return accum.concat(x); }); var subscription1 = merged.subscribe(function(x) {console.log(x)}); adder.onnext(4); adder.onnext(5); subscription1.dispose(); console.log('after disposal'); var subscription2 = merged.subscribe(function(x) {console.log(x)}); t