Posts

Showing posts from January, 2015

c# - await for another method -

i think need async await program can't figure out how it. getdata method need send request socket, , socket data same method. need pass data somehow onreceive initial getdata method. possible implement await async tasks here? here simplified scheme: asynccallback m_pfnlookupcallback; socket m_sock; public void getdata() { string data; if (condition) data = getdatafromcache(); else data = getdatafromnet(); /// !need await socket data here //will process data here. } public string getdatafromnet() { m_sock.send(szcommand, ibytestosend, socketflags.none); waitfordata("s1"); } public void waitfordata(string ssocketname) { m_pfnlookupcallback = new asynccallback(onreceive); m_sock.beginreceive(m_szlookupsocketbuffer, 0, m_szlookupsocketbuffer.length, socketflags.none, m_pfnlookupcallback, ssocketname); } private void onreceive(iasyncresult asyn) {...

ruby - Issue with Rails 4.2.1 in routing paths -

1) messagecontroller should check status failure/error: :status runtimeerror: in order use #url_for, must include routing helpers explicitly. instance, include rails.application.routes.url_helpers. # /users/vishal/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.1/lib/abstract_controller/url_for.rb:13:in _routes this error getting on running specs. route.rb file valid , when run rails server , hit status url shows page needed, while running rspec test case fails. any suggestions? as error says.. use application helpers in spec need include them explicitly applicationhelper doesn't include them default: module applicationhelper include rails.application.routes.url_helpers ... end using rspec.. add rspec_helper.rb rspec.configure |config| config.include rails.application.routes.url_helpers ... end

html - How can I center this div in Bootstrap? -

i using bootstrap build website. i don't understand how center <div> within <div> . believe should able use -offset accomplish when not in number surely never going possible center exactly, or there way? i need center <div> containing gender @ http://www.bootply.com/tdcsiiuhfe i don't think can center filed in grid odd number of columns. option 1 enlarge container 4 column, field 2 , can center grid system option 2 just use css: left: 50%; margin-left: -82px; hope helps

jquery - Cycle through array with animation -

so want cycle through list of arrays when click button, i've found info can't figure out how , put code have already, check below see have already; my current code [1]: http://codepen.io/anon/pen/pqkywz if me out that'd great! it'd bonus if show me how style launch link, reason being annoying hell? if cycle mean display name of games 1 one before displaying final name of game here can do, here demo so have altered pickrandomword() , tick() , created 2 global variables "i" , "s" below, var = 0; var s; function pickrandomword(frm) { s = setinterval(function() { tick(frm); }, 180); } function tick(frm) { frm.wordbox.value = words[i+1]; i++; if (i > 27) { clearinterval(s); var rnd = math.ceil(math.random() * numberofwords); var index = words[rnd].indexof("/"); frm.wordbox.value = words[rnd].substring(0, index); var link = docume...

matlab - Set specific elements on a matrix to zero -

i want preserve elements in 36x18x12000 matrix , set else zero. in particular, i'm interested in getting values of specific region in 36x18 map through time. code i'm trying use following: coflux_sam(1:26,1:3,:)=0;coflux_sam(35:36,11:18,:)=0 what plan here keep south american region (lon 27:34 ; lat 4:10 in map) , delete rest, basically. i'm getting pretty annoyed of finding neither line nor loop: for i=1:26 j=1:3 coflux_sam(i,j,:)=0; end end i=35:36 j=11:18 coflux_sam(i,j,:)=0; end end are working. seem make random modifications in matrix don't find pattern it. sorry delay in putting answer here, saw had to close thread. copy , paste can closed. cheers ok, nevermind...i being silly , getting worried code , not logic behind wanted. changed code to: 'coflux_sam(1:26,:,:)=0;coflux_sam(35:36,:,:)=0; coflux_sam(:,1:3,:)=0;coflux_sam(:,11:18,:)=0;' , works. previous 1 deleting intersection between longitude , la...

string - Select Concat Substring and Replace in MySQL -

