Posts

Showing posts from February, 2014

python - Unable to run Django's unit test -

when typed python manage.py test run unit testcases, prompted error messages below: traceback (most recent call last): ... django.test.utils import contextlist file "d:\dev\py27\lib\site-packages\django\test\utils.py", line 8, in <module> unittest import skipif, skipunless importerror: cannot import name skipif when run unittest alone, works fine, running unittest in django failed. unittest should built-in library of python. please let me know how fix issue. thanks. use dir(unittest) verify skipif etc included in unittest . in case skipif missing, , install python interpreter work. i tried several versions of python on windows , miss skipif .

cassandra - Ad hoc query support in NOSQL -

we can store duplicate data need in nosql dbs. data must saved in same pattern in want access out of it. there might cases don't access pattern in might need access data e.g. ad hoc queries. my company works on financial domain ad hoc queries used often. right use sql server stored procedure used perform ad hoc data calculations. here mean query can't predicted in advance ad hoc query. how model query behavior in nosql. right evaluating cassandra open switch other nosql databases any lead ? if looking full text search solr fit: http://lucene.apache.org/solr/

angularjs - How to insert a new line inside a directive template in angular.js? -

hi know easy question how can insert new line in directive template? have long template. , hard me scan through horizontally. want have in new line. angular doesn't want. app.directive('broadcasted', function(){ return{ restrict: 'eac', // new line template not in single line template: '<div class="alert alert-success col-md-6" ng-repeat="x in bcards"><strong class="broadcast-text" ><% x.q_number %> - <% x.teller_id %></strong></div>', link: function($scope){ } }; }); how this: app.directive('broadcasted', function(){ return{ restrict: 'eac', // new line template not in single line template: '<div class="alert alert-success col-md-6" ng-repeat="x in bcards">' + '<strong class="broadcast-text" >' + '<% x.q_number %> - <% x.t

angularjs - ngCart checkout button always 404s -

i feel being stupid. in docs says ngcart render checkout button this: <ngcart-checkout service="http" settings="{ url:'/checkout' }"></ngcart-checkout> however returns 404. have setup checkout view , added routeprovider (which works normal link) i have tried variations (add hashbang etc) , links non-angular pages 404s ngcart's example seem invoke checkout button so: <div ng-if="service=='http' || service == 'log'"> <button class="btn btn-primary" ng-click="checkout()" ng-disabled="!ngcart.gettotalitems()" ng-transclude>checkout</button> </div> this returns: provider.checkout not function - expected haven't declared it. wouldn't know start creating function open checkout page. any awesome! try changing code this: <ngcart-checkout service="http" settings="{ url:'/#/checkout' }"></ngc

ruby on rails - How to call a helper method in view -

