Posts

Showing posts from January, 2011

(Android) Find path /Android in internal storage -

is there method in android returns data path on internal storage? i have 2 android smartphone (samsung s2 , s7 edge) installed application. want take sqlitedb situated in path: /android/data/application.most/files/most_db the problem in samsung s2 must use path take db: private static final string db_path = "/storage/sdcard0/android/data/org.application/files/application_db"; instaed, in s7 must use this: private static final string db_path = "/storage/emulated/0/android/data/application.most/files/application_db"; i want take path independently device. can me? thanks in advance. i think you're looking that string path = getfilesdir().getabsolutepath();

meteor - Multiple startups on client -

we're seeing strange meteor behavior. after simple event hook executed (which gathers info form, executes insert , updates session variable), client seems startup again, redrawing entire page. in effect, meteor.startup being executed more once, though browser window not being refreshed (or that). stranger fact we've made extremely similar apps, don't display behavior @ all. cannot detect significant differences between different projects. we're using meteor version 0.6.4.1 (in cases), both autopublish , insecure have been removed. playlist.html: <body> {{> addsong}} {{> playlist}} </body> <template name="addsong"> <form> <fieldset> <legend>add song playlist!</legend> <div><input type="text" id="artist" /></div> <div><input type="text" id="title" /></div> <div><button type="submi...

python - file opening dialog & drag and drop in pygame -

i want build little application; , has have sort of possibility load files. right copying path application, want build possibility to drop file outside gui and have file opening dialog. is there way accomplish @ least 1 of requirements? because not want create non-native file opening dialog myself. you can use file opening dialog tkinter. to filename code be: from tkinter.filedialog import askopenfilename ## or tkinter.filedialog import * tkinter import * root = tk() foo = askopenfilename() root.destroy() print(foo)

javascript - jQuery Validation validate all steps in a multi-part form -

i'm made multi-part registration form, using jquery validation. problem clicking next button in first fieldset, validation works fine. in next fieldset, active fieldset slid , ignores validation, scenario same others. <script> $(document).ready(function () { // required fields var fields = [ { package: 'required' }, { fname: 'required', lname: 'required' } ]; // messages var msgs = [ { package: 'please select package.' }, { fname: 'please enter first name.', lname: 'please enter last name.' } ]; // index of active fieldset var active = $('fieldset.active').index() - 1; // want single method next button $('.next').click(function () { ...

angularjs - $stateprovider doesn't work or show any kind of errors -

Image
i can't figure out why angular state provider doesn't work , doesn't show no errors. when used ngroute working when included ui.router nothing seems work. once opened application, /#/ link generated (routed), hangs on myapp.com/ my html index.html <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>myapp</title> <style type="text/css"> [ng\:cloak], [ng-cloak], .ng-cloak { display: none !important; } </style> </head> <body class="hold-transition skin-blue sidebar-mini" ng-app="app"> <div class="wrapper"> <div class="content-wrapper"> <div ng-view></div> </div><!-- /.content-wrapper --> </div> <scrip...

r - Multiple if statement to change sign of column values -

i try change positive/negative sign of column values based on multiple conditions. dataframe looks this: df rs pub_snp snp b rs_1 g g 0.1 rs_2 c -0.2 rs_3 t 0.3 rs_4 t c -0.4 rs_5 t g 0.5 based on df$pub_snp , df$snp im trying change column df$b , (please notice, code not work, represent im trying achive) df$new_b <- ifelse(df$pub_snp=="c" & df$snp=="g" & df$pub_snp=="c" & df$snp=="c" & df$pub_snp=="g" & df$snp=="g", df$b, df$b) df$new_b<- ifelse(df$pub_snp=="a" & df$snp=="t" & df$pub_snp=="a" & df$snp=="a" & df$pub_snp=="t" & df$snp=="t", df$b,df$b) i following output: df rs pub_snp snp b ...

cmd - Print text before input() prompt in python -

in python, possible request user input input() in console while simultaneously printing out text in line before prompt? should this: text 1 text 2 text 3 please enter something: abc whenever new text printed, should printed after previous text , before input() prompt. also, should not interrupt user entering text. therefore, after printing "text 4" console should this: text 1 text 2 text 3 text 4 please enter something: abc is possible in python without using external libraries? i have tried using \r, \b , similar codes threading. know need have 1 thread printing out text while have 1 requesting user input. here's approach using ansi/vt100 terminal control escape sequences. we tell terminal scroll upper region of terminal, output data printed, lower region, input prompt printed, stays fixed in place. when exit program (using ctrl c ) need restore default scrolling settings. this program first clears screen , sits in loop prompting user number...

