Posts

Showing posts from September, 2014

javascript - setState of Undefined & User Authentication Error. Tried .bind(this). Tried fatpipe... Can't get it working -

i have 2 problems actually. first thing using componentwillmount or componentdidmount check user return asynchronous goes firebase check current user, , if statement not run there no user. tried solve promise, maybe understanding of promise isn't gave on , tried work inner code. substituted mount componentwillupdate seems run multiple times forcefully bypass error , check if state changed correctly. this leads me second problem. setstate says undefined. i've read on stack overflow , tried use ".bind(this)" , fatpipe, neither working. perhaps i'm putting in wrong place or syntax wrong. can help? import react, { component } 'react'; import search './search' import recipe './recipe' import fire '../fire' //import firebase 'firebase' class favourites extends component { constructor(props){ super(props); this.state = { recipes: [] } } componentdidupdate() {

javascript - Cloud function for Firebase error - function crashed out of request scope -

i saw error 1 of executions of cloud function function killed. error: function crashed out of request scope there no other supporting logs more information on firebase logs console , couldn't find more information error on web. have discussed funtion received error in detail in question . have couple of questions what error mean? there way more information error. tried looking logs in google cloud console function didn't find extra. is there way set alerts when such errors or timeout occurs execution of function? when @ details of function on google cloud console, still says no errors reported function last 7 days. above error has occurred @ least once function , function has timed out few times in last 7 days. such events not considered error events function?

ASP.NET MVC - @Import LESS variables returned from controller -