i have code in helper: def app_state(app) state = app.operator_apps.map(&:is_production) if state.include?(true) , state.include?(false) "sandbox/production" elsif state.include?(true) "production" else "sandbox" end end and in view have done this: <%= app.app_state %> i following error: actionview::template::error (undefined method `app_state' #): please me out in solving this. the error getting persist unless app_state method defined somewhere within app 's model. try calling helper method so: <%= app_state(app) %> now app object being passed in argument of app_state method, instead of method being called on object itself. hope helps!

oracle - Total count in sql -

i need create view display total number of students have declared 2 majors ( major1 , major2 not null). what query should use? my goal single row of output know order by clause irrelevant in case. something this: create view getnumberofstudentswithmajor select count(*) dbo.students major1 not null , major2 not null

javascript - How to add delay only when the function is called? -

i trying call function delay. window.setinterval(function(){ //$('.product-display').delay(3000).hide(); document.getelementbyid('product-list-display').style.display = "none"; },3000); the above code hides div after 3 seconds, above snippet called in show div function. need is, want invoke the above delay function when show div function called...right function executes every 3 secnds i.e using setinterval hiding. want hide after 3 seconds when show div called. how can this? can use jquery? function showdiv(city, imagesrc, timeout) { window.settimeout(function() { document.getelementbyid('city-order').innerhtml = ""; document.getelementbyid('order-product').innerhtml = ""; $('.product-display').addclass("zoomin"); document.getelementbyid('product-list-display').style.display = "block"; var order_placed_city = document.g

c# - Pagination code issue -

i have written below lines of code acconmplishing pagination in asp.net using repeater control as <asp:linkbutton id="linkbutton1" runat="server" causesvalidation="false" onclick="pagenexte_click" data-rel="tooltip" data-original-title="previous page.">&laquo;</asp:linkbutton> <asp:repeater id="rptpager" onitemdatabound="rptpager_itemdatabound" runat="server"> <itemtemplate> <asp:linkbutton id="lnkpage" runat="server" text='<%#eval("text") %>' commandargument='<%# eval("value") %>' enabled='<%# eval("enabled") %>' onclick="page_changed"></asp:linkbutton> </itemtemplate> </asp:repeater> <asp:linkbutton id="linkbutton3" runat="server" causesvalidation="false" onclick="pagenext_click&

javascript - Changing value of an attribute using jQuery -

i having file input field: <input class="uploadreptctrl" id="lang_file_1" name="photo[[1,312,3]]" type="file"> i trying change third element of array in name attribute becomes: <input class="uploadreptctrl" id="lang_file_1" name="photo[[1,312,4]]" type="file"> how possible? try this $('#lang_file_1').attr('name','photo[[1,312,4]]') https://jsfiddle.net/jzzl1d2r/ you can store value in variable , set as var = 4; $('#lang_file_1').attr('name','photo[[1,312,'+a+']]') https://jsfiddle.net/jzzl1d2r/1/ as want 3rd number increment , assign again can following var numberpattern = /\d+/g; var string = $('#lang_file_1').attr('name'); var = string.match( numberpattern ); $('#lang_file_1').attr('name','photo[[1,312,'+(++a[2])+']]'); https://jsfiddle.net/jzzl1d2r/3/

unity3d - image couldn't loaded from ios device in unity -

i using unity load facebook profile picture saved in device. code working fine in android not ios. suffering problem many days. here code, please me. using unityengine; using system.collections; using system.io; using unityengine.ui; public class userprofilepicture : monobehaviour { public rawimage profilepicture, testprofile; private texture2d texture,text; void fixedupdate(){ if (fbsetup.userinfoloaded) { if(spfacebook.instance.userinfo.getprofileimage(facebookprofileimagesize.square) != null) { text = spfacebook.instance.userinfo.getprofileimage(facebookprofileimagesize.square); } } testprofile.texture = text texture; byte[] texturebyte = text.encodetopng (); file.writeallbytes (path.combine(application.persistentdatapath,"profilepicture.png"),texturebyte); debug.log("save path: " + application.persistentdatapath + path.directoryseparatorchar + "profilepicture.png"); if(file.exists(ap

mysql - Store perl array in memory for other perl instances -

i using perl script upon receiving parameters, check 1 value on database , executes other actions accordingly. since traffic increasing there lot of mysql reads/writes being executed , might affecting performance. since data stored in mysql not complicated, wondering if better store array in memory can read/modified other perl instances ran. is possible? you can use shared memory ipc::sharedmem low level core module to non reinvent wheel, take to: ipc::shareable ipc::shareable allows tie variable shared memory making easy share contents of variable other perl processes. scalars, arrays, , hashes can tied. variable being tied may contain arbitrarily complex data structures - including references arrays, hashes of hashes, etc.

RTP Capture through java -

i wondering if possible read rtp packets ipaddress:port. have information rtp from. listen wire shark. want capture rtp packets , write them file. i've been looking @ jmf , think way go. know if has made sample code implement requirement. thanks :) you might want have @ rtp2dash project. jmf outdated gets - don't use (even if advice might bit late). the rtp2dash project reads aac , h264 rtp packets , re-emits mpeg-dash stream might adopted simple write mp4 files (as mpeg-dash mp4 based) good luck! sebastian

java - How to test an activity with robolectric while it has android.support.v7.widget.CardView? -

i have complex project contains few flavors , project dependency projects. if consider my_project project, contains project_1 main project, project_2 , project_3 acting dependency project_1. i've put tests under project_2/src/test/java . i'm trying write few simple methods test splash screen based on. this code have written: package com.something.splash; import android.os.build; import android.view.view; import static org.junit.assert.assertnotnull; import static org.junit.assert.assertnull; import static org.junit.assert.asserttrue; import com.flavour_1.buildconfig; import com.flavour_1.r; import org.junit.assert; import org.junit.before; import org.junit.test; import org.junit.runner.runwith; import org.robolectric.robolectric; import org.robolectric.robolectricgradletestrunner; import org.robolectric.annotation.config; @runwith(robolectricgradletestrunner.class) @config(constants = buildconfig.class, sdk = build.version_codes.kitkat, manifest = "../projec

javascript - Protractor IE 11 Error - Failed to find element -

using following syntax find username input text box, browser.findelement(by.id('username')); it works fine in chrome , firefox, has following error in ie 11: [internet explorer #3] message: [internet explorer #3] failed: finding elements id ==usernamereturned unexpected error (warning: server did not provide stacktrace information) [internet explorer #3] command duration or timeout: 970 milliseconds [internet explorer #3] documentation on error, please visit: http://seleniumhq.org/exceptions/no_such_element.html [internet explorer #3] build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' [internet explorer #3] system info: host: 'dev-web-01', ip: '10.126.1.32', os.name: 'windows server 2012 r2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45' [internet explorer #3] driver info: org.openqa.selenium.ie.int

Unable to understand the way of trimming white spaces in regex in a line from start to end using regex -

i'm new regex.i'm trying understand concept of trimming white spaces in line.in process came across snippet below given example: http://regexone.com/example/5 the question has got solution well ^\s*([\w\s.]*)\s*$ however..i finding hard understand this.let me explain understanding till now ^ - starting of line \s* - whitespace [\w\s.]*- combination of word character , white space character??(zero or more times??)(have not understood properly) \s* -again whitespace character(zero or more times?) $ -end of line i able understand syntax couldnot understand it's complete sense.any highly appreciated. that looks right. try clarify ^ - start of line \s - single whitespace character (space or tab or line return) * - 0 or more of previous item \s* - 0 or more whitespace characters [] - character class. matches of characters or groups of characters contained [\w\s.] - matches word character,

version control - Cannot clone Mercurial repo - abort: repository http://hg.something.com/something error -

Image
i ran command clone repo [19:07:19 root /data]$ hg clone http://hg.something.com/something dir abort: repository http://hg.something.com/something not found! [19:07:19 root /data]$ i not sure why hg says cannot find repo when can access repo http://hg.something.com/something web browser. same command works colleague's machine. , ping hg.something.com works fine. 1 more thing have same repo cloned using same command in same directory few days back. hg totally operational inside directory. any hint may causing problem? ps : can't use ssh. have stick http. i found peculiar problem. had copied repo link web browser looked this- if see there small character ( red circle ) indicates repo link. when copied whole command, character got copied. when pasted command linux terminal, turned invisible character , such never spot mercurial could. when pasted whole command vim, showed "invisible" character this- hg clone <200b>http://hg.somethin

How do I clear screen in julia-app mac OS-X? -

**how clear screen in julia-app mac os-x ** in mac terminal - clear clear terminal screen. how do same in julia interactive app in mac os x? use keyboard shortcut : ctrl + l . use julia's repl shell mode : julia> ; # upon typing ;, prompt changes (in place) to: shell> shell> clear # unix shell> cmd /c cls # windows if need function use run function: julia> ? # upon typing ?, prompt changes (in place) to: help> help?> run info: loading data... base.run(command) run command object, constructed backticks. throws error if goes wrong, including process exiting non- 0 status. julia> using compat: @static, is_unix # `pkg.add("compat")` if not installed. julia> clear() = run(@static is_unix() ? `clear` : `cmd /c cls`) clear (generic function 1 method) julia> clear() this works in platform , version independent way (tested in windows , linux, julia versions 0.3.12, 0.4.5 , 0.5.+).

ruby on rails - Dragonfly Imagemagick rotate, than crop than resize -

i using jquery plugin allows basic image manipulation: cropping, rotating, zooming, etc. i able rotate image: image = photo.image.rotate(wrapper.rotate) i able crop image image.thumb("#{wrapper.width}x#{wrapper.height}+#{wrapper.x}+#{wrapper.y}") however, can't figure out way resize image after cropping it. basically, want run: image.thumb("300x200!") once more. i understand image.thumb() returns dragonfly job, possible preform process after cropping it? some context on why want this: user can pan on specific area of image visible in 300x200px container. of time, image way larger 300x200px, want re-size after cropping reduce filesize. instead of trying given methods, use .convert , pass normal image magic arguments 1 lone string e.g image.convert("-gravity center -crop '#{wrapper.width}x#{wrapper.height}+#{wrapper.x}+#{wrapper.y}' -resize '300x200!'")

c# - MVC Number Input Being Treated as null -

Image
using form (with html.beginform ), have input type number . when submit so: i following error: the parameters dictionary contains null entry parameter 'amountonhand' of non-nullable type 'system.int32' method 'system.web.mvc.actionresult ingredient(int32, system.string, int32, system.string)' in 'brewreport.web.controllers.admincontroller'. optional parameter must reference type, nullable type, or declared optional parameter. parameter name: parameters the form (simplified) follows: @using (html.beginform("ingredient", "admin", formmethod.post, new { enctype = "multipart/form-data" })) { <input id="amountonhand" type="number" class="form-control" min="0" required="required" /> <input type="submit" class="btn btn-primary btn-lg" value="save changes ingredient" /> } here controller method: [httppost] pub

c# - Function to return list of strings starting with a character -

i want write function taking list of strings , character, returns list of strings start character. public list<string> sort(list<string> mylist, char mychar) { //this format want } something should work described: public list<string> sort(list<string> thelist, char thechar) { list<string> output = new list<string>(); foreach(string s in thelist) { if (s.startswith(thechar.tostring())) { output.add(s); } } return output; } don't want sound harsh, if cant implement code yourself, under qualified job.

php - Mysqli Getting Multiple Values from Multiple Tables -

i'm struggling figure out, , it's pretty simple can't work. using php/mysqli i'm trying data 2 tables, while first table have basis everything , second table may or may not have data matches first table's data, need second table return empty values . example... first table ' cust ': customerid name school ------------------------------------------ 1623 bob smith bon 1785 betty davis foot 1854 john miller beck 1547 kate lake bon second table ' ybk ': customerid frame type ------------------------------------------ 1623 001 cc 1854 012 cc what these 2 tables bit variable between 2 things... 1) if want select school first table (for example cust.school='bon') result back: customerid name school frame type --------------------------------------------------------- 1623 bob smith

javascript - How do I make this code refresh every minute? -

how make code refresh every minute? <script type="text/javascript"> $j(document).ready(function () { $j('#left-box').load('pages/box.php'); }); </script> i want refresh every 1 minute i've tried other stuff cant it use setinterval follows: $j(document).ready(function () { setinterval(function () { $j('#left-box').load('pages/box.php') }, 60000); });

java - The sum of all the multiples of 3 or 5 below N. Project Euler -

so i'm doing project euler challenge , i'm stuck @ first one, i'm using java pl. example if have list natural numbers below 10 multiples of 3 or 5, 3, 5, 6 , 9. sum of these multiples 23. have find sum of multiples of 3 or 5 below n. my code works on eclipse "nice try, did not pass test case." stdout : no response , when submit code wrong answer on test cases, here's code: public class solution { public static void main(string[] args) { (int j = 0; j < args.length; j++) { int n = integer.parseint(args[j]); if (somme(n) != 0) { system.out.println(somme(n)); } } } public static int somme(int nn) { int s = 0; (int = 0; < nn; i++) { if (((i % 3) == 0) || ((i % 5) == 0) && !(((i % 3) == 0) && ((i % 5) == 0))) { s = s + i; } } return (s); } } update : so, looked m

apache - Redirection to another port on the same server -

i have web application in http://example.com:8080/example-app/ when user types http://example.com/ , i'd redirect him web app. options +followsymlinks rewriteengine on rewritecond %{http_host} (.*)example.com$ [nc] rewriterule ^(.*)$ http://example.com:8080/example-app/$1 [l,r=301] i believe .htaccess has correct access right: $ ls -altr /var/www/html/.htaccess -rw-r--r-- 1 apache apache 178 jul 2 00:31 /var/www/html/.htaccess but navigating http://example.com/ serves index.html file. can tell me why doesn't work? there way debug this? (apache on centos). change server default listening port 8080 80 in configuration file 1 easy or try proxy tho redirect request below , default document root folder namevirtualhost *:8080 <virtualhost *> serveradmin me@example.com servername www.example.com:8080 proxypreservehost on # setup proxy <proxy *> order allow,deny allow </prox

regex - Extracting phone number issue in R -

having numbers this: ll <- readlines(textconnection("(412) 573-7777 opt 1 563.785.1655 x1797 (567) 523-1534 x7753 (567) 483-2119 x 477 (451) 897-mall (342) 668-6255 ext 7 (317) 737-3377 opt 4 (239) 572-8878 x 3 233.785.1655 x1776 (138) 761-6877 x 4 (411) 446-6626 x 14 (412) 337-3332x19 412.393.3177 x24 327.961.1757 ext.4")) what regex should write get: xxx-xxx-xxxx i tried one: gsub('[(]([0-9]{3})[)] ([0-9]{3})[-]([0-9]{4}).*','\\1-\\2-\\3',ll) it doesn't cover possibilities. think can using several regex patterns, think can done using single regex. if want extract numbers represented letters, can use following regex in gsub : gsub('[(]?([0-9]{3})[)]?[. -]([a-z0-9]{3})[. -]([a-z0-9]{4}).*','\\1-\\2-\\3',ll) see ideone demo you can remove a-z character classes match numbers no letters. regex : [(]? - optional ( ([0-9]{3}) - 3 digits [)]? - optional ) [. -] - either dot, or space, or hyphen ([a-

java - How to stop letters and erroneous characters as input -

i want throw error message when char or erroneous character input, loop works numbers other 1-5. class premierleagueclubs displays text. guessing need try catch block(s), maybe inputmismatchexception , i'm not sure in code put this? import java.util.*; import java.util.inputmismatchexception; import java.util.scanner; public class mainmenu3 extends premierleagueclubs{ public static void main(string args[]){ boolean valid = false; int option = 0; while (!valid) { scanner in = new scanner(system.in); menu(); system.out.println("\n"); option = in.nextint(); valid = option > 0 && option < 6; switch (option) { case 1: chooseteam(); case 2: createprofile(); //break; case 3: loadsave(); // break; case 4: credits(); // break; case 5: system.out.print

c# - Could not load file or assembly 'CefSharp.Wpf for both x64 and x86; only one works -

Image
when run get: could not load file or assembly 'cefsharp.wpf, version=41.0.0.0, culture=neutral, publickeytoken=40c4b6fc221f4138' or 1 of dependencies. attempt made load program incorrect format. means problem due dlls not being correct bitness. in version 41.0.0, nuget package adds dll references x86 version point correct path (an x86 folder). there copy of dlls point empty path in properties panel. problem x64 version crashes bad image error because referencing x86 versions of dlls. i have tracked 39.0.2 , cefsharp works me. have both sets of dlls , x86 , x64 versions of application compile , run expected. when upgrade again 41.0.0 same problem before. x64 version compile though application uses x86 versions of dll crashes when trying display first browser. tried rebuild removing dlls copied in automatically , during compilation x86 versions copied in again. (at least believe case a i removed of dlls in references , manually added x64 versions. compilati

Uppercase Visual Studio 2013 project template $itemname$ -

is there way uppercase visual studio project template parameters? for example change $safeprojectname$ uppercase. you can write template wizard extension. in runstarted method you dictionary list of standard parameters should replaced dictionary<string, string> replacementsdictionary you can go on dictionary , toupper or else yourself: foreach (var key in replacementsdictionary.keys) { replacementsdictionary[key] = replacementsdictionary[key].toupper(); }

javascript - Find polygon for place in KML -

note : please make sure read updates @ bottom!! i have kml file load 'onto' google map; have searchbox users can search city. when city found place marker which, in (if not all) cases should fall in 1 of polygons defined in kml. i can click polygon , shows info-popup areacode area; however: when marker placed have info-popup shown automatically (and possibly other(s) shown before placing marker hidden). i have looked on maps v3 documentation unable find anything. possible? you can view project @ http://netnummer.robiii.me , source can found @ https://github.com/robthree/netnummersnl the relevant (snippet of) code is: google.maps.event.addlistener(autocomplete, 'place_changed', function () { var place = autocomplete.getplace(); if (!place.geometry) return; // remove existing markers (var = 0, marker; marker = markers[i]; i++) marker.setmap(null); markers = []; // create marker place. var marker = new googl

asp.net mvc - I can't find a way to filter using PagedList -

well, assume problem it's pretty simple. second table... first 1 took 3 minutes load. looking way make faster found this: using nuget . can't make filter records. filter them once , show first page filtered, when click on page doesn't filter anymore. in bottom of partial view (where table displayed) have helper method filters. in here send page alone controller... in view (index) filter them brand send brand alone controller. controller public actionresult index(string brand_name, int? page) { //returns iqueryable<product> representing unknown number of products. thousand maybe? //var products = myproductdatasource.findallproducts(); viewdata["brand_name"] = brand_name; // if no page specified in querystring, default first page (1) var pagenumber = page.hasvalue ? page.value : 1; //viewbag.onepageofproducts = onepageofproducts; if (!string.isnullorwhitespace

c# - Regex match with multiple occurences -

with strings example 90001:21880004:los angeles 10001:21880005:new york i want extract city names @ end through regex. finding hard 2 : can point me in right direction? if want use regex: ^\d+:\d+:(.+)$ should work. ([^\d:]+) should work. however, looks want split. "11111:111111:name".split(':')[2] fastest method.

python - Determine if two html elements are siblings -

so, i'm building little utility automatically grab text article-style page. thought on how best solve problem find elements more ~150 chars of text: document.xpath("//*[string-length( text() ) > 150 ]") i list of elements , want identify of elements siblings, if possible i'd avoid doing more dom traversal sake of efficiency. is there nice way of doing in lxml? given list of nodes l , check whether parent of pair of elements same (where parent obtained .getparent() ): def get_siblings(l): in l: b in l: if < b: # tests elements' memory addresses, # don't duplicate pairs or test # elements against if a.getparent() == b.getparent(): yield (a, b) or maybe simpler: def get_siblings(l): return ((a, b) in l b in l if < b , a.getparent() == b.getparent()) you use counte

java - I am not able to use openFileInput() method in my Expandable list adapter -

i have been trying out way read file subs.txt. know there because works in other classes not one. on buffer reader no file exception , when use openfileinput "cannot find symbol method openfileinput()". public class expandableadapter extends baseexpandablelistadapter { private activity activity; private arraylist<object> childtems; private layoutinflater inflater; private arraylist<string> parentitems, child; public expandableadapter(arraylist<string> parents, arraylist<object> childern) { this.parentitems = parents; this.childtems = childern; } public void setinflater(layoutinflater inflater, activity activity) { this.inflater = inflater; this.activity = activity; } @override public view getchildview(int groupposition, final int childposition, boolean islastchild, view convertview, viewgroup parent) { child = (arraylist<string>) childtems.get(group

Java PhantomJS with Ghost Driver Working on Mac But Not On Linux -

our web application running fine on mac getting timeout out exception on linux. using phantomjs 1.9.8 , 1.9.7. below java code , stack trace. hi, our web application running fine on mac getting timeout out exception on linux. using phantomjs 1.9.8 , 1.9.7. below java code , stack trace. hi, our web application running fine on mac getting timeout out exception on linux. using phantomjs 1.9.8 , 1.9.7. below java code , stack trace. file scrfile=null; webdriver driver=null; try{ // initiation caps spring dependency. caps.setcapability(phantomjsdriverservice.phantomjs_executable_path_property, pathtophantomjs); caps.setcapability("phantomjs.binary.path", pathtophantomjs); caps.setcapability(iscoreconstants.take_screen_shot, true); logger.info("getting driver instance ."); driver = new phantomjsdriver(caps); logger.info("driver instance created."); stack trace: [date=&quot;2015-07-01 00:02:17,254&a

memory - Declare __global object inside kernel -

i tried declare __global memory chunk inside kernel, like __global float arr[200]; i assume create array in global memory referred in kernel. program compiled successfully, when run it, indicated: error: variable automatic storage duration cannot stored in named address space i don't know why happen. in order use global memory, did have create buffer on host side before use it? if want create array shared threads, except passing new argument global array, can instead ? you can allocate in program scope, @ least in opencl 2. __global float arr[200]; kernel void foo() { if(get_global_id(0) == 0) arr[0] = 3; } though careful initialization of course, there's no way synchronize work-items across dispatch not practical initialize , use in same kernel if have multiple work-groups. it doesn't make sense allocate in kernel scope. if work-groups serialized, lifetime of global array allocated in kernel code? should outlast workgr

python - How to access a method in one inherited tkinter class from another inherited tkinter class -

i've programmed using tkinter before, did long procedural gui class implemented other non gui classes i've created. time wanted using more oop making more modular. i ran problem, i've searched answers , haven't found any, means it's either easy or i'm wrong. created inherited classes tk.labelframe , created gui widgets in them. have methods manipulate widgets in classes can't figure out how execute function in inherited class, partly because can't figure out how correctly instantiate object other class (which have tkinter ('parent') objects parameters). would overloading constructors? i've seen @classmethods , *args, **kwargs haven't acted on them i'm not sure if that's right route either. there's debate best/correct way implement overloaded constructor in python. i'm stumped apropos i'm trying accomplish... thanks #python 2.7 on win7 import tkinter tk class testing(tk.labelframe): buttonwidth = 10

javascript - Redirect to another html page after JS function (Ionic, AngularJS) - Cordova -

i building android app in cordova tools visual studio using ionic , angularjs. i want redirect html page after function has finished executing cant seem work. heres function if (id == null || id == undefined) { contact.save(savesuccess, saveerror); } else { contact.save(upsuccess, uperror); } function savesuccess(newcontact) { id = newcontact.id; table.insert({ contactid: id, firstname: name.givenname, lastname: name.familyname, homephone: phonenumbers[0].value, mobilephone: phonenumbers[1].value, email: emails[0].value }); alert("contact saved."); window.location("#/managermenu"); } and heres $routprovider code. droidsync.config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'app/pages/main.html', controller: 'maincontroller' }

How to parse a text file successfully in rails -

i'm new rails, , trying set simple app parses list database that's displayed in app. the list have text file of films john williams scored, , actual parsing goes fine, when trying put database hits error. (nomethoderror). parser file: rails_env = 'development' require file.expand_path('../environment', __file__) f = file.open("films.txt") f.each |line| title = line[0,line.index('(')] year = line[line.index('('),line.rindex(')')] puts title puts year puts '/' @film = film.new @film.title = title @film.year = year @film.save end f.close it says error undefined method "title=" , i'm not sure means. this own interest feel free link me readings or whatever, solution nice too. cheers. edit: schema: activerecord::schema.define(version: 20141221022528) create_table "films", force: true |t| t.datetime "created_at" t.datetime "updated_at&q

ruby - How to reduce number of queries in Rails -

i have cats table. cat has_many impressions, , impression has impression_count , impression_day columns - count aggregate of people who've viewed cat on given day. what want create chart line chart showing number of impressions of cat on many dates. js charting library i'm using takes 2 arrays: chartvalues , , chartlabels . my controller action generate arrays: def show @cat = cat.find(params[:id]) @from = @cat.created_at @to = time.now dates = (@from.to_date..@to) @chartlabels = dates.to_a.map {|date| date.strftime("%b %e")} shown = @cat.impressions.ordered.between(@from,@to) @chartvalues = create_stats_for dates, shown end the private create_stats_for method used shovel 0 values array if no impressions recorded on date: private def create_stats_for dates, values stat_values = [] dates.each |date| valid_impression = values.find_by impression_day: date if valid_impression stat_values << valid_im