cannot find module in electron prebuilt 1.x but in 0.x (0.2 and 0.3 -

i have small code, run in electron (using prebuild 0.3.5, , 0.25). i upgrade electron prebuild 1.1.0 , 1.2.0 i got error uncaught exception: error: cannot find module 'app' @ module._resolvefilename (module.js:438:15) @ function.module._resolvefilename (/home/mervo/electron/midas-tron/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:47:12) @ function.module._load (module.js:386:25) @ module.require (module.js:466:17) @ require (internal/module.js:20:19) @ object. (/ho i think there change in structure in 1.x, dont know, can help? the correct way require app module in electron v1.0.0+ is: const { app } = require('electron'); the same applies other built-in electron module require directly.

python - Django CSRF Error PW Reset and Login -

i'm using django.contrib.auth.views password reset. i csrf error when try submit password change form. it lets me enter email, sends me link uidb64 , token, , lets me enter new password twice. when submit password_reset_confirm form csrf invalid error. here template password reset confirm: <div class="reset-page"> <h3 class="reset-header">{% blocktrans %}reset password - step 2 of 2{% endblocktrans %}</h3> <form class="login-form" action="" method="post"> <div class='form'> {% csrf_token %} {% if validlink %} <input id="id_new_password1" name="new_password1" type="password" class="text-login" placeholder="password" /> <input id="id_new_password2" name="new_password2" type="pass...

ios - CoreData Sort by relation -

Image
my relation shown on picture below. i'd sort events first in active promotion , start date. promotion active if current date between start , end date. unfortunately, because of coredata, i'm not able use transient properties sorting. in controller i'm not using fetch controller. is there way achieve that? update: i've following sort descriptors: // first incorrect [nssortdescriptor(key: "promotion.start", ascending: false), nssortdescriptor(key: "start", ascending: true)] predicates (they're ok, though): let promotionspredicate = nspredicate(format: "(%@ >= promotion.start && %@ <= promotion.end) && " + "(any promotion.cities.id == %@)", nsdate(), nsdate(), objectid) let eventspredicate = nspredicate(format: "start >= %@ && venue.city.id == %@", nsdate(), objectid) let subpredicates = [eventspredicate, promo...

java - GWT - XSS prevention and rendering safe/simple html -

i know best ways prevent xss in gwt app while still providing way users edit , view custom html (for ex. rich text editor). specifically, if user tries store evil hidden code in public entity meant viewed html other users, make sure evil html not executed. example: <img src=a onerror="alert('evil');"> <br> <b>test1</b> <font>test2</font> in code, allow <br> , <b> , <font> tags , <img> , want strip javascript. tried testing safehtml utility classes but: safehtmlbuilder , safehtmlutils escaping tags (so form first name, last name, not when rendering text rich text editor right?) , simplehtmlsanitizer has few allowed tags. my question is, there way achieve in gwt (protecting "good" users "bad" when rendering html) or must text processing should done on server-side ? this htmlsanitizer for. simplehtmlsanitizer might bit simple use case can serve basis build own. ...

ios - Core animation (size change) with autolayout challenge -

Image
i have piece of core animation use of 2 methods in order give appearance object growing in size centre-outwards existing location... (1) viewdidlayoutsubviews() self.imageview.frame = cgrectmake(187, 249, 0, 0) which in centre of screen imageview object (2) viewdidappear() - animation block of duration 1 second. e.g. uiview.animatewithduration(1.0, delay: 1.5, options: [], animations: { self.imageview.frame = cgrectmake(16, 70, 343, 358) }, completion: nil) which puts object want show in full size, specific screen size. when use x , y coordinates cgrectmake (...) on iphone size i'm looking work fine, when try on simulator different screen sizes, doesn't work in conjunction autolayout constraints, overrides existing constraints. question(s)... is there way of making animation work centering proportional screen size somehow, rather explicit coordinates , sizes? via cgrectmake...? (...which seems show clash between use of autolayout , a...

How to properly run a npm script with arguments -

i've written small command line program nodejs , want able type npm run test , run program arguments below. typing following command directly works, node.exe scrappee.js -u 'https://github.com/matutter/{}' -us 'cloggie, airrocks-flightcontroller' -s '$commit=li.commits > > span, $sha=.right .commit-tease-sha' -pm .\test\example_parse_module.js but contents of package.json follows there no output whatsoever. "scripts": { "test" : "node.exe scrappee.js -u 'https://github.com/matutter/{}' -us 'cloggie, airrocks-flightcontroller' -s '$commit=li.commits > > span, $sha=.right .commit-tease-sha' -pm .\\test\\example_parse_module.js" } how can command npm run test run scrappee.js script these arguments? the issue single quote ' being converted "'" npm when arguments forwarded, solution replace them double quotes below. "test" : "node.exe ...

javascript - Weird behavior on a test im desigining -

this posted has been updated previous post few hours earlier... i trying make multiple choice test rpg website. 14 questions, , each 1 has 8 answers. each of 8 answers corresponds 1 of set of 8 variables, upon submission user clicks radio buttons, ends adding points proper variable. at point comparison run spit out proper results. the problems had earlier have been solved , have been erased, didnt want start new thread on same topic. current problem: i have pieced code: (the full code below) // go through questions , add +1 each checked // input value = "monk" $('#test').on('click', function() { $('input[name^= "answer"]:checked').each(function(){ if ($('input[name = answer]:checked').val() == "monk"){ secondaryresults.mnk++; console.log(secondaryresults); } }) now above works perfectly, doesnt work if try same exact line of code switiching value , variable++...

ios - addSubview not showing view -

i'm trying add uitextview cell following code: func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier("message_cell" , forindexpath: indexpath) as! displaymessagecollectionviewcell let messagetextview: uitextview = { let textview = uitextview() textview.font = uifont.systemfontofsize(18) textview.text = chat_m[indexpath.row].text textview.backgroundcolor = uicolor.clearcolor() return textview }() cell.addsubview(messagetextview) cell.backgroundcolor = uicolor.lightgraycolor() return cell the problem is not visible on screen. have added using storyboard, problem occurred : uitextview in collectionview wrapping

Perl using a variable to reference a module messes up passing parameters -

i have problem when using variable reference module, seems mess passing of variables: toto.pm package toto; use data::dumper; sub print { print dumper(@_); } perl program package main; toto::print('hello world'); print ">>>>>>>>>>>\n"; $package = 'toto'; $package->print('hello world'); and output is: $var1 = 'hello world'; >>>>>>>>>>> $var1 = 'toto'; $var2 = 'hello world'; any advice on how avoid having toto passed first variable? short: observed behavior comes use of -> on package name. the arrow operator used reference or object, reference data structure has been bless -ed class. (or class name, see below.) object or class name quietly passed first argument whole system work. note package in question not define class (objects cannot created it). from arrow operator in perlop "-> " infix deref...

How do I use profiling to find execution time for both SQL and MongoDB query in PHP? -

i'm new php , don't know how use profiling execution time of following queries. mongodb query: $collection = new mongocollection($db,'customers'); $cursor = $collection->find(['customer_id' => intval($id)]); sql query: $s = oci_parse($c, 'select customer_id customers customer_id = :un_bv '); oci_bind_by_name($s, ":un_bv", $_post['customer_id']); oci_execute($s); i tried following code mongodb query print lot of things of know nothing. $db->setprofilinglevel(2); $cursor = $collection->find(['customer_id' => intval($id)]); $response = $db->system->profile->find(); foreach($response $obj) { print_r($obj); } help me on how use profiling execution time only. in general can use microtime() in php test execution time of piece of code, in case 2 queries. see: http://php.net/manual/en/function.microtime.php

css - How can I config workspace in chrome? -

Image
i'm trying activate workspace tool local project. want apply css changes on codes when edit them browser. i've added folder, perfix url , path of project chrome this: but still there isn't change in codes when change browser, what's wrong? here steps map local workspace server path, using example: click "add folder" in workspace settings, , navigate working directory. click "allow" in bar @ top grant chrome permissions. add mapping between server , path load url , navigate sources tab. open file , start editing. if save cmd + s (mac) / ctrl + s (windows / linux), changes persisted in workspace. you can read more information official documentation here , shows how add directly sources panel. read limitations section, in case trying isn't supported.

PostgreSQL: How to revalidate CHECKs -

my database has following structure: create type instrument_type enum ( 'stock', ... 'currency', ... ); create function get_instrument_type(instrument_id bigint) returns instrument_type language plpgsql stable returns null on null input $$ begin return (select instr_type instruments id = instrument_id); end $$; create table instruments ( id bigserial primary key, instr_type instrument_type not null, ... ); create table countries_currencies ( ... curr bigint not null references instruments (id) on update cascade on delete cascade check (get_instrument_type(curr) = 'currency'), ... ); as can see, use 1 common table instruments. there lot of foreign keys referencing table. tables countries_currencies require referenced item 'currency'. since can't use subqueries in check constraints, have use function. 1 day happen 1 bad man change instrument_type 'currency' else. if ...

java - Processing on iOS with Intel's Multi-OS Engine -

i looking way develop ios apps java. java because want able use processing java library. first found robovm. find out microsoft did shut down after bought xamarin. found intel's multi-os engine, technical preview right now. looks can develop android app used java , android studio. rewrite ui (and ios specific api calls) , build ios. either on mac xcode or in intel's build cloud (which seems free). using processing in android apps not new thing (even if new me). looks ios apps it's different. since have rewrite ui ios, not sure if it's still possible use processing same way. if that's not possible wonder if possible/a idea call loadpixels() @ end of draw function, read pixel values , write them ios ui element. use cpu power every single frame or solution if there's no other way? of couse give me ui output processing. somehow still have touch events processing if want handle events there. in jquery can not register callback event $("#mybutton")...

About the usage of files with a .BUILD suffix in Bazel -

recently, i'm studying bazel following tutorial in http://www.bazel.io/docs/tutorial . have known usage of build files, i'm still confused usage of files having .build suffix, e.g. when involved in building process, syntax , differences between them , build files (though similar). since cannot find documents introducing ".build" files either on above link or googling, explain usage of ".build" files me, or provide me references? in advance! the documentation bazel concepts @ http://www.bazel.io/docs/build-ref.html , part on build files @ http://www.bazel.io/docs/build-ref.html#build_files

Is Cassandra jdbc still actively supported? -

looking through apache cassandra page , other linked cassandra documentation, emphasis seems on cql , there no references jdbc. cassandra jdbc still under active development? google search 'cassandra jdbc' turns few things, none appear connected apache or datastax. if using cassandra jdbc, 1 using? thanks progress datadirect's cassandra driver supports following: datastax enterprise 4.6 , higher apache cassandra 2.0 , higher you can find more information on here: https://www.progress.com/jdbc/apache-cassandra or https://www.progress.com/jdbc/datastax-enterprise hope helpful. let me know if have specific questions.

java.AWT - setSize() method -

i facing issue using setsize() method in below program. error : method setsize(int,int) not defined type frame. when see java api, "class frame" has method inherited class java.awt.window. have instantiated frame class, object should have setsize() method frame derived class of window. why getting error then? how can derived class doesnt contain superclass method? public class awtprac{ public static void main(string[] args) { frame fm = new frame("java programm"); button b= new button ("click here"); fm.add(b); fm.setvisible(true); fm.setsize(300,300); fm.dispose(); } } take code import java.awt.frame; public class awtprac { private static void init(){ frame fm = new frame("java programm"); fm.settitle("awtprac"); fm.setsize(300,300); fm.setvisible(true); } public static void main(string[] args) { init(); } }

java - android 4 onCreateDialog return type incompatible when overriding -

the code below won't compile. understand when doing override, replacement class must match signature of original class exactly, think i'm following example android documentation carefully. error messages: overrides android.app.activity.oncreatedialog return type incompatible activity.oncreatedialog(int) oncreatedialog() method: @override protected dialog oncreatedialog(int id) { switch (id) { case 0: alertdialog.builder builder = new alertdialog.builder(this); builder.seticon(r.drawable.ic_launcher) .settitle("this dialog stupid message...") //more code here setting additional properties ); return builder.create(); } } you need default return block in switch or return after switch. can return null in cases.

python - Grouping of all possible combinations of points taken m at a time into r groups -

i want group possible combinations of points taken m @ time r groups. points = [a,b,c,d........] total n points combinations of these points taken m @ time list l l = list(itertools.combinations(points,m)) how can further group r groups such i-th element of each group has no similar points. for example, points = [a,b,c,d] m = 2 , r = 2 l = [[a,b],[a,c],[a,d],[b,c],[b,d],[c,d]] so groups be group 1 = [[a,b],[a,c],[a,d]] , corresponding group 2 = [[c,d],[b,d],[b,c]] note : points in i-th index of group 1 , group 2 have no similar points. i want n number of points taken m @ time , grouping r groups. please provide me algorithm. also note when number of points increases, possible combinations increase if want more 2 groups. this tough problem! i've implemented naive brute force solution. slow it's starting point. from itertools import combinations, permutations points = 'abcdef' r = 3 m = len(points) // r ...

2 power of 77 java Powerset -

i have 77 elements n1,n2,n3... etc need calculate superset. used binary mask algorithme number big fit in int. here code: private static vector powerset(string[] set) { //create empty power set vector power = new vector(); //get number of elements in set int elements = set.length; //the number of members of power set 2^n int powerelements = (int) math.pow(2,elements); //run binary counter number of power elements (int = 0; < powerelements; i++) { //convert binary number string containing n digits string binary = inttobinary(i, elements); //create new set vector innerset = new vector(); //convert each digit in current binary number corresponding element //in given set (int j = 0; j < binary.length(); j++) { if (binary.charat(j) == '1') innerset.add(set[j]); } //add new s...

Html and CSS buttons do not function -

hello have website making. have text , buttons on background used work before background added. no longer work. drawn screen not function. @ code minute: <div id = "rect0"> <div class = "banner grid_18" href="about.html"> </div> <a href="logic.html" class="button" id ="new">view article</a> <div class=" grid_8 callout"> </div> <a href="gallery.html" class="button" id ="new1">view gallery</a> </div> when buttons outside div rect0 function when inside not clickable. here's css encase effecting it. #rect0{ position: relative; margin-top: -10px; margin-left: 0px; width: 951px; height: 270px; padding-left: 4px; padding-top: 1px; background: #ffffff; z-index: -1; } .button{ background: #242324; color: #b7b7b7; padding: 6px; color: white; font-size: 11px; text-transform: uppercase; ...

const - How can I return imutable reference types without break constness? -

i have following code in d: import std.stdio; import std.container.array; class reftype { } class mycontainer { private array!reftype test; reftype result() const { // want const on this, not on return type return test[0]; // use opindex() array(t) // error: cannot implicitly convert expression (this.test.opindex(0u)) // of type const(reftype) main.reftype } } int main(string[] argv) { auto c = new mycontainer; auto r = c.result(); return 0; } as can see want return reference type custom container class. opindex() of array not giving permission that, why? i think opindex() should return reftype instead of const(reftype) value because array array!reftype . is bug? or design intention? if intented design, how can want? i think opindex() should return reftype instead of const(reftype) value because array array!reftype. no, wrong. when define memthod const , have specified members of class const. means that,...

c# - I am trying to implement search functionality but I am stuck -

these song , playlist models: namespace konacno.models { using system; using system.collections.generic; public partial class song { public int id { get; set; } public string name { get; set; } public string singer { get; set; } public string year { get; set; } public int playlistid { get; set; } public virtual playlist playlist { get; set; } } } namespace konacno.models { using system; using system.collections.generic; public partial class playlist { public playlist() { this.song = new hashset<song>(); } public int id { get; set; } public string playlistname { get; set; } public virtual icollection<song> song { get; set; } } } and inside songcontroller: public actionresult index(string searchby, string search) { var songset = db.songset.include(s => s.playlist); if (searchby...

java - NoClassDefFoundError on JXDatePicker -

Image
on netbeans, fine, when build project, , execute .jar dist folder, fine. when move .jar , execute; cmd gives me it points on declaration of jxdatepicker have .jar containing jxdatepicker on library project please; , thanks as found out, can happen due problem in runtime. project run fine in compile time error occures in runtime.as said first build , run , worked fine.after moved .jar file , run again.this time jar @ different directory , jvm still looks previous location .if want can reset calsspath this. for more reference set classpath=axis.jar;%classpath%; hope help!

within a dictionary, how do I remove a value from a key with multiple values? Python -

from collections import ordereddict def main(): dictionary = ordereddict() dictionary["one"] = ["hello", "blowing"] dictionary["two"] = ["frying", "goodbye"] key in dictionary: print key, dictionary[key] user_input = raw_input("remove buildings ending ing? y/n") if user_input == ("y"): print "" key in dictionary: x in dictionary[key]: if ("ing") in x or ("ing") in x: del dictionary[key][x] print "" key in dictionary: print key, dictionary[key] main() i attempting remove item "ing" in keys within dictionary, example "blowing" key "one" , "frying" key "two". the resulting dictionary go this: one ['hello', 'blowing'], 2 ['frying', 'goodbye'] to this: one ['...

ios - heightForRowAtIndexPath Not working properly -

i trying display image correct aspect ratio in tableview. have pre-calculated aspect ratio of image, , seems work on actual image, not on cell displayed in. code image in cell: private var cellimage: uiimage? { { return cellimageview.image } set { cellimageview?.image = newvalue if let newimage = newvalue { heightconstraint.constant = newimage.size.width / cgfloat(aspectratio) } } } code in tableview: override func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat { return tableview.bounds.size.width / cgfloat(aspectratio) } aspectratio variable same in both. aspectration = width/height of image. also, checked see height received in both places same, , same value (in runtime). anyone know why cell height not set correctly? you can use dynamic cell height , make cell fit imageview inside check tutorial https://www.raywende...

.net - WCF service works in WCF Client but not in IIS -

i have wcf service uses microsoft.synchronization.syncagent synchronize database on windows ce device. works great when run service visual studio 2008 when host in iis (using windows 10 way), sync fails targetinvocationexception. if browse service http://192.168.1.34:8711/inventorycachesyncservice/inventoryservicelibrary.inventorycachesyncservice.svc expected "you have created service." page, if use http://192.168.1.34:8711/inventorycachesyncservice/wtf endpoint service mentioned (as url client web reference) 404 error - although url works fine when hosting in visual studio's wcf test client. have tried every alteration can think of url in win ce client i'm getting nowhere. i'm new wcf services, i'm missing incredible simple. here's web.config file: web.config please me out if have ideas. thanks! you can below steps host wcf in simple steps goto properties of application in visual studio click on web tab select radio button "...

javascript - Regex working when embedded in CSHTML page but not when moved to an external JS file -

disclaimer. i've eliminated possibility of wrong linkage, incorrect regex etc. already. particular issue isn't duplicate questions. please, kindly take minute read whole before jumping premature dupe flags. it's else basic issues. please give me credit hours spent googling it. thanks. i noticed inherited lot of pages embedded explicit javascript, decided clean , move script external files. when i'm done, of things seems working except single thing , that's regular expressions. in fact, weird part of them still work expected while others fail. so when have following set directly in page: <script src="~/scripts/account.js" type="text/javascript"> $(function(){ var emailregex = /^[a-za-z0-9._-]+@@[a-za-z0-9-]+\.[a-za-z]{2,6}$/; function isemailvalid(){ return emailregex.test($("#email").val()); } }); </script> @using (html.beginform("register", "account", formmethod.post)) { <div> ...

android - Execution failed for task ':processDebugAndroidTestManifest' sdk:minSdkVersion 1 cannot be smaller than version 7 -

i want add achievements , xp simple game basegameutils of google play services shows error :- error:execution failed task':basegameutils:processdebugandroidtestmanifest'. manifest merger failed : uses-sdk:minsdkversion 1 cannot smaller version 7 declared in library [com.android.support:appcompat-v7:20.0.0] c:\users\admin\desktop\android-basic-samples-master\freexpandlevelup\basegameutils\build\intermediates\exploded-aar\com.android.support\appcompat-v7\20.0.0\androidmanifest.xml suggestion: use tools:overridelibrary="android.support.v7.appcompat" force usage here android manifest.xml :- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.org.superhuman.freexpandlevelup"> <uses-permission android:name="android.permission.internet" /> <uses-sdk ...

swift - Why is my fetchRequest returning nil? -

my fetch request returning nil entity think i've put data , after hours , hours of debugging, haven't been able figure out. (disclaimer: i've looked @ countless threads here on talk fetch requests , unwrapping options every 1 found how deal unwrapping error. i'm asking figuring out why fetch request isn't returning record when believe should.) in view controller i'm going display data, have in viewwillappear: class liftlogtableviewcontroller: uitableviewcontroller { var managedobjectcontext: nsmanagedobjectcontext! var liftevents = [liftevent]() override func viewwillappear(animated: bool) { super.viewwillappear(animated) let fetchrequest = nsfetchrequest(entityname: "liftevent") { if let results = try managedobjectcontext.executefetchrequest(fetchrequest) as? [liftevent] { liftevents = results <---- nil error happening here } } catch { fatalerror("error fetching data!...

javascript - Extending builtin objects in TypeScript on Netbeans with plugin -

i trying transcript existing javascript code typescript , ran problem extending builtin objects object.defineproperty , e.g. string.prototype . object.defineproperty(string.prototype, 'testfunc', { value: function():string {return 'test';} }); var s1:string = 'abc'.testfunc(); // property 'testfunc' not exist on type 'string' var s2:string = string.prototype.testfunc(); // property 'testfunc' not exist on type 'string' object.defineproperty(object, 'testfunc', { value: function():string {return 'test';} }); var s:string = object.testfunc(); // property 'testfunc' not exist on type 'objectconstructor' it gets translated javascript, however, netbeans 8.1 typescript plugin claims errors listed comments above. all of confused experiments declare , interface did not match proper syntax. have no idea how work. how can extend builtin objects in typescript , make...

How Gmail API's Quota Units Work? -

according gmail's api docs , limits follows: api limit type limit daily usage 1,000,000,000 quota units per day per user rate limit 250 quota units per user per second, moving average (allows short bursts) in table further below, docs messages.get costs 5 quota units. in case, interesting in polling inbox every second check new messages, , contents of messages if there any. question 1 : mean i'd spending 5 quota units each second, , i'd under quota? question 2 : how should check "new" messages? is, messages have arrived since last time made api call? need add "read" labels messages after each api call (spending quota units on "modify" api call), or there easier way? question 1: that's right. spend (5 * 60 * 60 * 24 =) 432000 quota points on polling, near limit. implement push notifications if want google notify of new messages rather polling yourself. question 2: listing messages has undocumented feature ...

Java How use Spring Autowired in SystemInitializer class -

i have java project spring mvc . need start timertasks after application initialized, implemented webapplicationinitializer interface , call systeminitializer . inside class have @autowired property, @autowired property dao class. need cause want execute tasks based in recordings data base. autowired property ever null. public class systeminitializer implements webapplicationinitializer { @autowired private domainresearchdao domainresearchdao; @override public void run() { if (this.domainresearchdao != null) { system.out.println("ok"); } // here else{ system.out.println("no ok"); } } you can not use @autowired inside of webapplicationinitializer . your beans not ready (not scanned yet) injected. application has no idea domainresearchdao @ moment. spring can autowire beans after application initialized , (singletone) instances ( @component , @service etc.) created. if want job after application start...

java - How to convert bitrates to megabytes -

i grouping ipaddress , date , have bitrate column. want convert bitrate (3600) mb.this how calculate not sure if correct. //5 5 seconds per every row. need add every row. seconds += 5; megabytes+=(3600 * 5 * 1000); // result 18000000 kbits how convert mb? 3600 bps = 450 bytes per second. 450*5 = 2.25 mb per row on 5 seconds. slow raw communications ok @ server level when consider parsing , other pre-processing needed extract data.

python - How can I cache API data in a class attribute? -

i have class, similar 1 below, can use property access data api. able cache data period of time, though, may access attribute rapidly without being ratelimited. cleanest way implement functionality? from requests import class githubuser: def __init__(self, user): self.user = user print("{user} has {repos} public repos!".format( user=user, repos=self.public_repos )) @property def _api_data(self): return get( "https://api.github.com/users/{user}".format(user=self.user) ).json() @property def public_repos(self): return self._api_data["public_repos"] here's 1 way make neat (it may seem overcomplicated it's not really): from uuid import uuid4 datetime import datetime class cached_descriptor(object): def __init__(self, func, timeout): self.__doc__ = getattr(func, '__doc__') self.func = func self.uuid = str(...

html - JSTL forEach and if code not executing properly -

i wrote code assignment appears not executing properly. <c:if test="${counter<fn:length(passangername[status.index])}"> <c:redirect url="confirmbooking.jsp" > <c:param name="error" value="invalid data. please try again!"/> </c:redirect> </c:if> i printing counter values check if loop working fine or not , during first iteration, seems work fine counter value not being printed in second iteration , forth. know second iteration takes place because can see other stuff printing. result "if" part @ end not working why needs fixed. note: else besides working fine. doing wrong here? please help! additional note: code working fine if inputs alphabets instance, saurav or john if second input combination of alphabets , numbers, code not work. <c:set var="alphaupper" value="${['a','b','c','d',...

ios - Make UIScrollView work only on content part, not "sides" -

Image
here's scroll view (it gray area). content area yellow. notice insets, can scroll sides of content on middle of screen. problem: can put finger on gray area , scroll it. i want work can scroll putting finger on yellow content. if put finger on gray "background" , try scroll it, nothing should happen. how this? yellow content scrolled right, rests here: yellow content scrolled left, rests here: make subclass of uiscrollview . give reference yellow view. override pointinside:withevent: return false unless point in frame of yellow view. class myscrollview: uiscrollview { @iboutlet var yellowview: uiview? override func pointinside(point: cgpoint, withevent event: uievent?) -> bool { return yellowview?.frame.contains(point) ?? false } }

perl - Can Test::Class tests be run in parallel? (or how to factor out superclass tests) -

in tutorials i've read test::class , there seems 1 runner script loads of classes. , think perspective of test::harness 1 giant test. don't think can parallelize tests inside runner. my x problem trying factor out superclass behaviors when testing subclasses. each subclass should have own subclass test (that can parallelized), exercise behaviors inherited superclass. how 1 that? edit: found these 2 posts 2007 seem imply i'm asking incompatible/not possible. update since then? http://www.hexten.net/pipermail/tapx-dev/2007-october/001756.html (speculation test::class support parallelism http://perlbuzz.com/2007/08/organizing-tests-with-testclass.html (implying test::class , test::harness ideologically exclusive) test::class doesn't support parallelisation on own. easiest solution have separate .t runners each of test classes (or logical groups of test classes), , run using e.g. prove -j9 . if want run of tests in parallel write simple scri...

mysql - Sum and order by desc with query builder (laravel) -

Image
i have som results of multiple table, selected $places = place::with(['rates' => function($query) { $query->select('id', 'place_id', 'criterion_id', 'value'); }])->select('id', 'coords')->get(); i need order reslut sum (or avg) of values. how can this? tried use $query->select('id', 'place_id', 'criterion_id', 'value')->sum('value'); but doesn't work. if works you. can use join instead of eager loading. the code this: place::leftjoin('rates', 'places.id', '=', 'rates.place_id') ->selectraw('places.*, sum(rates.value) sumofratevalues') ->groupby('places.id') ->orderby('sumofratevalues', 'desc') ->get();

node.js - How to add a common string in every randomly generated string Javascript -

i generating random strings using below function in node.js. wanted know if there way create text strings appropriately common string within every randomly generated string. edit: common string can in location of generated string for example: randomly generated string - cxqtooxyy4 can add 'abc' or 'abc' within string - cxqtoabcoxyy4 or cxqtoabcoxyy4 respectively. my code - var randomtextarraygeneration = function(size) { var text = ""; var possible = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"; for(var i=0;i<size;i++) text += possible.charat(math.floor(math.random() * possible.length)); return text; } can tell me how do this? helpful. var n = text.length; //the size of random string var randomposition = math.floor((math.random() * n) + 1); //generate random number between 1 , size of string //separate string in 2 strings var text1 = text.substring(1, randomposition); ...

ios - Architecture of a SceneKit game, multiple view controllers for menu screens? -

i'm working on scenekit game using swift, , i'm thinking best way organize various screens/ states surrounding actual main game scene. have simple prototype consists of 3 states: splash screen (choose game type) -> game -> game on screen (choose play again or return splash) in prototype opted go uikit ui elements, rather spritekit overlay. although it's buttons @ moment, easy enough in spritekit, might in future want add sliders (eg options screen set control sensitivity etc), text entry etc, , end recreating great chunks of uikit. so @ present, each of 3 scenes described above has own uiviewcontroller . splash , game viewcontrollers have own scnview s , scnscene s, , gameover modal displays on main game scene. this structure isn't ideal, means main game scnscene gets reloaded whenever viewdidload of gameviewcontroller fires. main scnscene quite detailed takes few seconds load, , repeated cycles seems create memory issues. after 2 cycles of spla...