Posts

Showing posts from April, 2011

algorithm - Fan out in B+ trees -

how fan out affects split , merge in b+ trees? if have 1024 bytes page , 8 byte key, , maybe 8 byte pointer, can store around 64 keys in 1 page. considering 1 page node, if have fan out of 80%, mean split happen after node 80% full after 52 keys inserted or after node overflows. same merge, when merge nodes if have 80% fan out, when keys go less half size of node or 80% has it. splits , merges in b-trees of kinds driven policies based on fullness criteria. best think fullness in terms of node space utilisation instead of key counts; fixed-size structures - space utilisation measured in terms of key counts , equivalent fanout - tend occur in academia , special contexts in-memory b-trees on integers or hashes. in practice there variable-size elements involved, beginning variable-size keys subject further size variation via things prefix/suffix truncation , compression. splits invariably occur when update operation result in overflowed node. difference between polici...

Drupal exposed filter not displaying children -

Image
please refer image when select child category shows "searchfilter?field_category_tid=5" but when select parent shows nothing "searchfilter?field_category_tid=4" i know can solved creating contextual filters or sort of relationship setting. have no idea how it. try using grouped filters. when configuring field in filter type expose chose grouped filters then can enter parent name , children filtered. can enter child name , 1 field (the child ) filtered.

oauth - Java OAuth2 Provider Implementation | Custom Errors -

i have searched high , low answer question , i'm reaching out community. i'm trying build oauth2 access token endpoint in java. i'll implementing resource owner credentials grant type return access token. (specifying end-user's username/password access token) during authentication of user credentials, number of rules prevent user having access web service, such user account being locked. the oauth2 rfc says errors must returned follows: { "error":"invalid_request", "error_description":"description", "error_uri":"some_link" } it's understanding oauth spec lists standard error codes , should avoid custom error codes in response, {"error":"account_locked"} ; however, i've seen api providers this. i need clients of api able read error code in response know when account locked. (or other specific scenarios) now questions are: does here have experience suggest how should s...

Python constraints (error) message -

Image
i have written function below in python. works if user selects holiday start-date , holiday end-date time correctly accepts, else show error message 'error: entered invalid date or time' shown in fig python code: def _date_start_end_validate(self, cr, uid, ids, context=none): sr_ids = self.search(cr, 1 ,[], context=context) self_obj in self.browse(cr, uid, ids, context=context): if self_obj.date_start >= self_obj.date_end: return false return true _constraints = [(_date_start_end_validate, 'error: entered invalid date or time', ['dates'])] i need display start-date showing error here, date should displayed. how start-date information in constraints. try below code may use full. def _date_start_end_validate(self, cr, uid, ids, context=none): sr_ids = self.search(cr, 1 ,[], context=context) self_obj in self.browse(cr, uid, ids, context=context): if self_obj.date_start >= self...

c# - Gridview selected row returning null -