i have .sql file needs characters removed , text left. inside " ". example of text field in column a:1:{i:0;s:9:"test word here";} a:1:{i:0;s:11:"test words here too";} so want words. test word here. , test words here too. left in text field. i went this. update `questions` set answer = replace(replace(replace(replace(answer, 'a:1', ''), 's:4', ''), 'i:0', ''), ',', '') but realized s:4 has s:5, s:16 etc. wouldn't work. next attempt use concat , remove amount of characters starting a:1. able working select. not able replace work. below can see working select. select concat('tt', substring(`answer`, -locate('a:1', `answer`)+15) ) `questions`; here attempt @ getting replace work it. i'm stuck. i'm open suggestions, in case i'm going in complete wrong direction here anyways. select concat(replace('tt', sub...

c - Call to fdopendir() corrupts file descriptor -

i stumbled upon problem in program working on. following reproduces issue: #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <sys/types.h> #include <dirent.h> #include <fcntl.h> #include <sys/stat.h> int main(int argc, char *argv[]) { int fd, ret_fd; dir *dirp; fd = open("./", o_rdonly); #if 1 if ((dirp = fdopendir(fd)) == null) { perror("dirp"); return 1; } closedir(dirp); #endif ret_fd = openat(fd, "makefile", o_rdonly); if (ret_fd == -1) { perror("ret_fd"); return 1; } return 0; } basically, call openat() , has been preceeded fdopendir() , fails with: bad file descriptor . however, not happen if fdopendir() omitted. i know fdopendir() makes internal use of file descriptor, shouldn't revert changes after calling closedir() ? what can prevent openat() failing in case? the posix descri...

Javascript three.js smooth camera motion -

in javascript, can use document.addeventlistener('keydown', function(event){...}); add key listener. however, when using three.js , moving camera key, camera moves once, delays, , continues moving. because computer delays key holding fixed amount of time. how go making camera move smoothly when key pressed? try starting continuous movement on keydown, , halting on keyup. that's general way hold inputs.

ef code first - Entity Framework Many to Many Relation on same entity with additional parameters -

i have city entity: public class city { public int id { get; set; } public string name { get; set; } public virtual icollection<citydistance> citydistances { get; set; } } and keep distances between cities. 1. how can achieve in code first entity framework 6? here other classes: public class citydistance { [key, column(order = 0)] public int cityaid { get; set; } [key, column(order = 1)] public int citybid { get; set; } public virtual city citya { get; set; } public virtual city cityb { get; set; } public double distance { get; set; } } is correct design? when run "add-migration distances" here result. 3. why adding foreign key column named "city_id"? createtable( "dbo.citydistances", c => new { cityaid = c.int(nullable: false), ...

linux - Bash: Unexpected parallel behavior when reading arguments from file using xargs -

previous this follow-up this question. specs my system dedicated server running ubuntu desktop, release 12.04 (precise) 64-bit, 3.14.32-xxxx-std-ipv6-64. neither release or kernel can upgraded, can install package. problem the problem discribed in question above seems solved, doesn't work me. i've installed latest lftp , parallel packages , seem work fine themselves. running lftp works fine. running ./job.sh ftp.microsoft.com works fine, needed chmod -x script running sed 's/|.*$//' end_unique.txt | xargs parallel -j20 ./job.sh ::: not work , produces bash errors in form of /bin/bash: <server>: command not found. to simplify things, cleaned input file end_unique.txt , has following format each line: <server> each line ends in crlf, because imported windows server. edit 1: this job.sh script: #/bin/sh server="$1" lftp -e "find .; exit" "$server" >"$server-files.txt" edit 2: i ...

javascript - Angular ngClass multiple ternary operator conditions -

what best way put more 1 ternary conditional class in angular's ngclass directive, values class-names? i've tried few variations on this, compiling error: ng-class="$index > 2 ? 'l3 m4 s12 medium' : 'l4 m6 s12 medium', true ? 'red':'blue' ng-class="{$index > 2 ? 'l3 m4 s12 medium' : 'l4 m6 s12 medium', true ? 'red':'blue'} my preferred syntax ng-class following, since explicit classes adding. ng-class={ 'classname' : yourconditionhere, 'class2' : anotherconditionhere } give try.

xml - AttributeError: Element instance has no attribute '__float__' in Python -

i error when run script attributeerror: element instance has no attribute '__float__' my code looks this: def populate(): parsedfiles = minidom.parse('c:\users\user\downloads\new folder\streettrees_arbutusridge.xml') treelist = parsedfiles.getelementsbytagname('streettree') alltrees in treelist: treeid = alltrees.getattribute('treeid') neighbourhood = alltrees.getelementsbytagname('neighbourhoodname') commonname = alltrees.getelementsbytagname('commonname') diameter = alltrees.getelementsbytagname('diameter')[0] diameter = float(diameter) streetnumber = alltrees.getelementsbytagname('civicnumber') street = alltrees.getelementsbytagname('stdstreet') lat = 0 lon = 0 add_tree(treeid=treeid, neighbourhood=neighbourhood, commonname=commonname, diameter=diameter, streetnumber=streetnumber, street=street,...

Convert a full length column to one variable in a row in R -

i wondering if possible convert 1 column 1 variable next eachother i.e.: d <- data.frame(y = 1:10) > d y 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 convert column into: > d 1 2 3 4 5 6 7 8 9 10 we don't know how going use numbers, think unnecessary make transformation. can use d$y numbers applied map of colors. see example. d <- data.frame(y = 1:7) library(rcolorbrewer) mypalette<-brewer.pal(4,"greens") mycol <-palette()#rainbow(7) heatmap(matrix(1:28,ncol=4),col=mypalette[d$y[1:4]],xlab="greens (sequential)", ylab="",xaxt="n",yaxt="n",bty="n",rowsidecolors=mycol[d$y])

Using humane.js with aurelia -

i'm trying use humane.js aurelia i'm running in problem. it appears humane.js adds element dom when it's created , far way i've found force this.... showmessage(message) { this.notify = humane.create(); this.notify.log(message); } however creates new instance of humane every time showmessage() called. breaks queue each 1 rendered separately. i've tried putting create() in activate() method of view model doesn't seem work either. any ideas? this solved problem, i've created custom element humane included in app.html in same way loading-indicator in skeleton app. import humane 'humane-js'; import 'humane-js/themes/original.css!'; import {inject, noview} 'aurelia-framework'; import { eventaggregator } 'aurelia-event-aggregator'; import { apistatus } 'resources/messages'; @noview @inject(eventaggregator) export class statusindicator { constructor(ea) { this.ea = ea; ea.subsc...

html - Jquery doesnt perfectly work after browser resize? -

Image
those triggers when scroll reaches element not work when browser re-sized works if reloaded after re-sizing. how make triggers work after browser re-size guess messes position of divs? #main { width: 100%; } nav { position: fixed; top: 5%; height: 30%; text-align: center; display: block; z-index: 999; width: 100%; } nav { font-size: 20px; font-family: 'montserrat'; color: #808080; text-decoration: none; text-transform:uppercase; opacity: 0.9; word-spacing: normal; display:inline-block; width: 176px; height: 30px; padding-top: 7px; z-index: 999; } html,body { margin: 0; padding: 0; height: 100%; width: 100%; } #test {position: relative; width: 100%; height: 100%; background-color: #ffd800; } #test2 { position: relative; display: block; width: 100%; height: 100%; ba...

Simple onClick Every Other Click Javascript HTML -

onclick="handleaction(\'playnow\');handleaction(\'stop\');" performs 2 functions simultaneously. no since action \playnow\ , \stop\ after. i need onclick perform function every other click. click 1: \playnow\ click 2: \stop\ click 3: \playnow\ etc. is there simple way achieve this? define var holds current state: var state = false; function handleaction() { if (state == false) { // stuff 'playnow' action state = true; return; } if (state == true) { // stuff 'stop' action state = false; return; } }

caching - Intelligently cache google places -

i'm attempting build multiplayer gps game uses google places retrieve local places, such stores or other points of interest. saw here might bit difficult straight-up cache of information get, @ same time, i'm concerned i'll hit api limits quickly, i'm looking intermediate solution. i'm trying come way intelligently cache google places. supposing there 1 player per city, wander around , discover things , possibly not have problems if keep asking google data every often. base case hitting google "you logged in, there 0 places around you, lets google" , update case "you traveled distance start location, lets more data around you" however, when 2 players start in opposite sides of city, that's bit trickier. if cache results find, might possibly miss points of interest. suppose p2 starts on outside of circle of p1 has been; means p2 not data elsewhere because have data (because follow previous algorithm, p1 has explored area, when p2 logs...

python - Dynamic Dictionary Field Names -

i'm trying create dictionary dynamic names ( m['field1'], m['field2'], etc). i'm getting error: typeerror: string indices must integers, not str index = 0 in results: metrics['users']['total']['month' + str(index)] = results[index][1] index = index + 1 when dictionary doesn't have specific key (e.g. when metrics empty , doesn't have users key), reading dictionary key (i.e. metrics['users'] ) error. i'm not sure want, following code runs fine: metrics = {'users': {'total': {}}} results = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] index = 0 in results: metrics['users']['total']['month' + str(index)] = results[index][1] index = index + 1

java - how to parse this in android with json -

i want parse json in android. can me how parse, if need start head parse or results don't know. can me { "head": { "link": [], "vars": ["city", "country"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "city": { "type": "uri", "value": "http://dbpedia.org/resource/ferizaj" } , "country": { "type": "uri", "value": "http://dbpedia.org/resource/kosovo" } } ] } } okay, first of json string you've gi...

ruby on rails - Sortable UUIDs and overriding ActiveRecord::Base -

i'm wanting use uuids in app i'm building , running bit of problem. due uuids (v4) not being sortable because they're randomly generated, i'm trying override activerecord::base#first, rails isn't pleased that. yells @ me saying argumenterror: tried define scope named "first" on model "item", active record defined class method same name. have use different method if want sort , have sort correctly? here's sauce: # lib/sortable_uuid.rb module sortableuuid def self.included(base) base.class_eval scope :first, -> { order("created_at").first } scope :last, -> { order("created_at desc").first } end end end # app/models/item.rb class item < activerecord::base include sortableuuid end rails 4.2, ruby 2.2.2 reference: http://blog.nakonieczny.it/posts/rails-support-for-uuid/ http://linhmtran168.github.io/blog/2014/03/17/postgres-uuid-in-rails/ ( drawbacks section ) fi...

ios - Swift 2.0 minimum system version requirement (deployment target) -

so swift 2.0 coming xcode 7, minimum ios / os x system version required use swift 2.0? an apple staffer had say : ios 7 / os x 10.9, same swift 1.0. update: i'm guessing because runtime packaged built app / library / framework / whatever same swift 1.x.

Trello "PUT" API Access performission requirement -

i understand access permission of trello api "put /1/boards/[board_id]". in document, required permissions: read, put request trello. why has read permission while put may need change information on server according http protocol ? you'll notice of routes (like put /1/boards/[board_id]/myprefs/emailposition ) have read permission despite causing writes - because read doesn't affect state of board, rather affects how current member views board. the "mass put" route uses lowest-common-denominator permission can use set set scoped put. also check permissions each of individual fields trying set, , fail if don't meet of them.

python - How to create a trigger with threading.Timer? -

i discover python last month, i'm not programmer @ all. i'm trying create own software electronic instrument. need create trigger call function each 0.04 ms (if it's possible). tried this: in first file metronome.py: class metronome: def __init__(self, clip, _matrix): self.clip = clip self._matrix = _matrix self.inc = -1 def _trigger(self): self.inc = self.inc + 1 self._matrix.get_button(self.inc, 1).send_value(green_full) t = threading.timer(1.0, self._trigger).start() in second file , new class: i import previous function with: from metronome.py import metronome i call previous function with: metronome(self.clip, self._matrix)._trigger() in _trigger function, self._matrix.get_button(self.inc, 1).send_value(green_full) allows me send led feedback on instrument interface. when launch program, first led feedback on instrument. however, others take more 1 second setup , of them appear @ same t...

php - Force included pages to be included (i.e. not opened by themselves) -

i in process of creating own cms system because of tired of wordpress (and hack attempts come it). my question this: there way force pages in includes directory opened included pages? looking @ doing allowing search engines crawl public_html/blog_files , /public_html/pages folders, if google displays them in searches, want open included page inside of pre-determined page. typically, website call single_post.php page blog_abc123.php page included. if opens blog_abc123.php, want include inside of single_post.php page , display single_post.php page blog_abc123.php in it. i hope explained well, , can understand idea. thanks in advance help. why includes publicly accessible in first place? need fix that. in meantime, can use get_included_files() returns array containing files have been included in script far. counting contents of array, can determine if current file being included or not (because if not, file). can redirect correct parent page: <?php if (count(...

javascript - Private messaging in node js and socket io using php -

i developing chat application using nodejs,socket.io , php,but got simple error in private messaging between 2 users .here using email id unique key each user. when user send message user b can't read messages until when user b send message user after works expected. chat.php <form class="form-inline" id="messageform"> <input id="messageinput" type="text" class="input-xxlarge" placeholder="message" /> <input type="hidden" name="" id="to" value="<?php echo $recevierid; ?>"> <input type="submit" class="btn btn-primary" value="send" /> </form> here hidden field contains email id of receiver. chat.js $( "#messageform" ).submit( function() { var msg = $( "#messageinput" ).val(); var =$( "#to" ).val(); socket.emit('join', { message:msg,to:to} ); ...

javascript - External JS Doc Not Working -

so i'm practicing javascript skills simple little script change heading size , color upon click. when run js within html doc within script tags works fine, when run page in browser, console gives me error: "uncaught typeerror: cannot read property 'addeventlistener' of null - (anonymous function) @ practice.js:13" html code: <!doctype html> <html> <head> <title>javascript</title> <link rel="stylesheet" href="main.css"> <script src="practice.js"></script> </head> <body> <h1 id="main-heading">hello</h1> <p class="para">lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p class="para">lorem ip...

css - How to disable paragraph text selection on ios with ionic framework -

i have web app created ionic framework. have select text on ios safari , action on selected text. problem: when want select word (by holding tap on ios) selects whole paragraph. depending on font size , paragraph length , it sometimes select word, sometimes select whole paragraph , allow modifying (decreasing) selection word sometimes select whole paragraph , disallow modifying (decreasing). (can not select want) here video demonstrating problem: http://screencast.com/t/zsrhyk1gjzy question: how can disable paragraph selection , force word selection on ios safari? there should way conducting text selection behaviour. css or html trick.

html - Nested fixed element not work in IE -

Image
i'm trying put fixed element within fixed element this <div class="wrapper-fixed"> <div class="content"> <div class="element-fixed"> <p>i'm fixed in chrome, ff</p> <p>why not in ie ?</p> </div> </div> </div> when scroll page in chrome , ff element-fixed stay fixed in ie scrolls , guess should not happen because fixed element outside document flow. i tried pulling out of content did not work, pulling out of wrapper-fixed in case can't. here jsfiddle similar real situation so why happens , how fix without pulling out of wrapper-fixed adding images illustrate problem: option 1 change wrapper position absolute .wrapper-fixed{ position: absolute; ... fiddle - http://jsfiddle.net/za4hdmpf/ option 2 won't suitable requires solution not involve pulling element-fixed out of wrapper-fixed...

mongodb - Appengine + Hibernate OMG - how to make it work? -

i trying simple example running jetty dev server comes eclipse plugin. far no luck. code: this code: entitymanagerfactory entitymanagerfactory; entitymanager entitymanager; entitymanagerfactory = persistence.createentitymanagerfactory( "hike-pu" ); entitymanager=entitymanagerfactory.createentitymanager(); entitymanager.gettransaction().begin(); person p = new person("peter"); entitymanager.persist(p); hike mountkillmore=new hike("mountkillmore flat", "palm springs"); mountkillmore.organizer=p; p.organizedhikes.add(mountkillmore); hike rushduddeldei=new hike("rushdudeldidei down", "rush upstream"); rushduddeldei.organizer=p; p.organizedhikes.add(rushduddeldei); entitymanager.persist(p); entitymanager.persist(mountkillmore); entitymanager.persist(rushduddeldei); entitymanager.gettransaction().commit(); entitymanagerfactory.close(); and here error stacktrace getting: java.lang.exceptionininitializererror ...

ruby - How do I associate an Activerecord Object with Em-Websocket connection? -

i new ruby. trying implement chat client using em-websocket. have following code: eventmachine::websocket.start(host: '0.0.0.0', port: 8080) |websock| websock.onopen puts 'new connection opened' cookies = cgi::cookie::parse( websock.request["cookie"]) person = person.where(['token = ?', cookies["token"]]).first unless person websock.close(code = nil, body = {error: "invalid token"}.to_json) unless person return end puts "#{person.name} authenticated!" person=person.attributes.merge(websock.attributes) # doesn't work # subscribe new user grindserver.realtime_channel callback function push action new_user = grindserver.realtime_channel.subscribe { |msg| websock.send msg } grindserver.online_people << person # add new user user list @users[websock.object_id] = new_user # push last messages user # ...

chrome web store - How does an unpublished extension get weekly users? -

Image
this weird. have extension not available through webstore because it's marked private , still pending review. however, see weekly users count increasing. when counter @ 1, thought somehow tracking own usage of locally built .crx extension because manifest contains public key. it's @ 10? is there kind of accidental public link pending extensions don't know about? when published item private means trusted testers set see , install extension. besides that, team in google handles manual review , marked item pending review (maybe due policy violation) see , install extension ether (probably testing). status data counted probably. best knowledge, there's no kind of accidental public link pending extensions said.

php - 766 versus 666 Permissions on an Upload Directory -

is 766 permissions okay directory website users can upload images to? i using 766 because when set directory 666, script returns error , file not uploaded. please there explanation this? thanks yes, 755 way go because user need execute flag enter directory. edit same issue 766 if web user either group or others . 6 = read/write , lack execute flag. so 7 66 wont work if web server not owner of directory.

excel - INDEX MATCH with different sizes of arrays -

i trying link dividends of several stocks range of dates. dividends several months apart, column date , column b amount of dividend. each stock has 10-20 dividend payments in last 5 years. trying distribute these dividend payouts across daily timeline, column shows daily dates today until 2005 (3818 rows). i tried index/match following formula: =index([a68u.si.csv]a68u.si!$b$2:$b$13,match([a68u.si.csv]a68u.si!$a2,$a2:$a3818)) however, #ref error. seems wrong approach. have idea? many thanks! use vlookup : =vlookup(a2,[a68u.si.csv]a68u.si!$a$2:$b$13,2,false) to remove errors dates when there no paid dividends: =iferror(vlookup(a2,[a68u.si.csv]a68u.si!$a$2:$b$13,2,false),"") if have more 1 paid dividend on same date, have use different.

Adding entries from multiple MySQL tables using one single SQL join statement, but only if there are entries available in the second table -

using 1 single sql query join: how can add entries second table if there corresponding entry available? project source description | source source_id | value ---------------------------- -------------------------------- project 1 | 1 1 | additional info 1 project 2 | null when type select project.description, source.value project, source project.source = source.source_id , project.description = "project 1"; as desired receive project 1 | additional info 1 however when replace project 1 project 2 in last line, won't result, because project.source null . possible use single sql query outputs this? project 2 | null i´m looking query covers both cases. any ideas? you can use left join on project table make sure all projects appear in result set if have no matching value in source table. proj...

php - Object not found - Netbeans always give error like so -

Image
when ever try run php class netbeans error. not have clue ever because apache web server , mysql both running can see in picture, why every time giving error. can please me this. have tried couldn't find out problem.

.net - Compile a non-commandline application using CodeDomProvider? -

i've written simple function automate compilation of single exe assembly embedded resource: public shared function compileassembly(byval codeprovider codedomprovider, byval isexecutable boolean, byval targetfile string, optional byval resources ienumerable(of string) = nothing, optional byval code string = "") compilerresults dim cp new compilerparameters cp ' generate exe or dll. .generateexecutable = isexecutable ' set assembly file name generate. .outputassembly = targetfile ' set compiler argument optimize output. .compileroptions = "/optimize" ' specify class contains main method of executable. if codeprovider.supports(generatorsupport.entrypointmethod) .mainclass = "mainclass" end if ' set embedded resource file of assembly. ...

Splitting Python List -

i want split list below: my_list = [(55, 22), (66, 33), (77, 44)] i have tried: a, b = my_list this did not work. what need is: a = [55,66,77] b = [22,33,44] i looking simplest , easiest way. in [18]: l = [(55, 22), (66, 33), (77, 44)] in [19]: a,b = zip(*l) in [20]: out[20]: (55, 66, 77) in [21]: b out[21]: (22, 33, 44)

The best way to detect any change to Internet Connection xcode swift -

i wondering if there best way detect change happens internet connection i mean using code import systemconfiguration var isconnected: bool = false func isconnectedtonetwork() { var zeroaddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) zeroaddress.sin_len = uint8(sizeofvalue(zeroaddress)) zeroaddress.sin_family = sa_family_t(af_inet) let defaultroutereachability = withunsafepointer(&zeroaddress) { scnetworkreachabilitycreatewithaddress(nil, unsafepointer($0)).takeretainedvalue() } var flags: scnetworkreachabilityflags = 0 if scnetworkreachabilitygetflags(defaultroutereachability, &flags) == 0 { self.isconnected = false } let isreachable = (flags & uint32(kscnetworkflagsreachable)) != 0 let needsconnection = (flags & uint32(kscnetworkflagsconnectionrequired)) != 0 if isreachable && !needsconnection { self.isconnected = true } else{ self.isconnected = false ...