i attempting return less variables in response asp.net mvc controller method -- @imported body of less file. purpose allow users customize appearance of of multi-tenant web application. this works. public class stylecontroller : controller { // get: style public string index() { var responseless = new stringbuilder(); responseless.appendline("@color1: red!important;"); responseless.appendline("@color2: green!important;"); response.contenttype = "text/css"; return responseless.tostring(); } ... }; the sample.less file imports response of above controller... @color1: yellow!important; @color2: lime!important; h1 { color: @color1; } h2 { color: @color2; } @import (less) url('http://localhost:50274/style/index'); also in bundleconfig.cs, include following include less files... bundles.add(new stylebundle("~/content/less").include("~/content/*.less")); i had define

ruby on rails - ActionMailer before_action is being passed img src's when navigating to new_mailer -

notification controller: class notificationscontroller < applicationcontroller before_action :set_notification, only: [:show, :edit, :update, :destroy] # /notifications # /notifications.json def index @notifications = notification.all end # /notifications/1 # /notifications/1.json def show end # /notifications/new def new @notification = notification.new end . . . private # use callbacks share common setup or constraints between actions. def set_notification @notification = notification.find(params[:id]) end # never trust parameters scary internet, allow white list through. def notification_params params.require(:notification).permit(:name, :email, :subject, :text) end end when new_notification_path link clicked, of prints console started "/notifications/new" ::1 @ 2017-04-06 23:41:03 -0400 processing notificationscontroller#new html started "/notifications/legal2.jpg" ::1 @

android - CommandInvokationFailure: Failed to re-package resources after adding Google Play Games -

help! after plugin google play games, can't build apk anymore. i'm using facebook sdk. commandinvokationfailure: failed re-package resources. c:\android\android-sdk\build-tools\24.0.0\aapt.exe package --auto-add-overlay -v -f -m -j gen -m androidmanifest.xml -s "res" -i "c:/android/android-sdk\platforms\android-25\android.jar" -f bin/resources.ap_ --extra-packages android.support.v7.appcompat:android.support.v7.cardview:com.facebook:com.facebook.android:com.google.example.games.mainlibproj:com.unity3d.player:com.google.android.gms.ads.impl:com.google.android.gms.ads:com.google.android.gms.auth.api:com.google.android.gms.auth:com.google.android.gms.base:com.google.android.gms.base:com.google.android.gms:com.google.android.gms:com.google.android.gms.drive:com.google.android.gms.games:com.google.android.gms.nearby:com.google.android.gms.tasks:android.support.v4:android.support.v4:com.teratomocorp.panicchase:com.unity3d.ads.android -s try delete

html - Filter the values using angular js -

i have web application have many forms have created using bootstrap modal. in application have search textbox filter button. when adding text , filter list per result (for filter using ng-click=search('f') . result has edit , delete buttons each. when open result data editing(using edit button) close top right "x" button ng-click = reset() called , filtered values go off. i want the filtered values remain after open files edit , close it. code confidential can put code "x" button <button type="button" class="close" data-dismiss="modal" aria-hidden="true" data-ng-click="reset()">&times;</button> the code search filter button is: <button class="btn btn-primary" type="button" id="btnfilter" ng-click="search('f')"> &nbsp;&nbsp; filter &nbsp;&nbsp;

java - how can I convert keystore file to pem -

Image
use openssl generate 3 file and use keystore generate 2 file can transform each other

Android parse String into StringDef -

i have declared @stringdef in code : @stringdef({notificationaction.displayed, notificationaction.content_clicked, notificationaction.action_clicked, notificationaction.dismissed}) @retention(retentionpolicy.source) public @interface notificationaction { string displayed = "displayed"; string content_clicked = "contentclicked"; string action_clicked = "actionclicked"; string dismissed = "dismissed"; } how parse new string notificationaction without individually comparing each of them? in enum, can directly use valueof function. couldn't find similar here. it seems cannot else implementing it. did following. public class job { @intdef(value = { status.stopped, status.started, status.new }) @retention(retentionpolicy.source) @interface jobstatus { } public static class status { public static final int stopped = 0; public sta

How to get formId of leadgen webhook on facebook? -

i have created webhook tracking of leads on facebook page. need formid of lead logs shown below. [field] => leadgen [value] => stdclass object ( [ad_id] => 0 [form_id] => 2.6147643765585e+14 [leadgen_id] => 2.6356365078047e+14 [created_time] => 1491489109 [page_id] => 4.3192338381483e+14 [adgroup_id] => 0 ) [form_id] shown 2.6147643765585e+14 actual formid different.i think in encoded form right? how formid in decoded form, mean original formid "field" => "leadgen", "value" => array( "leadgen_id" => 123123123123, "page_id" => 123123123, "form_id" => 12312312312, "adgroup_id" => 12312312312, "ad_id" => 12312312312, "created_time" => 1440120384 ) thanks in advance..

java - Issues with reversing objects in a LinkedList -

i'm writing code assignment requires method reverses elements in linkedlist, given portion of list reverse. example, if user enters 3 method reverse first 3 elements in array. i've written code instead of reversing code replaces 2nd element element present in first index. issue seems reversefirstsome method. i'm not asking write code me, pointer in right direction appreciated. here full code class: import java.util.nosuchelementexception; public class linkedlist { //nested class represent node private class node { public object data; public node next; } //only instance variable points first node. private node first; // constructs empty linked list. public linkedlist() { first = null; } // returns first element in linked list. public object getfirst() { if (first == null) { nosuchelementexception ex = new nosuchelementexception(); throw ex; } else return first.data; } // re

ms access - SQL Server : create record fails when trigger is enabled -

i have old application must support. i'm pushing (hard) replace know management can like. front end in access 97 , has linked tables in sql server 2008 r2 data storage. it has been working smoothly many years , refuse modify it. i have been requested send automatic email whenever new record created in particular table. have been sending emails sql server agent jobs in past thought wouldn't hard send email trigger when record created, avoiding need make changes access97 front end. i have created trigger lots of logging file built in can tell if falls on part way through, doesn't. the error message i'm getting on client "odbc--insert on linked table 'dbo_quote' failed." this table being inserted , 1 trigger. i'll post trigger code here if wants see don't think problem there. little long debugging code in there. to prove works commented out lines this set @masuburb = (select rtrim(masuburb) inserted) and set variables m

visual studio - Display numbers that are divisible by 7 (range 10-25). Calculate and display an average of the numbers that are not divisible by 7 -

so wrote code in visual basic. how can improved? not know how display numbers 14 , 21 in other way. public class form1 private sub button1_click(sender object, e eventargs) handles button1.click dim counter byte = 0 dim accumulator short = 0 dim average single dim loopcounter byte loopcounter = 10 25 if loopcounter mod 7 <> 0 accumulator += loopcounter counter += 1 else label1.text = loopcounter & ", 14"\ end if next average = accumulator / counter label2.text = average end sub end class

sql - redshift to_timestamp() without millisecond -

how convert string 2017-06-20t09:52:33+0000 timestamp 2017-06-20 09:52:33 . tried still got last +00 : select to_timestamp(substring('2017-06-20t09:52:33+0000',1,19), 'yyyy-mm-dd hh24:mi:ss') >> 2017-06-20 09:52:33+00 try: select left(to_timestamp(substring('2017-06-20t09:52:33+0000',1,19), 'yyyy-mm-dd hh24:mi:ss'),19); >> 2017-06-20 09:52:33 this'll work sure. let me know if still face issues.

java - How to show the distance in kilometer on activity using google map in Android -

i trying distance of nearby event location (from google map) , show on activity. not sure button need use show distance , java code show distance in kilometer on activity? if know current latlong or targeted location lat long can find distance using following method. public double finddistance(latlng fromlatlan, latlng tolatlan) { int earthradious = 6371;// radius of earth in km double latfrom = fromlatlan.latitude; double latto = tolatlan.latitude; double lonfrom = fromlatlan.longitude; double lonto = tolatlan.longitude; double difflat = math.toradians(latto - latfrom); double difflon = math.toradians(lonto - lonfrom); double avalue = math.sin(difflat / 2) * math.sin(difflat / 2) + math.cos(math.toradians(latfrom)) * math.cos(math.toradians(latto)) * math.sin(difflon / 2) * math.sin(difflon / 2); double c = 2 * math.asin(math.sqrt(avalue));

Circular reference when calling PHP script from C++ program -

when called php script c++ program called different php script, server crashed. i'm assuming circular reference occurred. i'm using godaddy dedicated server centos 6.9. here first php script (named script1.php): <?php passthru('test_cpp'); ?> here c++ program (named test_cpp) #include "iostream" #include "cstdlib" int main(int argc, char* argv[]) { std::cout << std::system("/usr/bin/php script2.php") <<std::endl; return 1; } here second php script (named script2.php): <?php #!/usr/bin/php echo "hello"; ?> i expect first php script display output of second script. instead, browser displayed hourglass minute, , 2 minutes later mysql database stopped working had restart server.

c - Recursion or extracting a variable -

void base_aux(unsigned int n, unsigned int base, unsigned int x) { zero_int(32 - x); if (n > (base - 1)) { base_aux(n / base, base, ++x); printf("%u", n % base); } else { printf("%u", n); } } void binary_int(unsigned int n) { base_aux(n, 2, 0); } i'm making converter decimal whatever base. have use recursion , need print leading zeros. zeros print without recursing. call in actual function, don't know how incremented x this. please help. zero_int helper function print many zeroes needed. i.e @ moment when attempt convert 1288 decimal 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100001000. what 00000000000000000000010100001000. i see because each recursive

jquery - resourceId not being reset after ajax request -

so select function within fullcalendar, i'm using add appointments calendar. on first appointment add calendar, resourceid variable correct, , appointment gets added in correct position. there on out, time add appointment, gets added under resource, variable never changes resourceid slot clicked on in calendar. select: function(start, end, event, view, resource) { $("#addeventmodal").modal('show'); $("#addappt").submit(function(e) { $("#apptsubmit").attr("disabled", true); e.preventdefault(); e.stopimmediatepropagation(); console.log(resource.id); var formdata = $(this).serialize() + '&start=' + moment(start).format('yyyy-mm-dd hh:mm:ss') + '&end=' + moment(end).format('yyyy-mm-dd hh:mm:ss') + '&resourceid=' + resource.id; $.ajax({ url: '/dentist/db/createappt.php', type: 'post', data: for

javascript - Laravel : Call API Update Database using Ajax -

i have laravel frontend calling api using javascript when onlick on image. having 1 issue, when user clicks fast on 3 img(in sequence:img1->img2->img3), id=img2, updates src correct image, didn't update flag in database frontend blade: <img src="/images/empty1.gif" id="img1" onclick="return changeflags(1,6)"/> <img src="/images/empty2.gif" id="img2" onclick="return changeflags(2,5)"/> <img src="/images/empty3.gif" id="img3" onclick="return changeflags(3,4)"/> javascript: <script type="text/javascript" charset="utf-8"> function changeflags(s9bid, position) { console.log("s9bid: "+s9bid); console.log("position: "+position); var url = "{{env('api_url')}}"; $.ajax({ method: "get", data: { id:s9bid,posit

multithreading - Java ExecutorService:- Notify a thread to wake up when an event occurs -

i have manager class multiple threads register (used uuid generate unique identifiers per requests), gives payload process , corresponding responses manager. using java.util.concurrent.executorservice launch multiple threads. here implementation testing manager functionality- public class managertest { public static void main(string[] args) { try { manager mymanager = new manager(); // start listening messages different threads mymanager.consumemessages(); int num_threads = integer.parseint(args[0]); executorservice executor = executors.newfixedthreadpool(num_threads); (int = 0; < num_threads; i++) { // class implementation given below runnable worker = new myrunnable(mymanager); executor.execute(worker); } executor.shutdown(); // wait until threads finish while (!executor.isterminated()) {

Use a field of a variable inside of a foreach in PowerShell -

so have list of active directory users: $users = get-aduser -filter {enabled -eq "true"} what want group them based on description since have 3 possible descriptions in whole user list. however: can't seem use description field inside of foreach : foreach ($user in $users) { write-host $user.name write-host $user.description } their name shows not description. why this? get-aduser returns specific properties default. description property not 1 of these. ensure returned need use following parameter get-aduser : -properties description "this cmdlet retrieves default set of user object properties. retrieve additional properties use properties parameter." - https://technet.microsoft.com/en-gb/library/ee617241.aspx

GitLab CI - if variable exists set variable -

i'd set dash plus repo tag docker image build if build build of tag, , neither if not, i'll explain... this trivial if wanted set tag if existed because work: build-nginx: stage: build-nginx script: - command docker build -t $ci_registry_image:nginx$ci_commit_tag . - command docker push $ci_registry_image:nginx$ci_commit_tag this create registry.example.com/image:nginx if there no tag , registry.example.com/image:nginx1.0 if there was, how image named registry.example.com/image:nginx-1.0 (with dash), i've have check if tag variable set otherwise i'd end , image called registry.example.com/image:nginx- if tag variable not set.

Polybase performance issues -

i trying connect hadoop clusters (cloudera) polybase 2016. when querying hadoop clusters polybase, performance getting slow. in fact, 50 times slower local sql server tables on same data size. did 1 has worked on improve query performance on polybase? regards, ritu ranjan

c# - Referencing embedded script from an embedded script -

i have 2 embedded resources in assemblyinfo.cs file. [assembly: webresource("custom.inputbox.js", "text/javascript")] [assembly: webresource("custom.jquerycaret102min.js", "text/javascript")] the first file works correctly, when tries reference second file error raised. have added resources in onprerender method: string resourcename = "custom.inputbox.js"; clientscriptmanager clientscriptmanager = this.page.clientscript; clientscriptmanager.registerclientscriptresource(typeof(custom.inputbox), resourcename); resourcename = "custom.jquerycaret102min.js"; page.clientscript.registerclientscriptresource(typeof(custom.inputbox), resourcename); the implementation in inputbox.js file: if (typeof textbox.caret().start == "number" && typeof textbox.caret().end == "number") {//do something} the files have been added "embedded resources. there may missing?

performance - Python 3.6: How to play audio faster -

so, have bit of code print out text in delayed fashion see in old school or indie video games. everything working, not way want to. want printing , playing of sound faster right slow. is there way make possible? here code: note: lags in pycharm works fine in terminal/cmd. import sys import time pydub import audiosegment pydub.playback import play def print_delay(string_in): sound_1 = "text_beep.wav" sound_play = audiosegment.from_wav(sound_1) char in string_in: sys.stdout.write(char) sys.stdout.flush() play(sound_play) if char != ",": time.sleep(0.01) if char == ".": time.sleep(0.20) if char == ",": time.sleep(0.10) print("\n") string_hello = "hello world, sample text.\ni want want print out faster without being delayed sound file.\nis there faster way this?" print_delay(string_hello) woohoo! ok f

c# - How to simulate mouse click AngularJs in the WebBrowser control -

i using webbrowser control in c# load angularjs web page . on page have tag has ng-mousedown event want simulate mouse click on : <a class="im_dialog" ng-mousedown="dialogselect(dialogmessage.peerstring, dialogmessage.unreadcount == -1 &amp;&amp; dialogmessage.mid)"> <div class="im_dialog_meta pull-right text-right"> <div class="im_dialog_date" ng-bind="dialogmessage.datetext">11:22 am</div> <span class="im_dialog_badge badge im_dialog_badge_muted" ng-show="dialogmessage.unreadcount > 0 &amp;&amp; !dialogmessage.pflags.out" ng-bind="dialogmessage.unreadcount" my-peer-muted="dialogmessage.peerid" muted-class="im_dialog_badge_muted">120</span> <i class="im_dialog_unread ng-hide" ng-show="dialogmessage.pflags.out &amp;&amp; dialogmessage.pflags.unread"></i> </di

file management - Alternative of filedepot module in Drupal 7 -

i need file management module user specific upload option. if the file1 uploaded by user a it should not visible on user b loggedin page. tried filedepot module in drupal 7 it's working fine but, listing files on authenticated users loggedin. i change permission on admin filedepot access authenticated user, admin user . so need altenative of filedepot module in drupal 7 . heared webfm module on drupal 6. is there possible use webfm module on drupal 7 . immediate appreciate. thanks in advance.

timezone - Is browser Date#toString time zone reliable -

most browsers can display kind of timezone information: example new date().tostring() returns "fri apr 07 2017 02:20:12 gmt-0500 (cdt)" . however see many solutions not use @ all, instead try guess timezone using several methods. if new date().tostring() return timezone information, correct? or can browsers return wrong info too? the value in parenthesis not defined in ecmascript specification. each implementation decide want show there. thus, value reliable implementation makes it. 1 cannot state in general, other expect inconsistent results. that said, many modern implementations take values same source data, the unicode cldr project , way of icu . give localized text value, such "eastern daylight time" in english. (not "edt" )

wordpress - WPML get translated content of a string from all languages if available -

using wpml, have translated string in 4 languages say: en, nl, fr , de. by default can use <?php _e('my string here','text_domain'); ?> , return exact translated text when in domain. how can translated texts in 1 place. if on english version of website translated content string in nl, fr, de , en. may know how possible? you temporary change current language retrieve translated string. like: // backup current language $current_lang = $sitepress->get_current_language(); // it's "en" // switch language. e.g. $desired_lang = "nl"; $sitepress->switch_lang( $desired_lang ); // translated string... _e( 'my string here', 'text_domain' ); // original language not interfere $sitepress->switch_lang( $current_lang ); i've tested on page template (say index.php ) , works... tried build function job. like: // put in functions.php function get_all_translations( $string, $languages ) { global

saxparser - Can I use startEntity to ask ISAXLexical Handler not to interpret #8804; -

i using isaxlexicalhendler in c++ ask reader not convert character &#8804: "≤" . i trying put output of parser browser browser can understand meaning of character. so created saxlexicalhendler pointer , pass reader along property " http://xml.org/sax/properties/lexical-handler ". but unable hit startentity of saxlexicalhendler when call parse. i hitting code startdtd, enddtd,startcdata unable hit startentity() can have this. here input: <?xml version="1.0" encoding="windows-1252"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=us-ascii" /> <title>xsl fo document</title> </head> <body bgcolor="white" marginwidth="6" marginheight=&qu

objective c - UIAlertAction can't be clicked on iPad -

i created uialertcontroller 3 uialertaction. working in iphone, cant click in of uialertaction's in ipad. working, , didn't made changes in code uialertcontroller *alert = [uialertcontroller alertcontrollerwithtitle:@“select item” message:@“please choose 1.” preferredstyle:uialertcontrollerstyleactionsheet]; [alert addaction:[uialertaction actionwithtitle:@"cancel" style:uialertactionstylecancel handler:^(uialertaction *action) { _logoview.alpha = 1; }]]; uiwindow* window = [[uiwindow alloc] initwithframe:[uiscreen mainscreen].bounds]; window.rootviewcontroller = [uiviewcontroller new]; window.windowlevel = uiwindowlevelalert + 1; nsstring *buttontitle = [sessionarray objectatindex:0]; uialertaction *session1 = [uialertaction actionwithtitle:buttontitle style:uialertactionstyledefault handler:^(uialertaction * _nonnull action) { window.hidden = yes; [self sessionpickerselected:0]

stata - collinearity found in multiple dummy variables in logistic regression -

i have several categorical variables such nationality, office locations etc. since dependent variable binary outcome, logistic regression used. i encountered multiple warning messages these variables omitted due collinearity. in scenario, there methods "treat" these dummy variables able include them in model? there message in stata "convergence not achieved", means model has failed?

math - Rounding away from zero in Javascript -

we building table in javascript handsontable representing currency amounts. give user possibility of render amounts 2 decimal places or no decimal places (it's requirement client). , find things this: column column b column c = + b ------------------------------------------- -273.50 273.50 0 2 decimals -273 274 0 no decimals investigating little came find basic rounding function in javascript, math.round() , works this : if fractional portion 0.5, argument rounded next integer in direction of +∞. note differs many languages' round() functions, round case next integer away zero , instead (giving different result in case of negative numbers fractional part of 0.5). as dealing currency amounts, not care happens after second decimal place, chose add -0.0000001 negative value in table. thus, when rendering values 2 or no decimals, proper results, math.round(-273.5000001) = -274, , math.round(-2

join more than one table in spring jparepository -

i trying fetch record doing join. new spring jparepository. understand there separate repository each entity(table) when implement need define entity , datatype of primary key. could please suggest how can fetch record joining 2 tables. i have 2 repo below: public interface aentityrepository extends jparepository<aentity, integer> public interface bentityrepository extends jparepository<bentity, integer> i want join above 2 entity(aentity, bentity). know can have custom query using below: @query("select ****** aentity ae") aentity findcustomrrecords(); however can write same kind of query (join query) join. need have separate repository implementing other class. can please help. i using mysql. i understand there separate repository each entity(table) this common misunderstanding. not want have repository per entity, per aggregate root. see http://static.olivergierke.de/lectures/ddd-and-spring/ regarding specific problem @ han

directx - CreateBitmapFromDxgiSurface() failed (0x88990003, D2DERR_UNSUPPORTED_OPERATION) -

i want share texture dx11 d2d : // dxgi surface version d3d texture. idxgisurface1* pdxgisurface = nullptr; auto hresult = irisd3dresourcemanager::instance()->getd3d10device()->opensharedresource(hresourcesharehandle, __uuidof(idxgisurface1), reinterpret_cast<lpvoid*>(&pdxgisurface)); if (failed(hresult)) { goto failed_release; } float fdpix = 0.0f; float fdpiy = 0.0f; m_pd2dfactory->getdesktopdpi(&fdpix, &fdpiy); d2d1_bitmap_properties1 dbbp1; dbbp1.dpix = fdpix; dbbp1.dpiy = fdpiy; dbbp1.pixelformat = d2d1::pixelformat(dxgi_format_b8g8r8a8_unorm, d2d1_alpha_mode_premultiplied); dbbp1.colorcontext = nullptr; dbbp1.bitmapoptions = d2d1_bitmap_options_target | d2d1_bitmap_options_cannot_draw; // create shared id2dbitmap1 id2d1bitmap1* pbitmap = nullptr; hresult = m_pd2ddevicecontex->createbitmapfromdxgisurface(pdxgisurface, dbbp1, &pbitmap); however, createbi

multithreading - Calculating factorial using multiple threads in Python -

i use python 2.7 , have task write function calculates factorial using multiple threads. tried using traditional recursive approach, like def factorial(n): if n < 1: return 1 else: return n * factorial(n - 1) but seems way doesn't suite multithreading. there ways calculate factorial using multiple threads? in multi-threading applications best minimize data dependencies exists between different threads. in recursive solution factorials have mentioned hard find calculations not depend on results of other calculations. a distinct approach split factorial in multiple parts. example, 2 threads 1 this: n! = [1 * 2 * 3 * .. * (n/2)] * [(n/2 + 1) * ... * n] the first thread calculate value: v1 = 1 * 2 * 3 * .. * (n/2) the second thread calculate: v2 = (n/2 + 1) * ... * n and afterwards, when both threads finished, main thread compute n! = v1 * v2 . this can generalized use k threads splitting input factorial k different parts

android - How to getSharedPreferences in Application? -

i tried call getsharedpreferences in application... public class app extends application{ public app() { sharedpreferences prefs = getsharedpreferences(shared_preferences_name, context.mode_private); } } ...but got nullpointerexception : java.lang.nullpointerexception: attempt invoke virtual method 'android.content.sharedpreferences android.content.context.getsharedpreferences(java.lang.string, int)' on null object reference i tried , got same exception: context con = getapplicationcontext(); how can call getsharedpreferences ? override oncreate() , in app, @override public void oncreate() { super.oncreate(); and there. don't forget declare application subclass in androidmanifest well. e.g. <application android:name="app"

regex - extraction perl -

i have file 1.txt below content f1,f2,[as1,as2],[as3,as4] f3,f4,f5,[as5,as6] i require write regex in perl should change delimiter ',' inbetween [' , '] | . i tried below, did not work. @qr = $st = /\{(.*)(\|)+\}/; where $st has input string. for versions of perl older perl 5.14, can't use regex like echo "[as1,as2,as3],[as4,as5]" | perl -lpe 's/(?:\[|\g(?!^))[^]]*?\k,/|/g' see online demo . pattern details : (?:\[|\g(?!^)) - either literal [ or end of previous match ( \g(?!^) ) [^]]*? - 0 or more chars other ] , few possible, matched \k - whole match value dropped , - comma lands in match (that replaced | ). for perl version 5.14 , newer ( where r modifier appeared ), may match [...] substrings \[[^][]+] regex (that matches [ , 1+ chars other [ , ] , , ] ) , perform replacements inside these matches: echo "f1,f2,[as1,as2],[as3,as4]" | perl -lpe 's/(\[[^][]+])/$1=~s#,#|#gr/ge'

java - String cannot be applied to com.org.apache.xpath.internal.operations.String -

i'm trying create piechart in javafx, , want fill data hashmap . here's code: public graph(hashmap<string, double> chartdata) { observablelist<piechart.data> piechartdata = fxcollections.observablearraylist(); (map.entry<string, double> entry: chartdata.entryset()) { string s = entry.getkey(); new piechart.data(entry.getkey(), entry.getvalue()); //system.out.println("key = " + entry.getkey() + ", value = " + entry.getvalue()); } chart = new piechart(piechartdata); chart.settitle("imported fruits"); } the issue facing when try use entry.getkey() string, following error: data (java.lang.string, double) in data cannot applied (com.org.apache.xpath.internal.operations.string, double). the string marked red , when replace entry.getkey() "some text" work. cause? you seem have imported wrong "string" class ( com.org.apache.xpath.internal.op

linux - How to remote access the CouchDB on google cloud compute instance -

i trying access remote couchdb server failed. hope can me. have done far: install couchdb on ubuntu 14.04 https://www.digitalocean.com/community/tutorials/how-to-install-couchdb-and-futon-on-ubuntu-14-04 modify local.ini file, bind address 0.0.0.0 now. i think maybe problem of firewall , know nothing how configure it, pls help. regards

javascript - Invalid key path in IndexedDB: restrictions? -

i'm trying create simple indexeddb javascript, fails in on handler already. apparently browser (chrome 57) not able parse keypath (in basic concepts ) of storage. i'm following more or less these simple examples: mdn or opera-dev . suppose want store objects 1 in db: { "1": 23, // unique id "2": 'name', "3": 'description', "4": null, "5": null } here code: var sstorenodes = 'nodes'; var sidfieldnode = '1'; // important part // event fired creating db , upgrading version request.onupgradeneeded = function(event) { var db = event.target.result; // create objectstore nodes. unique key should id of node, on property 1. // id key! var objectstore = db.createobjectstore( sstorenodes, { // changing plain string works, if valid identifier , not strigified number 'keypath' : [ sidfieldnode ],

Python - How to import module from .so file from egg file without using an absolute file path -

i built pyahocorasick library python setup.py bdist_egg command , uploaded onto spark pyspark job. however, .so file inside pyahocorasick can't imported through pkg_resources.resource_filename() method on spark cluster security reasons. traceback (most recent call last): file "spark_datawash.py", line 251, in <module> import ahocorasick file "build/bdist.linux-x86_64/egg/ahocorasick.py", line 7, in <module> file "build/bdist.linux-x86_64/egg/ahocorasick.py", line 4, in __bootstrap__ file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1152, in resource_filename file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1696, in get_resource_filename file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1726, in _extract_resource file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1219, in get_cache_path file "bui

c# - compilationWin32Exception when building Windows Store App in unity3D -

hello trying build windows store app in unity3d(unity 5.6.0f3). when following these steps: https://developer.microsoft.com/en-us/windows/mixed-reality/holograms_230 at scanning step when need build app following 2 errors in unity: == could not start compilationwin32exception: applicationname='c:\program files\unity\editor\data\tools\roslyn\corerun.exe', commandline='"c:\program files\unity\editor\data\tools\roslyn\csc.exe" /noconfig @temp/unitytempfile-5ed7a9a146122744fb2017a810d85b49', currentdirectory='' system.diagnostics.process.start_noshell (system.diagnostics.processstartinfo startinfo, system.diagnostics.process process) system.diagnostics.process.start_common (system.diagnostics.processstartinfo startinfo, system.diagnostics.process process) system.diagnostics.process.start () (wrapper remoting-invoke-with-check) system.diagnostics.process:start () unityeditor.utils.program.start (system.eventhandler exitcallback) (at c:/buildsla

Create a SQL-like Sequence in Clickhouse -

i have sql query having sequence in it. how can create sequence create in sql in clickhouse? clickhouse don't support sequences postgresql or other rdbms use case? you need insert data incremented sequence ? for? or need sequencematch , sequencecount functions funnel analyze? may it's url helfull https://clickhouse.yandex/reference_en.html#sequencematch(pattern)(time,+cond1,+cond2,+...)

classpath - Log4j2.xml monitorInterval not working -

hi using log4j2 , have written log4j2.xml file under src/main/resources i have added attribute <configuration monitorinterval="60"> but doesn't work. how add file classpath using intellij. i have included following in pom.xml under build tag: <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> you should update log level in target/classes/log4j2.xml instead of src/main/resources/log4j2.xml update: here's test , works me test.java public class test { static final logger logger = logmanager.getlogger(); public static void main(string[] args) throws interruptedexception { while (true) { logger.info("info"); logger.error("error"); thread.sleep(1000); } } } log4j2.xml <?xml version="1.0" encoding="utf-8"?> <configuration monitorinterval="5"> <appe

gerrit - Can I be notified when "merge conflict" appears on my change? -

let assume have several changes in review state in gerrit. can notified (via email) when "merge conflict" appears on 1 of changes? have nice day, adam you can't receive information e-mail (unless wrote script automate task using rest) have other options: search field you can use search feature search following: owner:username , status:open , not is:mergeable this show open changes conflicts. my menu you can add menu entry search showed above @ settings > preferences > my menu adding following url: #/q/owner:username+and+status:open+and+not+is:mergeable

navigation - Routing with parameter not working UI5 -

since days i`m stucked parameter based navigation overview- detailpage. navigation working fine values of detailpage not being displayed in detailpage (showobject). think somehow related binding in detail controller. please find codesnippets attached: manifest.json "routes": [ { "pattern": "showobject/{code}", "name": "showobject", "target": "showobject" }, overview.controller.js triggered navigation clicking selecting line item , clicking on edit button. result value of column "code" (e.g. "abc"). oneditbuttonpressed:function() { var otable = this.getview().byid("idtable"); var ocode = otable.getselecteditem().getbindingcontext("model").getproperty("code"); var orouter = this.getownercomponent().getrouter(); orouter.navto("showobject", {