i have gridview contains linkbutton below cod in aspx file: <asp:templatefield> <itemtemplate> <asp:linkbutton id="button3" style="float: left; margin-left: 10px" commandargument='<%# bind("id") %>' text="cancellation" runat="server" commandname="cancell" onclick="button3_click"> <i aria-hidden="true" class="icon-lock" title="cancellation"></i> </asp:linkbutton> </itemtemplate> </asp:templatefield> i want when user click on link button update database table when want value of cell gridview selected row face null refrence exception in line: string barcode = dgvdata.selectedrow.cells[12].text;. protected void button3_click(object sender, eventargs e) { transaction tr = new transaction(); hasinreservation.entities.db.transaction dt = new transa...

javascript - Alert msg box display blank page behind -

i displaying message box @ client browser. works fine see blank page @ when alert message box pops up. want user see browsing page , pop message box. here code.` if($_post['submit']=="save") { $language=$_post['pbx_lan']; if($language!="") { $query="update `account_detail` set `prompt_language`= '$language' `org_id`='".$_session['account_id']."'"; $result = $mysqli->query($query) or die($mysqli->error); $_session['check_update'] = "1"; // setcookie("msg","language updated",time()+5,"/"); echo '<script> confirm("you have selected '.$language.'"); window.location = "'.site_url.'index.php?view=pbx_prompts." </script>'; // header("location:".site_url."index.php?view=view_service"); } else { setcookie("err","no l...

Embed Android dependencies in to Android library -

i create android self-consistent library, has inside external dependencies (like retrofit). want use in main project without having re-import library dependencies. possibile? this library build.gradle: apply plugin: 'com.android.library' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { applicationid "my.lib" minsdkversion 8 targetsdkversion 21 versioncode 4 versionname "0.4.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'),'proguard-rules.pro' } } } dependencies { compile 'com.squareup.retrofit:retrofit:1.8.0' } this app build.gradle: apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { applicationid "my.app" ...

android - App cannot be launched, but seems to have installed -

i changed manifest of app, , app cannot launched. no icon. however, when check installed under setting application manager, see there! whats going on??? have used same permissions before. changed app main , launcher. cannot see app. not come via studio or show in apps device!!!! update: created new app same permissions , launches ok, not seem permissions ... installing com.mycomp.myapp device shell command: pm install -r "/data/local/tmp/com.mycomp.myapp" pkg: /data/local/tmp/com.myapp. success 09-21 13:40:43.261 454-499/? w/packagemanager﹕ verifying app can installed or not 09-21 13:40:49.171 454-499/? w/packagemanager﹕ unknown permission android.permission.update_device_state in package com.mycomp.myapp 09-21 13:40:49.171 454-499/? w/packagemanager﹕ not granting permission android.permission.package_usage_stats package com.mycomp.myapp (protectionlevel=18 flags=0x18be46) <?xml version="1.0" encoding="utf-8"?...

Crystal build fails with linker error -

i've tried run simple http server language documentation. program fails error. /usr/bin/ld: cannot find -lssl collect2: error: ld returned 1 exit status error: execution of command failed code: 1: `cc -o "/home/rasmus/dev/crystal/projects/hello/.crystal/crystal-run-hello.tmp" "${@}" -rdynamic -lssl -levent -lrt -lpcl -lpcre -lgc -lpthread -ldl` the program has been copy-pasted the documentation . i can confirm program did/does run on guest machine, not on host. both ubuntu 14.04.3 installs. the problem ssl libraries weren't installed. if have same problem can simple run sudo apt-get install libssl-dev . should install needed fix error.

centos - Linux,How to show absolute path in shell promt? -

Image
now shell shows short path this i want show full absolute path in front.like how change it? append ps1 variable \w , store in e.g .bash_profile an example export ps1="\u@\h \w> " where \u – username \h – hostname \w – current working directory, full path (ie: /data/temp) check out following tutorial more options.

android - Pass data to previous fragment -

i have 2 fragments , b. going fragment fragment b using following method. getactivity().getsupportfragmentmanager().begintransaction().replace(r.id.content_frame, new b()).addtobackstack(tag).commit(); now want send data fragment b fragment i.e previous fragment. can please give me idea how send data previous fragment. thanks check documentation fragments , communication. do want pass info 1 fragment another? 1 fragment shouldn't know other fragments. make fragment b communicate activity through interface , make activity pass data fragment a

javascript - I can't do a regular expression -

i have variable: física in mongodb , have model attribute name educación física . i make regular expression passing variable física not return me educación física if database had model name fisica or fisica or something, give yes. i using nodejs , mongodb , javascript ... sorry english , thank much. the things need are: anchors : ^ means "beginning of input" , $ means "end of input" case insensitivity : i flag means "ignore whether things capitalized or not" so: var rex = /^fisica$/i; // ^ ^ ^ // | | +------ flag (ignore case) // +------+-------- anchors example: if (rex.test(somestring)) { // matches... } re comment below: how can put fisica variable? because fisica example, variable sends frontend backend for that, you'd need regular expression constructor, regexp : var rex = new regexp("^" + yourvariable + "$", "i"); if there ch...

javascript - Multiple Facebook Custom Audience Tracking Events on the same page -

i have single page website , trying invoke multiple events same facebook custom pixel here. using facebook pixel helper on chrome test. here scenario: this how javascript file looks: (function() { var _fbq = window._fbq || (window._fbq = []); if (!_fbq.loaded) { var fbds = document.createelement('script'); fbds.async = true; fbds.src = '//connect.facebook.net/en_us/fbds.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(fbds, s); _fbq.loaded = true; } _fbq.push(['addpixelid', '1634281670122256']); })(); window._fbq = window._fbq || []; window._fbq.push(['track', 'pixelinitialized', {}]); function trackfbeventdownloadbrochure() { window._fbq.push(['track', 'viewcontent', {content_name: 'brochure-pdf'}]); } function trackfbeventdownloadtsaway() { window._fbq.push(['track', 'viewcontent', {content_name: 'tsa-way-pdf'}]); } it inclu...

python - can't delete a file after no space left on device -

i'm writing bunch of files on several hard disks. files don't fit on single hard drive write on next 1 if first 1 out of space. catch ioerror 28 figure out. my exact problem when try remove last file written (incomplete file) first disk new exception don't understand. seems with-block can't close file because there no space left on disk. i'm on windows , disks formatted ntfs. could please me. # here's sample code # recommend first fill disk full large dummy file. # on windows create dummy file # 'fsutil file createnew large.txt 1000067000000' import os import errno fill = 'j:/fill.txt' try: open(fill, 'wb') f: while true: n = f.write(b"\0") except ioerror e: if e.errno == errno.enospc: os.remove(fill) here's traceback: traceback (most recent call last): file "nospacelef.py", line 8, in <module> n = f.write(b"\0") ioerror: [errno 28] no sp...

mysql - Should i stock "quotation_request" as a table on my DB? -

Image
i'm working on simple db. imagine i've table customer , table seller. the customer able request quotation products there simple form allow customers select products , submit quotation. now, should create table : "quotation" , store quotations (with id_quotation..etc)? thank all without knowing of business rules govern requirements of database, perhaps following design answer question , explain few concepts in process. in database terms, entity person, place, or thing want collect , store data. description can see 2 entities: seller , customer. important since entities identify conceptually become database tables in own right. the seller table should contain data applicable sellers. thus, qualities (attributes) sellers want store become columns in our seller table. each row (record) in seller table represents individual seller. each individual seller uniquely identified in seller table unique value stored in it's primary key column, c...

sql - Comparing a Date column with a datetime value -

i have found below query in 1 our stored procedures select *from table1 (convert(date,dateto) between @wkstdate , @wkenddate)) since usage of functions in where clause may hinder performance have changed below, select *from table1 dateto between @wkstdate , @wkenddate the result same after changing codes. not sure whether both give same result in time. scenarios above codes bring different results? (p.s: @wkstdate , @wkenddate date values & dateto datetime value) appreciate suggestions this not yield same result. let's dateto , datetime value, has time component: '2015-09-21 01:00:00' your @wkenddate '2015-09-21' . where dateto between @wkstdate , @wkenddate not retrieve above row since '2015-09-21 01:00:00' > @wkenddate . for more example: create table tbl(dateto datetime) insert tbl select cast('2015-09-21 00:00:00.000' datetime) union select cast('2015-09-21 16:10:49.047' ...

java - get total hours from two timepicker -

can tell me how can total hours 2 timepicker ?it possible since 2 timepicker getting same function. workdetails.java edittext timein = (edittext) findviewbyid(r.id.edittext6); edittext timeout = (edittext) findviewbyid(r.id.edittext7); timein.setonfocuschangelistener(new view.onfocuschangelistener() { @override public void onfocuschange(view v, boolean hasfocus) { if (hasfocus) { timepick time = new timepick(v); fragmenttransaction ft = getfragmentmanager().begintransaction(); time.show(ft, "timepicker"); } } }); timeout.setonfocuschangelistener(new view.onfocuschangelistener(){ @override public void onfocuschange(view v,boolean hasfocus) { if (hasfocus) { timepick time = new timepick(v); fragmenttransaction ft = getfragme...

Copy & Paste Using Drag and Drop With MS VB? -

i'm looking copy , paste windows form. i'm writing program in microsoft visual basic. i'm stuck. can't seem copy files have been dragged windows form. i'm asking help, started 3 months ago ms vb. if using vb6 then you can retrieve file names data.files() object private sub form_oledragdrop(data dataobject, effect long, button integer, shift integer, x single, y single) dim fname each fname in data.files '... next end sub don't forget set oledropmode property of form manual (1)

R - creating dataframe from colMeans function -

i've been trying create dataframe original dataframe, rows in new dataframe represent mean of every 20 rows of old dataframe. discovered function called colmeans, job pretty well, problem, still persists how change vector of results dataframe, can further analysed. my code colmeans: (matrix1 in original dataframe converted matrix, way managed work) a<-colmeans(matrix(matrix1, nrow=20)); but here numeric sequence, has results concatenated in 1 single column(if try example as.data.frame(a)). how supposed result dataframe each column includes results specific column name , not averages. i hope question clear, help. based on methods('as.data.frame') , as.data.frame.list option convert each element of vector columns of data.frame as.data.frame.list(a) data m1 <- matrix(1:20, ncol=4, dimnames=list(null, paste0('v', 1:4))) <- colmeans(m1)

Undestanding double bracket operation in Javascript -

what [1,2,3][1,2] means in javascript? not understand supposed do, , have no clue how google such thing. any ideas? i assume quite newbie question, please forgive ignorance. [1,2,3] array literal <obj>[p] bracket notation property access 1, 2 comma operator expression evaluates 2 so [1,2,3][1,2] whole accesses index 2 of array, , yields 3 .

forecasting - forecast with R -

Image
i have daily data of dengue index january 2010 july 2015: date dengue_index 1/1/2010 0.169194109 1/2/2010 0.172350434 1/3/2010 0.174939783 1/4/2010 0.176244642 1/5/2010 0.176658068 1/6/2010 0.177815751 1/7/2010 0.17893075 1/8/2010 0.1813232 1/9/2010 0.182199531 1/10/2010 0.185091158 1/11/2010 0.185267748 1/12/2010 0.185894524 1/13/2010 0.18511499 1/14/2010 0.188080728 1/15/2010 0.190019472 … … 7/20/2015 0.112748885 7/21/2015 0.113246022 7/22/2015 0.111755091 7/23/2015 0.112164176 7/24/2015 0.11429011 7/25/2015 0.113951836 7/26/2015 0.11319131 7/27/2015 0.112918734 i want predict values until end of 2016 using r. library(forecast) setwd("...") dengue_series <- read.csv(file="r_wikipedia-googletrends-model.csv",head=true,sep=";") dengue_index <- ts(dengue_series$dengue_index, frequency=7) plot(dengue_index) # lambda=0 -> predict positive values fit <- auto.arima(dengue_index, l...

javascript - How to display product unit of measurement on frontend (website) in Magento? -

i want display products unit of measurement @ frontend. have created weight_unit attribute in admin panel , adding products gram, kilogram, liter, etc. can't show @ frontend. use following code display @ frontend: <?php echo $_product->getattributetext('weight_unit'); ?> still not getting proper show of product unit. please can suggest me how show it? there other methods represent product unit? you can use translation method achieve this. can find out in following link. https://magento.stackexchange.com/questions/6924/custom-attribute-ending in post, translation method , translation csv files used achieve this. can write unit of measurement in csv file , use attribute code in translation method.

android - Prevent CollapsingToolbar continuing under status bar in Lollipop -

i have developed custom behaviours textview changes position , size based on height of appbarlayout inside coordinatorlayout . title appears large , in centre of expanded toolbar when open, in normal title position when toolbar collapsed. take @ videos see on lollipop device (not working correctly) , jellybean device (working fine). the issue occurs (i believe, based on tests) on lollipop devices only, , seems linked fact status bar overlay on lollipop device, not on jellybean one. reflected in code well, calculate final y positions need following final position correct: if (mfinalyposition == 0) { mfinalyposition = (build.version.sdk_int >= build.version_codes.lollipop) ? (((mcontext.getresources().getdimensionpixeloffset(r.dimen.abc_action_bar_default_height_material)/2)) + getstatusbarheight()) : ((mcontext.getresources().getdimensionpixeloffset(r.dimen.abc_action_bar_default_height_material)/2)); } the best solution me if have lollipop...

php - Protected Directory existence and creating custom validator in Yii2 -

i searching password strength meter yii2. found this article yii1. saw protected directory mention there. i'm unable find folder. available in basic application template or advanced application template? there no protected directory in yii2 (neither in basic nor in advanced application template). where place custom validator - it's you. i'd recommend components/validators folder. here the part of official guide covering custom validation yii2. also take @ this extension , maybe covers needs, don't have reinvent wheel.

php - If/else statement inside the same div tag (formatting) -

absolute beginner here, bare me :) i'm trying formatting of php , html in same document right. can't seem conversion right. .... this original html: <div class="content-holder clearfix"> <div class="container"> <div class="row"> <div class="span12"> <div class="row"> <div id="title-header" class="span12"> <div class="page-header"> <?php get_template_part("static/static-title"); ?> </div> </div> <div class="row"> <?php if ($masonrycategory=='false') { ?> <div class="span8 <?php if (of_get_option('blog_sidebar_pos')==''){echo 'right';}else{echo of_get_option('blog_sidebar_pos'); } ?>"...

jquery - Pagination stops after JQGrid Reload and setting custom page number? -

i new jqgrid , problem jqgrid pagination stops after grid reload. highlighting selected row , maintaining grid page based on given id. for eg : if select row id 45 on page 4 of jqgrid , page redirected again , selecting same highlighted row , maintaining page 4 . problem when click pager-previous button goes page 3 not page 2, page 1. same case pager-forward button, goes page 5 not further. my jqgrid code below- function bindgroupgrid() { $("#grouplistgrid").armcustomgrid( { url: '../masterdata/getallgroup', sortname: 'groupname', sortorder: 'asc', colnames: ['id', 'entity type', 'group name', 'group description', 'is company', 'edit'], colmodel: [ { name: 'id', key: true, hidden: true }, { name: 'entityname', width: 100, align: 'left', index: 'entityname', searchoptions: { sopt: [...

Eclipse code formatter multiline function call closing bracket indention -

currently eclipse formatter formats multiline function call this: someobject.dosomething( some().long().chain().of().methods() ); but want eclipse align closing bracket method call: someobject.dosomething( some().long().chain().of().methods() ); i have tried playing around new line , wrapping rules in code formatter haven't been able achieve this. solution? after time of digging found similar question has accepted answer seems not answer same question: can eclipse formatter configured indent multiple lines between parenthesis properly? the author of question states: edit: found settings "line wrapping" -> "default indentation wrapped lines" , "default indentation array initializes" , have set them "1" instead of "0". better array initializers, but still doesn't indent closing parethesis match opening parenthesis way want to :

One servlet with multiple jsp's -

is possible if have 1 function in servlet forward getrequestdispacher 4 jsp. possible? from javadoc, requestdispatcher defines object receives requests client , sends them resource (such servlet, html file, or jsp file) on server. its clear at time can send 1 resource . refer documentation of requestdispatcher.

php - Could not connect to a specific host -

i trying contents of http://betsbc.com . nothing this: curl, wget, file_get_contents , ruby's file.open , python's urllib2.urlopen . nothing. can open browser successfully. ve tried in cloud9 , hosting. what doing wrong? thanks in advance curl seems work me. it returns html page structure no content, i'd guess it's generated in javascript. you may have connectivity limitations are, preventing access website. here can see content returned: pastebin.com/8jype9b1 $ curl http://betsbc.com <html><head><title>betcity - ▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒</title> <meta name="keywords" content="betcity,▒▒▒▒▒▒▒,▒▒▒▒▒▒▒▒▒▒▒▒,▒▒▒▒▒▒▒▒,▒▒,▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒,▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒,▒▒▒▒▒▒,▒▒▒▒▒,▒▒▒▒▒▒▒▒▒▒,live ▒▒▒▒▒▒▒▒▒▒,live ▒▒▒▒▒▒,▒▒▒▒▒▒▒▒▒,▒▒▒▒▒▒,▒▒▒▒▒▒,▒▒▒▒▒▒,on-line,sports,soccer,hockey,basketball,tennis"> <meta name="page-topic" content="sports"><meta name="description" content=...

jackson - Collection Wrapper as JSON List? -

i need wrap list<something> in dto (say, wrapper ) custom annotations work expected. end this: public class wrapper { private list<something> list; @customannotationshere public list<something> getlist() { ... } public void setlist(list<something> list) { ... } } however, makes jackson serialize/deserialize wrapper object as { "list": [...] } which, imho, verbose , unnecessarily complex. there way have jackson serialize/deserialize wrapper object list (the value of list field)? i swear once came across annotation-based way of achieving this, @ moment can't recall where. add @jsonvalue field serialization, , single-argument constructor deserialization?

java - Connect Multiple Device using NsdManager -

i have working on android , need little bit socket programing in application.i want create own network using nsdmanager.i succefully register service in network , done connection other device.i have transfer data between devices. problem everthing working fine transfer message between 2 devices problem occur while connect more 2 device. requirement i want connect more 2 device , share data in connected device. brief description of code here have 2 class chatconnection , nsdhalper. chatconnection transfer data between 2 device , nsdhalper provice utility of nsdmanger. first register service in network. public void registerservice(int port) { nsdserviceinfo serviceinfo = new nsdserviceinfo(); serviceinfo.setport(port); serviceinfo.setservicename(mservicename); serviceinfo.setservicetype(service_type); mnsdmanager.registerservice( serviceinfo, nsdmanager.protocol_dns_sd, mregistrationlistener); } than discover service public...

How do you show line numbers in R Sweave chunk outputs? -

i writing document in sweave , echo r code chunks in final pdf with code lines. however, cannot seem find line numbers chunk option. know how include code lines in chunk echos? for example, how can following chunk include 2 line numbers (1 , 2) when chunk echo'd pdf? <<echo = t, eval = t>>= amount <- 5 5 * amount @

javascript - Responsive menu won't close -

i have problems responsive menu. can't go again when click on link. have used ajax , jquery make menu sites stay on front page, can't figure out wrong? the site can seen here: www.sverkel.dk/m_index.php html: <!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/menu.css"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>untitled document</title> </head> <body> <div> <center><img src="http://oi60.tinypic.com/2ykaurc.jpg"></center> </div> <div class="handle"><img src="http://oi58.tinypic.com/mn0w95.jpg"></div> <nav> <ul id="nav"> <li><a href="index">forside<...

database - Display BLOB object in Java web project avoiding persistent cross site scripting? -

how display data stored blob object in java web project , avoid persistent cross site scripting vulnerability? the method respond() in viewdeliveredreportspage.java sends un-validated data web browser on line 2775 , can result in browser executing malicious code. 2773 byte[] barray = new byte[bytelen]; 2774 barray = blob.getbytes(1,bytelen); 2775 httpresponse.getoutputstream().write(barray); 2776 } catch (sqlexception e) { 2777 logger.error("error onselectionchanged before pass data displayed, need escape it. owasp esapi library seems choice. can find here: https://code.google.com/p/owasp-esapi-java/downloads/list byte[] barray = new byte[bytelen]; barray = blob.getbytes(1,bytelen); //you'll have convert string first - not //familiar java, principal same. string output = esapi.encoder().encodeforhtml(barray); httpresponse.getoutputstream().write(output); } catch (sqlexception e) { logger.error("error onselectionchanged it's worth reading cheat ...

angularjs - Data Binding is not working with Ionic Cards -

alright, have html page contains ionic card when bind data items not shown @ browser problem <ion-view title="game" ng-controller="gamectrl vm"> <ion-content class="has-header"> <div class="card"> <div class="item"> home team </div> <div class="item"> {{vm.game.team1}} </div> <div class="item"> score: {{vm.game.team1score}} </div> </div> <div class="card"> </div> <div class="card"> </div> </ion-content> </ion-view> and here angular controller page : (function () { 'use strict'; angular.module('eliteapp').controller('gamectrl', ['$stateparams','eliteapi', gamectrl]); fun...

Distributing set of python files as a single executable -

i have python script, distributed across several files, within single directory. distribute single executable file (for linux systems, mainly), such file can moved around , copied easily. i've come far renaming main file __main__.py , , zipping myscript.zip , can run python myscript.zip . that's 1 step short. want run ./myscript , without creating alias or wrapper script. is possible @ all? what's best way? thought maybe zip file embedded in (ba)sh script, passes python (but without creating temporary file, if possible). edit: after having go @ setuptools (i had not managed make work before), create sort of self-contained script, " eggsecutable script ". trick in case cannot have main module named __main__.py . there still couple of issues: resulting script cannot renamed , still creates __pycache__ directory when run. solved these modifying shell-script code @ beginning of file, , adding -b flag python command there. edit (2): not easy either, work...

objective c - Error saving data in Core Data (IOS) -

my program receives json data web service. next, program stores data in database using core data. if call save data after adding each entry, works, slowly. keeping 200 entries takes more 1 minute. if execute saving once @ end – program throw exception. - (void) onloadmessages:(nsobject*)object { nsarray *messages = (nsarray*)object; if (messages==nil) { [self onerror:@"message array null"]; return; } nsdate *date = [nsdate date]; long = [date timeintervalsince1970]; boolean update = false; for(int i=0; i<messages.count; i++) { nsdictionary *m = messages[i]; message *msg = [[message alloc]initwithdictionary:m]; if ([self updatemessage:msg updatetime:now]) update = true; } if (update) { nserror *error = nil; // error throw here if (![self.managedobjectcontext save:&error]) [self onerror2:error]; }...

swift - Xcode 7.0 The launch image set "LaunchImage" has 2 unassigned children -

i updated xcode 7.0 , fixed of bugs, keep getting error message:the launch image set "launchimage" has 2 unassigned children. deleted 2 unassigned children , still getting error message. try deep clean xcode (command+alt+shift+k)

google chrome - xpath - join/concat child node siblings text -

i searched , found reference accepted answer did not solve issue. have simple html dom is: <div class="name-hg"> <h2 class="head-name"><a href="http://www.example.com/example.html" title="example title">times have changed</a></h2> <div class="sub-name">10 things did not know time</div> </div> <div class="name-hg"> <h2 class="head-name"><a href="http://www.example.com/example.html" title="example title">a guide mental fitness</a></h2> <div class="sub-name">i fit... mentally is.</div> </div> <div class="name-hg"> <h2 class="head-name"><a href="http://www.example.com/example.html" title="example title">sllippers &amp; boots</a></h2> <div class="sub-name">fashion eccentric</d...

java - Netty causing memory leak in tomcat -

i'm using netty 4.0.26.final along tomcat 8 implement embedded tcp server inside web application. the problem when stop tomcat i'm getting message : the web application [app] appears have started thread named [nioeventloopgroup-2-1] has failed stop it. create memory leak. stack trace of thread: sun.nio.ch.windowsselectorimpl$subselector.poll0(native method) sun.nio.ch.windowsselectorimpl$subselector.poll(windowsselectorimpl.java:296) sun.nio.ch.windowsselectorimpl$subselector.access$400(windowsselectorimpl.java:278) sun.nio.ch.windowsselectorimpl.doselect(windowsselectorimpl.java:159) sun.nio.ch.selectorimpl.lockanddoselect(selectorimpl.java:87) sun.nio.ch.selectorimpl.select(selectorimpl.java:98) io.netty.channel.nio.nioeventloop.select(nioeventloop.java:622) io.netty.channel.nio.nioeventloop.run(nioeventloop.java:310) io.netty.util.concurrent.singlethreadeventexecutor$2.run(singlethreadeventexecutor.java:111) io.netty.util.concurrent.defaultthreadfactory$d...

c# - Convert fullwidth to halfwidth -

in c#, how convert string that's using fullwidth form characters halfwidth form characters? for example, given userinput below, want convert Stackoverflow stackoverflow : string userinput= "Stackoverflow"; //string userinput= "stackoverflow"; you can use string.normalize() method: string userinput = "Stackoverflow"; string result = userinput.normalize(normalizationform.formkc); //result = "stackoverflow" see example on dotnetfiddle . more information on normalization forms can found on unicode.org .

ios9 - iOS 9 unable to access camera from addressbookui/contactsui while adding a new contact -

since ios 9 while adding new contact in app using addressbookui framework unable add photo camera although can add photo photo library. works expected in ios 8 , below versions. have used contactsui api , tried add photo camera doesnot work. //ios 9 cncontact *contact = [[cncontact alloc] init]; cncontactviewcontroller *contactvc = [cncontactviewcontroller viewcontrollerfornewcontact:contact]; [self presentviewcontroller:contactvc animated:yes completion:nil]; //ios 8 abnewpersonviewcontroller *unknownpersonviewcontroller = [[abnewpersonviewcontroller alloc] init]; [self presentviewcontroller:unknownpersonviewcontroller animated:yes completion:nil];

javascript - Allow div scrolling with page scroll, but only within parent div -

Image
i have div needs stay on page as possible when user scrolling down. starts off inside it's parent div @ top. when user scrolls, needs stay on page, until hits bottom of div, must stop scrolling on page , accept it's fate scrolling off of top of page. confused? me too. here paint diagram of happen on scroll: here happening: here bodged jquery using achieve near this: //start div scrolling if ($(this).scrolltop() > 420 && $(this).scrolltop() < 1200) { $('.fixedelement').css({ 'position': 'fixed', 'top': '0px' }); } //stop div scrolling if ($(this).scrolltop() < 420) { $('.fixedelement').css({ 'position': 'static', 'top': '0px' }); } //div stop scrolling div leave parent div otherwise. master not want that. if ($(this).scrolltop() > 1200) { $('.fixedelement').css({ ...

sql server - SP_ExecuteSQL Generic stored_procedure call without output parameters, but catching the output -

i'm scratching head hard on pb , figure out solution. inside tsql programmable object (a stored procedure or query in management studio) i have parameter containing name of stored procedure + required argument these stored procedures (for exemple it's between brackets []) sample of @sptocall ex1 : [sp_choosetypeofresult 'water type'] ex2 : [sp_choosetypeofxmlresult 'table type', 'node xml'] ex3 : [sp_getsomeresult] i can't change thoses stored procedures (and don't have nice output param cache, need change stored procedure definition) all these stored procedures 'return' 'select' of 1 record same datatype ie: nvarchar . unfortunately there no output param in stored procedures definition (it have been easy otherwise :d) so i'm working on can't find working declare @myfinalvarfilledwithcachedoutput nvarchar(max); declare @sptocall nvarchar(max) = n'sp_choosetypeofxmlresult ''table type'...

php - MySQL server has gone away error on server -

i have following code storing info arxiv.org pages in mysql function paper_info($paper_id){ $url = 'http://arxiv.org/abs/'.$paper_id; $options = array('http'=>array('method'=>"get", 'header'=>"user-agent: mozilla/5.0 (windows nt 6.1; trident/7.0; rv:11.0) gecko\r\n")); $context = stream_context_create($options); $sites_html = file_get_contents($url, false, $context); $html = new domdocument(); @$html->loadhtml($sites_html); $title = null; foreach($html->getelementsbytagname('meta') $meta) { if($meta->getattribute("name")=="citation_title"){ $title = $meta->getattribute('content'); } } if(preg_match('~<blockquote class="abstract mathjax">(.*?)</blockquote>~si', $sites_html, $match)){ $abstract = trim(preg_replace('#<span class="descriptor">(.*?)<...

android - Workaround a bug in Samsung camera drivers -

i'm writing application custom camera functionality. in picture taken device's camera shown user question if needs saved. i'm using method: public final void takepicture (camera.shuttercallback shutter, camera.picturecallback raw, camera.picturecallback postview, camera.picturecallback jpeg) ( http://developer.android.com/reference/android/hardware/camera.html#takepicture%28android.hardware.camera.shuttercallback,%20android.hardware.camera.picturecallback,%20android.hardware.camera.picturecallback,%20android.hardware.camera.picturecallback%29 ) according documentation method pauses preview after picture has been taken, feature need. however, on samsung devices preview not paused, assume bug in camera drivers. can reproduce bug on galaxy s3 (gt-i9300), , qa says reproduce on other samsung devices too. on devices other manufacturers method works expected. i tried manually pausing preview in each of camera.takepicture() callbacks, none of them executed @ precise t...

Reading file multiple ways in Python -

i trying set system running various statistics on text file. in endeavor need open file in python (v2.7.10) , read both lines, , string, statistical functions work. so far have this: import csv, json, re textstat.textstat import textstat file = "data/test.txt" data = open(file, "r") string = data.read().replace('\n', '') lines = 0 blanklines = 0 word_list = [] cf_dict = {} word_dict = {} punctuations = [",", ".", "!", "?", ";", ":"] sentences = 0 this sets file , preliminary variables. @ point, print textstat.syllable_count(string) returns number. further, have: for line in data: lines += 1 if line.startswith('\n'): blanklines += 1 word_list.extend(line.split()) char in line.lower(): cf_dict[char] = cf_dict.get(char, 0) + 1 word in word_list: lastchar = word[-1] if lastchar in punctuations: word = word.rstrip(lastcha...