Posts

Showing posts from July, 2010

r - How to check the consistency of specific variables from different IDs registered repeated times in a dataframe -

i know how can detect if different individuals captured repeated times have same value in specific variables along different measures. specifically, have repeated measures of individuals (column id) values of different variables along time (e.g. sex, weight) i check individuals assigned time same sex, having reference last measure because measure reliable. later store every row or register mismatch references in 1 dataframe. id <- c("1", "2", "3", "1", "2", "3", "1", "2", "3") sex <- c("m", "f", "m", "m", "m", "m", "f", "f", "m") weight <- c(20, 15, 30, 22, 18, 32, 26, 21, 36) time <- c(1, 1, 1, 2, 2, 2, 3, 3, 3) df <- data.frame (id, sex, weight, time) df to that, have selected last register of each id library (data.table) dt <- as.data.table (df) dt_last_register <- dt [

c - Passing array to function results in segmentation fault (core dumped) -

i trying build quicksort function results in segmentation fault (core dumped) . having read error sure have stray pointer can't spot it. used valgrind me debug , comment lines valgrind told me in following piece of code: #include <stdio.h> #include <assert.h> int partition(int *a,int l, int h, int pivot) { l++; while(l <= h && a[l] < a[pivot]) { l++; } while(a[h] >= a[pivot]) { //conditional jump depends on uninitialised value here h--; } if(l < h) { int tmp = a[l]; a[l] = a[h]; a[h] = tmp; partition(a,l,h,pivot); } else { int tmp = a[pivot]; a[pivot] = a[h]; a[h] = tmp; return h; } return -1; } void quicksort(int *a, int low, int high) { //base case. if(low - high == 0){ return; } //just 2 elements in array sorted if(low - high == -1) { if (a[low] < a[high]) { int tmp = a[low]; a[low] = a[high]; a[high] = tmp; }

java - Eclipse error adding images to an array -

i new android programming. found tutorial on how create simple gallery app android phones/tablets. finished beta of app, using 10 example images called a1.png, a2.png... a10.png in new resource folder (app/res/drawable/) my code was: private integer[] smallprev = { r.drawable.a1, r.drawable.a2... r.drawable.a10 }; and working should when tested app on phone. saw a1, a2... a10 indentified somehow in r.java file in project: public static final class drawable { public static final int a1=0x7f020000; public static final int a10=0x7f020001; public static final int a2=0x7f020002; public static final int a3=0x7f020003; public static final int a4=0x7f020004; public static final int a5=0x7f020005; public static final int a6=0x7f020006; public static final int a7=0x7f020007; public static final int a8=0x7f020008; public static final int a9=0x7f020009; so far, good... today tried make new version of app, using original amount of images -

html - Atom - Emmet package: closing comments -

emmet atom: auto comments after html closing tag. i can't seem find solution problem anywhere i've resorted asking on here. http://iaintnoextra.tumblr.com/post/68089741466/automatically-add-closing-comments-to-html-using in sublime text 3, using emmet user preferences file link above, emmet automatically adds comments after closing html tag; example: div.container would produce: <div class="container"></div><!-- /.container --> i can't seem find anywhere within emmet's package settings make happen on atom v1. know can change mimics same functionality? http://www.devstavern.com/emmet/custom-comments-in-emmet-sublime-atom-and-others/ with of link above managed figure out on own, here's answer: edit emmet settings on atom. update extensions path under "settings" heading location you'd save preferences.json file we'll create next, i've created folder in dropbox folder can access file loca

java - Jackson's @JsonView annotation does not work -

i annotated class user @jsonview , when returned see fields not contains in view class. here class @entity @table(name = "users") public class user implements serializable{ /** * */ private static final long serialversionuid = 1l; @id @column(name="id") @generatedvalue(strategy=generationtype.auto) private long userid; @jsonview(view.summary.class) @column(name="email") private string email; @jsonview(view.summary.class) @column(name="user_name") private string firstname; @jsonview(view.summary.class) @column(name="user_last_name") private string lastname; @jsonview(view.summary.class) @column(name="phone") private string phone; @jsonview(view.summary.class) @column(name="origin") private string address; @jsonview(view.summary.class) @column(name="birth_date") private long birthdate; @jsonview(view.summary.class) @column(name="gender") private long gender; @jsonview(view.summary.class) @

javascript - Android Cordova canvas app lags only for specific device running 2.3.6 Gingerbread when no touch events are being fired -

my app uses html5 canvas , uses cordova build .apk file. i have tested app on 5 devices running varying versions of android os , of varying hardware capabilities. 1 lagged samsung galaxy ace 2, running android 2.3.6 gingerbread. believe os issue because phones tested similar/worse hardware not lag. when screen touched , remains touched, lag reduced. noticed pixels seem smoothed or anti-aliased when screen not touched more pixelated when screen touched, believe causing lag. prefer less pretty no lag opposite. javascript not cause happen, , stuck on how resolve it. the following did not solve problem: context.imagesmoothingenabled = false; and using css image-rendering settings did not help. the javascript has touchstart, touchend , touchmove event listeners attempted hack way faking touchmove event if user not touching screen, although couldn't working , it's not elegant solution anyway. i have had problem weeks , want apps work on devices. does have sug

android - How to get lollipop status bar on kitkat -

Image
i'm trying achieve status bar primarydarkcolor , primarycolor lollipop on kitkat , here try: <style name="populartheme" parent="theme.appcompat.light.darkactionbar"> <item name="colorprimarydark">@color/colorprimarydarkpopular</item> <item name="colorprimary">@color/colorprimarypopular</item> <!--here i've added try transparency --> <item name="android:statusbarcolor">@android:color/transparent</item> <item name="android:windowactionbaroverlay">true</item> <item name="android:windowcontenttransitions">true</item> <item name="android:windowtranslucentnavigation">true</item> <item name="android:windowtranslucentstatus">true</item> </style> also, test method https://github.com/jgilfelt/systembartint won't choice because i'm using color each

If not applicable, ignore JavaScript function -

i have function changes element of markup don't have control over. has been working great, on pages - there no element of name. js compiled 1 file - , on pages no match, error: uncaught typeerror: cannot read property 'attributes' of undefined (function($) { $.fn.changeelementtype = function(newtype) { // create object store attributes var attrs = {}; // save out values object $.each(this[0].attributes, function(idx, attr) { attrs[attr.nodename] = attr.nodevalue; }); // replace element - , put original values this.replacewith(function() { return $("<" + newtype + "/>", attrs).append($(this).contents()); }); }; })(jquery); (for example, should list , not tons of divs) $('.list-view').changeelementtype('ul'); so instinct put if statement or if no match there - doesn't in way. - i'm not sure on direction take. i used

ruby on rails - Data not getting saved to database from the form -

class usercontroller has following code: def create @user = user.new(params[:user].permit(:userid,:password,:email)) render plain: params[:user].inspect+"||"+@user.inspect #@user.save #flash[:notice] = "you signed successfully" #redirect_to @user end the form has following code: ( @user or :user , doesn't matter, output same) <%= form_for :user, url:users_path |f| %> <%= f.label:userid %><%= f.text_field :userid %><br /> <%= f.label:password %><%= f.password_field :password %><br /> <%= f.label:email %><%= f.text_field :email %><br /> <br /> <%= f.submit %> <% end %> when fill form, output: {"userid"=>"viky", "password"=>"123456", "email"=>"aa"}||#<user id: nil, userid: nil, password: nil, email: nil, created_at: nil, updated_at: nil> as can see, userid , passwor

java - General consensus on using database ids in urls? -

this question has answer here: exposing database ids - security risk? 7 answers is using database ids in urls (e.g. example.com/users/35/details) acceptable practice or should avoided? more vulnerable security threats exposing it? exposing internal details, such ids, security risk. however, exposing detail low risk. if limiting actions possible user based on role, unlikely attacker can beyond user do. if attacker has angle allows them run script against database knowing ids based on urls not biggest problem. beyond security concerns may business concern, may not want let know approximately how many users in system. sequential ids way of finding out. in end though, in opinion, effort , performance hits come obscuring object ids not worth in cases. if have reason obscure means it. otherwise time , effort can spent better elsewhere.

dart - How to get a reference to a particular component in an Angular2 template -

i know angular2 has @viewquery querylist of components matching given type. there way reference particular component in querylist ? right now, way can think give component "id" field, iterate through querylist , check if identifier 1 want, e.g.: getcomponentbyid(querylist<hasidfield> querylist, string id) => querylist.singlewhere((component) => component.id == id); but seems common enough problem seems there should way without adding "id" boilerplate. know component can referenced locally within template using # , there way reference component within class? currently functionality not exist, see here details on why functionality implement custom filter on hold due potential performance reasons. so way doing seems right way given functionality available currently, might change framework in alpha.

objective c - Access workout data even when apple watch screen turn off -

i success heart rate data in live without workout session on apple watch os 2. when apple watch screen turn off, completion block not anymore called. continue manage these data in live , make phone ring when heart rate low. maybe can let app on iphone perma open , maybe can access healthkit data during workout ? think can work ? or have idea ? regards hey found solution : i keep iphone app in foreground : [uiapplication sharedapplication].idletimerdisabled = yes and same query apple watch (hkanchoredobjectquery) can access latest health kit data. live heart rate data when apple watch turn off (with workout session) my query hkquantitytype *type = [hkobjecttype quantitytypeforidentifier:hkquantitytypeidentifierheartrate]; hkanchoredobjectquery *heartratequery = [[hkanchoredobjectquery alloc] initwithtype:type predicate:nil anchor:self.anchor

node.js - How to convert mongodb date object in "mm/dd/yyyy" format in node -

i using jquery date picker in "mm/dd/yyyy" format , saving mongodb default date type. problem when fetch documents db date looks "2015-08-29t18:30:00.000z". want convert mm/dd/yyyy format can display in date field while editing record. below code: before returning document, want chnage dates in "mm/dd/yyy" format. var query = trips.findone({"_id":tripid},function (err, trip) { if (err) res.send(err); console.log(trip.tripenddate); res.json(trip); }); date.prototype.tolocaledatestring() need. d = new date() > sun aug 30 2015 22:47:48 gmt+0300 (msk) d.tolocaledatestring('en-us') > "8/30/2015"

Are Meteor template events lost if the template is relocated within the DOM? -

i have 2 lists appear adjacent each other on page. list items can dragged 1 list other, , vice-versa (using jquery.sortable). list item template, within button. click event button defined using template.my-button.events method. when page rendered, if click button in list item, events fire ok. if, however, drag list item adjacent list, events no longer fire. does know why and/or can suggest way circumvent issue? it possible jquery.sortable messes meteor events tracker. maybe not elegant way possible work-around add eventlistener through classic js in template.page.onrendered() . like: template.yourpage.onrendered(function() { document.getelementbyid("yourbuttonid").addeventlistener("click", function() { #your code }); })

Meteor: Spacebars not updating on session-value change -

i have html-file in meteor {{#if thevalue}} {{> one}} {{else}} {{> two}} {{/if}} and helper 'thevalue': session.get('thevalue') //returns true or false my problem when session-value changes, if/else-bracktes spacebars not change it. thought session-values reactive...but maybe have sort of misconception how works. try write helper function so 'thevalue': function () { return session.get('thevalue'); } see docs here more.

java - Soundpool not playing correctly -

i'm creating little game have audio samples drumkit set play when image-buttons touched. working on 1 device not 2 others i've tried on. there in code makes inconsistent across android devices? cannot find reason inconsistency... genius out there solution?? activity code public class gamemain extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.game_main); // initialise soundpool play drum sample sounds soundpooldrums = new soundpool (8, audiomanager.stream_music, 0); // create hashmap of sounds soundmap = new hashmap<integer, integer>(); } // constants , variables storing sounds drumkit public static final int hihat_sound_id=0; public static final int ride_sound_id=1; public static final int cymbal_sound_id=2; public static final int bass_sound_id=3; public static final int snare_sound_id=4; public static final int tomtoma_sound_i

javascript - Cytoscape.js partial layouter -

is there "real" partial layouting option in cytoscape.js? i've tried following suggested options : using arbor layouter , locking nodes don't want re-layout execute layouter on elements in graph using makelayout function , setting avoidoverlap option true on layouter supply option. in both cases layouter didn't take account existing nodes locked or not part of layouter nodes list led overlapping nodes in graph. note: (1) layout aware of elements in it. (2) locked nodes can not moved @ long they're locked. you can run layout on subset of graph, not take account other elements because of (1). can run layout on graph including locked nodes, not moved because of (2). it sounds don't result of arbor, should try better force layout, cose or cola. locking elements , running layout should work simple usecases. approach , others working fine in several of our projects cytoscape.js.

sails.js - heroku and sails app | crashes and timeouts -

i have basic sails app , running locally. when deploy heroku, cannot response app , "application error". receive "no data received". heroku logs 2015-08-30t22:06:50.949475+00:00 heroku[api]: release v22 created me 2015-08-30t22:08:57.324207+00:00 heroku[router]: at=error code=h20 desc="app boo t timeout" method=get path="/" host=www.ninjalist.io request_id=8e21f6eb-1a59-4e 31-9c40-00aab002d0f1 fwd="118.61.238.166" dyno= connect= service= status=503 bytes= 2015-08-30t22:08:52.058851+00:00 heroku[web.1]: state changed starting down 2015-08-30t22:11:55.735176+00:00 heroku[router]: at=error code=h10 desc="app cra shed" method=get path="/" host=ninjalist.herokuapp.com request_id=314047d1-97d8- 40ea-8596-4b21978eb581 fwd="108.61.228.166" dyno= connect= service= status=503 b heroku logs --source app 2015-08-30t21:40:42.149449+00:00 app[web.1]: > firstapp@0.0.1 start /app 2015-08-30t21:40:42.14945

java - findviewbyid always returns null with imageview -

i have been struggling evening, whatever reason imageviews return null! here java package com.example.christmascontroller; import android.os.bundle; import android.app.activity; import android.app.alertdialog; import android.app.dialog; import android.content.dialoginterface; import android.util.log; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.view.window; import android.widget.imageview; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { dialog dialog = new dialog(this, android.r.style.theme_translucent_notitlebar); dialog.requestwindowfeature(window.feature_no_title); super.oncreate(savedinstancestate); dialog.setcontentview(r.layout.activity_main); dialog.setcancelable(true); dialog.show(); imageview imgremote = (imageview) findviewbyid(r.id.control); imgremote.setclickable(t

PHP PDO left join not giving the same results as in mysql direct -

Image
i have 2 db tables this: mysql server: if execute following sql statement on mysql server directly all games usertogame entrys or null values if not existent. select g.*, ug.id_usertogame, ug.id_user, ug.nickname, ug.server games g left join usertogame ug on g.id_game=ug.id_game , ug.id_user=11 order g.id_game php pdo: but if run following pdo statement in php games usertogames entry exists (without null values, in normal join). first thougt pdo doesnt support left join found many exaples wich prove does. function getusergames($uid) { $stmt = self::$_db->prepare("select g.*, ug.id_usertogame, ug.id_user, ug.nickname, ug.server games g left join usertogame ug on g.id_game=ug.id_game , ug.id_user=:uid order g.id_game"); $stmt->bindparam(":uid", $uid); $stmt->execute(); return $stmt->fetchal

c++ - How to format doubles in the following way? -

i using c++ , format doubles in following obvious way. have tried playing 'fixed' , 'scientific' using stringstream, unable achieve desired output. double d = -5; // print "-5" double d = 1000000000; // print "1000000000" double d = 3.14; // print "3.14" double d = 0.00000000001; // print "0.00000000001" // floating point error acceptable: double d = 10000000000000001; // print "10000000000000000" as requested, here things i've tried: #include <iostream> #include <string> #include <sstream> #include <iomanip> using namespace std; string obvious_format_attempt1( double d ) { stringstream ss; ss.precision(15); ss << d; return ss.str(); } string obvious_format_attempt2( double d ) { stringstream ss; ss.precision(15); ss << fixed; ss << d; return ss.str(); } int main(int argc, char *argv[]) { cout << "attempt #1&qu

ios - How to set maximum length for UILabel? -

in objective-c , attempting set limit of character length uilabel , not find way anywhere. example, line of text entered uilabel , 100, if maximum character length set 50, want cut off @ 50 , not truncate. cut off once hits limit. i have tried this; didn't work: nsstring *string = my_uilabeltext; if ([string length] >74) { string = [string substringtoindex:74]; } any insight or appreciated. thank you based on comment, implemented work. have ensure syntax correct. assuming getting string database: nsstring *string = stringfromdatabase; //execute conditional if statement if (string.length > 50) { //meaning 51+ /* trim string. important note substringtoindex returns new string containing characters of receiver to, not including, 1 @ given index. in other words, goes 50, not 50, means have desired number + 1. additionally, method includes counting white-spaces */ string = [string substringtoindex:51]; } then must set

How can I extend a "normal" class with a static class in Python? -

i'm using python 3 , i'm trying rewrite graphics library wrote while ago. right now, have class called scene has 3 methods in addition constructor: logic(self) , update(self) , , render(self) . logic(self) handles logic of each scene . handles mouse , keyboard input, , figures out whether button clicked, et cetera. update(self) can thought of abstract method. contents raise notimplementederror . update(self) called number of times each second, , updates whatever going on in program, but not draw on screen . framerate-independent update. if pong made library, ball's position updated in method. render(self) updates screen. way, speed of program not determined framerate. i current implementation of scene . it's clean right now, , seems intuitive. however, can't on how extend scene . suppose want make scene basic gui main menu. want there only one main menu scene , because don't think it's idea recreate whole other scene every time main menu

iPython: DLL load failed: The specified module could not be found; plain Python fine -

i keep getting (well known) error in ipython. yet, same import works fine in plain python. (python 3.3.5, see details below) ipython: python 3.3.5 (v3.3.5:62cf4e77f785, mar 9 2014, 10:37:12) [msc v.1600 32 bit (intel)] type "copyright", "credits" or "license" more information. ipython 2.0.0 -- enhanced interactive python. ? -> introduction , overview of ipython's features. %quickref -> quick reference. -> python's own system. object? -> details 'object', use 'object??' details. in [1]: import test1 --------------------------------------------------------------------------- importerror traceback (most recent call last) <ipython-input-7-ddb30f03c287> in <module>() ----> 1 import test1 importerror: dll load failed: specified module not found. python (not loads fine, works): $ python python 3.3.5 (v3.3.5:62cf4e77f785, mar 9 2014, 10:37:12) [msc v.160

Remove duplicate using regex jquery -

i've below text in file. 10 - black 10 - black 10 - black 10 - black 10 - black 20 - grey/black 20 - grey/black 20 - grey/black 20 - grey/black 20 - grey/black 30 - blue 30 - blue 30 - blue 30 - blue 30 - blue 40 - brown/red 40 - brown/red 40 - brown/red 40 - brown/red 40 - brown/red here want replace following duplicates, remain letter below is. in simple want output below. 10 - black 20 - grey/black 30 - blue 40 - brown/red here's regex code: (\b[^\n,]+)\n(?=.*\b\1\b) regex101: https://regex101.com/r/wf0ag1/1 edit 1 try regex: ([^\n].*)\n(?:\1(?:\n|$))* and substitution: $1\n\n\n demo

ios - Parse Facebook Login Crash -

Image
i getting crash in ios project when calling logininbackgroundwithreadpermissions . here complete code. let permissions = ["public_profile", "email", "user_friends"] pffacebookutils.logininbackgroundwithreadpermissions(permissions, block: { (user: pfuser?, error: nserror?) -> void in }) the app crashes. here stack trace. i using parse latest sdk 1.8.1 in ios project. facebook sdk 4.5.1 anyone facing same issue?

java - How to use regular expressions to add delimiters? -

hi have sample log file here: jan 1 22:54:17 drop %logsource% >eth1 rule: 7; rule_uid: {c1336766-9489-4049-9817-50584d83a245}; jan 1 22:54:22 drop %logsource% >eth1 rule: 7; rule_uid: {c1336766-9489-4049-9817-50584d83a245}; jan 1 22:54:23 drop %logsource% >eth1 rule: 7; rule_uid: {c1336766-9489-4049-9817-50584d83a245}; jan 1 22:54:41 drop %logsource% >eth1 rule: 7; rule_uid: {c1336766-9489-4049-9817-50584d83a245}; the default delimiter semi-colon(;) , want separate timestamp , "drop", "drop" "%logsource%" delimiter. didnt expected result. whole code insert delimiter.) main idea add log file arraylist string(which can use regular expressions according current knowledge of java) , add delimiters accordingly. the error shown below: exception in thread "main" java.lang.runtimeexception: uncompilable source code - erroneous tree type: @ testing.testing.main(testing.java:31) starts line liststring.replaceall("r

java - Merge arrylists and save as arraylist with in arraylist -

i have 3 array list , want merge array list 1 arraylist like, merge first object of arraylist 1 arraylist , put arraylist first object of new arraylist merge second object of arraylist 1 arraylist , put arraylist second object of new arraylist need output there possibility this what asking transpose function. here example using iterator , can handle number of lists, , each list can different size. list<list<integer>> input = arrays.aslist(arrays.aslist(1,2,3,4), arrays.aslist(5,6,7), arrays.aslist(8,9,10,11,12)); iterator<integer>[] iters = new iterator[input.size()]; int = 0; (list<integer> list : input) iters[i++] = list.iterator(); list<list<integer>> output = new arraylist<>(); while (true) { list<integer> sublist = new arraylist<>(iters.length); (iterator<integer> iter : iters) if (iter.hasnext())

android - Test for keepScreenOn attribute -

given have simple android activity following view code: <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:ignore="mergerootframe" android:keepscreenon="true"> <!-- more views --> </framelayout> then: how can test activity keep it's screen on , prevents tablet sleep? sidenote: if set flag_keep_screen_on flag in activity (oncreate) this: @override protected void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on); } then can read via robolectric this: public static int getwindowflags(final activity activity) throws exception { class clazz = class.forname(window.c

sql - Inner join does not output id column -

i have query joins of different tables select cust_name, order_no, order_status, pay_method, pro_name, cust_city customers inner join orders on customers.cust_id = orders.cust_id inner join pro_orders on pro_orders.order_id = orders.order_id inner join products on products.pro_id = pro_orders.pro_id order customers.cust_name asc i trying output order_id orders table & customer_id customer table id column related other table relation not output try below select c.cust_id, c.cust_name,order_no,order_status,pay_method,pro_name,cust_city customers c inner join orders o on c.cust_id = o.cust_id inner join pro_orders po on po.order_id = o.order_id inner join products pr on po.pro_id = pr.pro_id order c.cust_name asc it because cust_id column in both customers , order table. sql doesn't know table's cust_id should printed. also 1 of best practices create aliases , use aliases in query. makes query m

ios - Git Ignored File When GitIgnore Doesn't Exist -

i have ios project on xcode. i've been working off of branch time. i've made particular changes file , have been committing branch time. when moved old branch, merged code, , deleted recent branch, realized file never updated git. don't have .gitignore file. all other files pushed except particular set of header , main objective-c files. have no idea why code never pushed up. i've spent quite bit of time working on , losing updated file great blow me. when moved older commit deleted branch file took original form. what have caused , there wy me fix this? update this not first rodeo git. let me further explain. every commit i've made i've used git add . , followed git commit , git push respectfully. i've attempted pull branch remote repository file not reflect of changes i've made of recent commit. you second question - how code had on file deleted. here's how - create new branch - git checkout -b newbranch perform

javascript - PHP get contents of a div, and echo the div contents in same page -

hello , thank help. i'd similar website. simply loading of page, in php, take content of div. and display anywhere on page. store in variable $texte1 contents of the div id texte-1 <?php $texte1 = get_contents_div('text-1'); ?> and put content of div in page <?php echo ($texte1);?> tank friends sorry bad english this how can in javascript: <script> (function(){ var divcontent= document.getelementbyid("text-1").html(); //get div content document.getelementsbytagname("body").append(divcontent); //add body })(); </script>

python - Parsing CSV to list of tuples without using CSV module -

i'm working on assignment in python class @ moment, , 1 particular part asking me import csv file (with data in format of "text, number, number, ..., number, number") without use of csv module (or modules @ all, in fact), , return data list of tuples, in format: [(’text’, [number, number, ..., number, number]), (’text’, [number, number, ..., number, number]), .....] i think i've got actual process of opening file , beginning read line line correct (see snippet below), i'm not quite sure on how proceed regards parsing each line format needed. def load_data(filename): open(filename) line in filename i've tried searching can seem find says use csv module (which isn't particularly helpful because we're not allowed import modules bar math library) or has data being input and/or output in different format. if give me pointers should doing or can start super helpful. thanks! edit: per suggestion made @dotancohen here sample data: slow

javascript - Replacing string around a number -

i have text file in want following replacements: "type": "sql.nvarchar(100)", with "type": sql.nvarchar(100), the number inside nvarchar can anything . can complete following regex number remains such: schema = schema.replace(/"sql\.nvarchar(/g, 'sql.nvarchar('); // incomplete you can use capturing group capture number, , use in replacement string. schema = schema.replace(/"sql\.nvarchar\((\d+)\)"/g, 'sql.nvarchar($1)'); // ^^^^^^^^^ ^^ in regular expression, \d+ inside parentheses captured , used in replacement.

R: Set loop index from within the loop -

i want set loop run 1 10. within loop want change index skip iterations 6 , 7, , complete loop iterations 8, 9 , 10. for (i in 1:10) { print(i) if (i == 5) { <- 8 print(i) } } [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 [1] 5 [1] 8 [1] 6 [1] 7 [1] 8 [1] 9 [1] 10 clearly, i after line 1 <- 8 set function for 6. there way prevent this? as you're talking skipping, best idea use next on values wish skip: for (i in 1:10) { if (i %in% c(6,7)) { next } print(i) } quote help("for") : next halts processing of current iteration , advances looping index. another option restrict ranges looping on this: for(i in c(1:5,8:10)) { print(i) }

python - Getting certain information from string -

i'm new python wondering how estimatedwait , routename string. { "lastupdated": "07:52", "filterout": [], "arrivals": [ { "routeid": "b16", "routename": "b16", "destination": "kidbrooke", "estimatedwait": "due", "scheduledtime": "06: 53", "isrealtime": true, "iscancelled": false }, { "routeid":"b13", "routename":"b13", "destination":"new eltham", "estimatedwait":"29 min", "scheduledtime":"07:38", "isrealtime":true, "iscancelled":false } ], "servicedisruptions":{ "infomessages":[], "importantmessages":[], "criticalmessages":[] } } and sa

How to create an alarm wake screen in android and disable default back button? -

hello every 1 request please give me solution of question . have created alarm wake screen when alarm started has 2 buttons snooze , dismiss , work fine . problem started when user press button on phone disappears screen , sound still playing. if have solution please provide me. thank you this alarmservice class import android.app.service; import android.content.intent; import android.os.ibinder; public class alarmservice extends service { public static string tag = alarmservice.class.getsimplename(); @override public ibinder onbind(intent intent) { return null; } @override public int onstartcommand(intent intent, int flags, int startid) { intent alarmintent = new intent(getbasecontext(), alarmscreen.class); alarmintent.addflags(intent.flag_activity_new_task); try{ alarmintent.putextras(intent); getapplication().startactivity(alarmintent); alarmmanagerhelper.setalarms(this); }catc

objective c - Buttons in Cell not clickable IOS 9 -

uitableviewcell few buttons on it, on ios 8.4 buttons clickable (able tap event), in ios 9 unable tap event. did 1 notice this? ok found solution this, think bug @ past @ ios 6.. way should add uitableviewcell: self.contentview.userinteractionenabled = no; but because i've added views cell itself, instead of i'ts contentview.

github - Lost commits made to git on switching branch -

i have started using git , not aware of may basic functionalities of it. cloned forked repo on machine , started making changes repo without taking note of branch using. assumed must default. committed change , selected current branch master github ui interface on osx. when see repo, don't see of changes in it. instead recent commits original authors of repo. ps. had not published committed changes git reflog need. shows log of local "ref" changes.