Posts

Showing posts from September, 2012

javascript - JS - Google charts - Cannot read property 'getChartLayoutInterface' of undefined -

i've encountered issue in i'm given console error of: cannot read property 'getchartlayoutinterface' of undefined i've read on other questions , i've seen it's because google vizulation api has not loaded, code following: <script type="text/javascript"> // load visualization api , piechart package. google.charts.load('current', {'packages':['corechart']}); // set callback run when google visualization api loaded. google.charts.setonloadcallback(drawchart); function drawchart() { var jsondata = $.ajax({ url: "assets/main/getfrontdata.php", datatype: "json", async: false, type: 'post', }).responsetext; var data = new google.visualization.datatable(jsondata); var options = { backgroundcolor: 'none', linewidth: 4,...

sql - Add different number for every row in a table -

i have flat table fake customer information (name, address, gender,...). added column flat table called customer_id of values null. i'm trying add different id every customer i'm not sure how achieve that. i've done far, don't have primary key table since want customer_id primary key alter procedure [dbo].[add_id] begin declare @customer_id int declare cursor1 cursor select customer_id flat_customer open cursor1 fetch next cursor1 @customer_id while(@@fetch_status = 0) begin if(@customer_id null) begin exec get_next_id_by_name 'customer', @customer_id output end fetch next cursor1 @customer_id end end i'm still beginning in sql i'm not sure how parse trough row row just this: declare @i int = 1; update flat_customer set customer_id = @i, @i=@i+1;

html - Why does my menu not go all the way to the left -

Image
i'm new coding sorry if i'm doing here stupid. i'm building basic website using html , css. want use 2 navigation bars. 1 on top of screen main navigatio. , 1 on left side navigating through specific page.the first 1 works fine second 1 looks weird. clickable links can't moved further left , therefore sticking out on right. mean: i'm hovering mouse on "content2" what doing wrong? here code wrote: <body> <nav> <ul class="navbar"> <li class="navbar"><a class="navbar active" href="index.html">home</a></li> <li class="navbar"><a class="navbar" href="page1.html">page 1</a></li> <li class="navbar"><a class="navbar" href="page2.html">page 2</a></li> <li class="navbar"><a class="na...

express - How to GET json data from API with a header -

i'm trying json data api using nodejs , express, requires header i'm not sure how input header request. the documentation says: curl -h"x-fullcontact-apikey:$your_key" 'https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com' how do add request header? looked everywhere on stackoverflow days, , havent found anything. php, nothing nodejs w/ express. how can request node npm manager package not sure on how request code looks like, should it; right? var request = require('request'); var options = { url: 'https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com', headers: { 'x-fullcontact-apikey': '$your_key' } }; function callback(error, response, body) { if (!error && response.statuscode == 200) { var result = json.parse(body); console.log(result); } } request(options, callback);

ios - Xcode "Cannot convert return expression of type 'String' to return type 'Float'" -

i trying create bmi calculator takes user's height , weight inputs calculates bmi; there, uses series of if-else statements return message user states if healthy/over/underweight. have no problem getting program return calculated bmi value; when incorporate if-else statement, "cannot convert return expression of type 'string' return type 'float'" error. here's code (i've done 1 if-else statement far): import uikit func bodymassindex (userheight : float, userweight : float) -> string { let userheightsquared = (userheight*userheight) let userweight = userweight let userbmi = (userweight/userheightsquared) return userbmi if userbmi > 25 { return "overweight" } } print(bodymassindex (userheight : 1.82, userweight: 90.7)) you have wrap float value of userbmi string . func bodymassindex (userheight : float, userweight : float) -> string { let userheightsquared = (userheigh...

templates - Decide when to 'templateUrl' of AngularJS directive in the link function -

is possible decide whether use templateurl parameter in link function of angularjs directive? suppose have following directive: app.directive('sitesandimprovements', function() { return { restrict: 'e', replace:true, templateurl: '<path-to-file>/site-and-improvments.html', link: function (scope, elem, attrs) { scope.testclick = function() { var myscope = scope; //debugger; } scope.constructioncompleteclick = function () { if (scope.construction_complete == 'yes') { scope.hold_back = ''; scope.percent_complete = 100; } else if (scope.construction_complete == 'no') { scope.hold_back = '1'; if (scope.percent_complete == 100) { scope.percent_complete = ''; ...

testing - Test cases for Binary Search Tree (BST) remove function using linked lists C++ -

question: test cases should use test remove function? my thoughts: case 1: delete when no element in system. case 2: delete when there 1 element in system. case 3: delete when left side of tree empty. case 4: delete when right side of tree empty. first, third, , fourth test cases fine. should cover case both left , right children present , both not present there more 1 element. remove need second test case. what should out way reorder tree when have deleted item. should continue follow whatever order tree structured in. i'm not sure mean "using linked lists"?

android - Current Location(on Google Maps API) not showing in app -

this question has answer here: how can show current location on google map on android marshmallow? 2 answers we have google maps api working; however, current location not show in our app show when redirected google maps(app). want blue dot show in our app , not when forwarded google maps(app). here code snippets (we using android studio v2.3.3): can offer guidance, please? here our mapactivity.java package com.example.administrator.bubbleproject; import android.manifest; import android.content.pm.packagemanager; import android.support.v4.app.activitycompat; import android.support.v4.app.fragmentactivity; import android.os.bundle; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.onmapreadycallback; import com.google.android.gms.maps.supportmapfragment; import com.google.a...

c# - Remove hacks from my odata generic base Controller? -

i have created genericcontroller move crud logics genericcontroller, , hacked stuff make work like: create tablefort set entity create interface indexedmodel hold guid make compraion hard code db context how can remove hacks code keep code clean? namespace airvinyl.api.controllers { public class genericcontroller<t> : odatacontroller t : class, indexedmodel { airvinyldbcontext db = new airvinyldbcontext(); private bool exists(long key) { return tablefort().any(p => p.id.equals(key)); } private dbset<t> tablefort() { return db.set<t>(); } protected override void dispose(bool disposing) { db.dispose(); base.dispose(disposing); } [enablequery] // enablequery allows filter, sort, page, top, etc. public iqueryable<t> get() { return tablefort(); } [enablequery]...

Can we use Kendo.observable with angular2 -

i have angular 2 kendo ui project needs create dynamic forms using json returned server. want know can have kendo.observable in angular2 kendo supports javascript. or can suggest me make our life easier building app :)

linux - Building Wireshark on Ubuntu from source -

while trying build wireshark on ubuntu 16.04 source code, encounter error after running ./configure : error: /home/yoyo/anaconda3/bin/lrelease -qt=5 -version returned non-zero exit status any suggestions? you appear have python installed in home directory via anaconda. set via path variable in .bashrc (or anaconda installer did) try editing .bashrc , removing you're using ubu system defaults. run failing command manually see if work or if have problem. $ /usr/bin/lrelease -qt=5 -version lrelease version 5.5.1

swift - Hide back button -

i'm working on 1st real game. have 2 view controllers. 1st 1 has animated picture, , player can enter there names. 2nd 1 displaying game. after game on player can play again or reset. reset takes them 1st vc can give new names. question how hide reset until need it. put there made button , command dragged 1st vc , selected show. thanks information might able give me. if using ios predefined button try this:- navigationitem.hidesbackbutton = true or if have dragged , drop uibarbutton create outlet , hide/show accordingly.

amazon web services - Ansible AWS: Unable to connect to EC2 instance -

what want achieve i want create ec2 instance lamp stack installed using 1 ansible playbook. problem the instance creation works fine, , can modify in ec2 console, problem appears when trying access instance example install apache or create keys. this error: fatal: [35.154.26.86]: unreachable! => { "changed": false, "msg": "[errno none] unable connect port 22 on or 35.154.26.86", "unreachable": true } error screenshot code this playbook: --- - name: power ec2 lamp stack installed hosts: localhost become: true become_user: root gather_facts: false vars: keypair: mykeypair security_group: launch-wizard-1 instance_type: t2.micro image: ami-47205e28 region: x-x-x tasks: - name: adding python-pip apt: name=python-pip state=latest - name: install boto library pip: name=boto - name: launch instance (amazon linux) ec2: key_name: ...

playframework - Displaying a list of checkboxes in my form -

i want display many checkboxes inline like: <label class="checkbox-inline"> <input type="checkbox" id="inlinecheckboxa" value="optiona"> </label> <label class="checkbox-inline"> <input type="checkbox" id="inlinecheckboxb" value="optionb"> b </label> <label class="checkbox-inline"> <input type="checkbox" id="inlinecheckboxc" value="optionc"> c </label> so have form like: val form: form[searchform] = form( mapping( "letters" -> list(text) ) )(searchform.apply)(searchform.unapply _) can somehow pre-populate form data or have pass variable view has 'letters' data? val letters = list[string]("a", "b", "c", ...) if can't pass letters val down view, guess pass variable model , iterate on it? have looked @ helper inputcheckboxgr...

.net - The connection with the server was terminated abnormally (AWS S3 file upload) -

using following code upload gzip file s3: class program { public static awscredentials credentials; static program() { var chain = new credentialprofilestorechain(); if (!chain.trygetawscredentials("awsconfig", out credentials)) throw new exception("aws credentials not found!!"); } static void main(string[] args) { var filepath = $@"c:\temp\test.gz"; uploadfile("mybucket", filepath, "test"); } private static void uploadfile(string bucketname, string filepath, string prefixkey) { transferutility filetransferutility = new transferutility(new amazons3client(credentials, amazon.regionendpoint.useast1)); transferutilityuploadrequest filetransferutilityrequest = new transferutilityuploadrequest { bucketname = bucketname, filepath = filepath, key = prefixkey, }; filetransferutili...

-label:pinned works in Gmail but not in the Google Apps Script GmailApp.search() function? -

the following gmail / inbox gmail search returns in inbox pinned. in:inbox label:pinned and returns unpinned inbox messages. in:inbox -label:pinned side note: though messages "pinned" in inbox gmail, , not gmail, search still works expected in both web apps. the following google apps script logs pinned emails. function getunpinnedemails() { var threads = gmailapp.search('in:inbox label:pinned'); (var = 0; < threads.length; i++) { message = threads[i].getmessages()[0]; subject = message.getsubject(); logger.log(subject) } } however, following google apps script logs all inbox emails including pinned messages . function getunpinnedemails() { var threads = gmailapp.search('in:inbox -label:pinned'); (var = 0; < threads.length; i++) { message = threads[i].getmessages()[0]; subject = message.getsubject(); logger.log(subject) } } gmailapp.search('in:inbox not label:pinned') ...

html - Bootstrap customizing accordion -

i creating accordions using bootstrap, each accordion uses following div: <div class="panel-group" id="accordion"> and each header uses: <div class="panel-heading"> <h4 class="panel-title"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseone">heading</a> </h4> </div> using css, how can style text white instead of black? put style="color: white" inside tag of each header, have use accordion many times , headers should have white text. best way override default black text? you can use class selector achieve same. refer below css <style> .panel-title a{ color: white !important; } </style>

Couldn't Cast Value of Type UIButton: Swift -

Image
i getting error of cannot cast value of type uibutton in console. thing not uibutton, label would 1 know why? looks viewwithtag(2) not label . check if adding button programmatically inside cell , setting tag value 2 . also try avoid forced unwrapped if possible prevent crash guard let questionlabel = cell.viewwithtag(2) as? uilabel else {return} questionlabel.text = "yourvalue

mysql - Laravel adding parameter with raw queries using Like operators and '%" -

i did ways assign parameter it's not working here code: $sqldefault = "select * histories h h.status % :status %"; return db::select(db::raw($sqldefault), ['status' => $status]); it's not working try ways assign: '%:status%' or '%':status'%' but it's not work now don't use parameter , it's worked perfectlly $sqldefault = "select * histories h h.status '%$status%'"; the question how can use parameter when using operator "%" ? replace $status '%'.$status.'%' $sqldefault = "select * histories h h.status :status "; return db::select(db::raw($sqldefault,['status' => '%'.$status.'%'])); or use select only: return = db::select(sqldefault , ['status' => '%'.$status.'%']);

Data security concern with downloaded extensions of Qlik sense -

i'm using qlik sense , love it, have been using nice extensions downloaded internet. today, tried https://www.vizlib.com/protected/downloads , looks good, somehow checked & have user log-ins on qlik server check licenses. raised me concern if downloaded extensions of qlik sense secure, data, information on qlik app might @ risk extensions. thanks!

javascript - Call Java Script function if $POST or cookie is emtpy? -

i want call java script function called expandregisterform() if conditions apply: if ( isset( $_post['billing_first_name'] ) && empty( $_post['billing_first_name'] ) ) { //call expandregisterform() } if ( isset( $_post['billing_last_name'] ) && empty( $_post['billing_last_name'] ) ) { //call expandregisterform() } if ( isset( $_post['billing_phone'] ) && empty( $_post['billing_phone'] ) ) { //call expandregisterform() } if ( isset( $_post['billing_address_1'] ) && empty( $_post['billing_address_1'] ) ) { //call expandregisterform() } if ( isset( $_post['billing_postcode'] ) && empty( $_post['billing_postcode'] ) ) { //call expandregisterform() } if ( isset( $_post['billing_city'] ) && empty( $_post['billing_city'] ) ) { //call expandregister...

linux - Why can't ld find libcurses.so even though it is in `/usr/lib` directory? -

on arch linux , when build something, ld complains can't find curses library: /usr/bin/ld: cannot find -lcurses collect2: error: ld returned 1 exit status but /usr/lib indeed contains curses related library: # ls -lt /usr/lib/libcurse* lrwxrwxrwx 1 root root 13 may 29 14:50 /usr/lib/libcurses.so -> libncurses.so -rw-r--r-- 1 root root 18 may 29 14:50 /usr/lib/libcursesw.so # ls -lt /usr/lib/libncurse* -rw-r--r-- 1 root root 20 may 29 14:50 /usr/lib/libncurses++.so lrwxrwxrwx 1 root root 18 may 29 14:50 /usr/lib/libncurses++w.so -> libncurses++w.so.6 lrwxrwxrwx 1 root root 20 may 29 14:50 /usr/lib/libncurses++w.so.6 -> libncurses++w.so.6.0 -rwxr-xr-x 1 root root 77264 may 29 14:50 /usr/lib/libncurses++w.so.6.0 -rw-r--r-- 1 root root 18 may 29 14:50 /usr/lib/libncurses.so -rwxr-xr-x 1 root root 444776 may 29 14:50 /usr/lib/libncursesw.so.6.0 lrwxrwxrwx 1 root root 16 may 29 14:50 /usr/lib/libncursesw.so -> libncursesw.so.6 lrwxrwxrwx 1 ...

java - Image click of RecyclerView -

i know there questions on this,but format follow code different unable find answer question. when click on recyclerview item includes textview , imageview, want show image in detailactivity. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/framelayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="pritish.sawant.com.photogallery.mainactivity"> </framelayout> fragment_photo_gallery.xml <relativelayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="m...

excel vba - create a macro to cut a row on sheet1 based on the "False" criteria in the same row of sheet3 -

i new macros have managed create 1 using record macro function not work scenario i have workbook paste rows of data 2 tables in different sheets , have table in 3rd sheet checks if corresponding cells match i.e. sheet1 j3 matches sheet2 j3 rec table show "true" i put in macro using record macro sort both tables same columns in line each other if have same data rows, issue 1 side have more rows other because have include data rows may not required report , after sorting these can end anywhere in table , throw out data doesn't match properly to desired results work manually , start top of sheet2 (it table has rows) , cut out first row has multiple "false" readings , paste bottom of sheet2 data, mean rows below 1 until next data row match "true" i repeat until rows of data @ bottom of sheet 2 , above should matching can me put in macro cut , insert row paste, have 1 one ensure rows below cut 1 allowed match before looking next "false...

Neo4j configure path to java 8 -

how configure neo4j default path java_home other path? current server has java 6 installed , applications depend on it. need configure neo4j java 8 folder without changing java_home. how do this? while try , fix scripts depend on java_home : installation_directory/bin/* on linux installation_directory\bin\neo4j-management\get-java.ps1 on windows your best bet i.m.o override java_home in session start neo4j. if you're using package installations on linux, should set java_home override in environment of neo4j user (that should not impact other softwares). hope helps, regards, tom p.s. fact running other applications on same machine neo4j may not idea if we're talking production environment (it's not idea environment in fact).

java - Traversing anonymous/blank nodes in Jena -

i using apache jena's api, graph contains anonymous/blank nodes well, due unionof , intersectionof. 1 of such example is: <owl:class> <owl:unionof rdf:parsetype="collection"> <rdf:description rdf:about="http://www.summyurl.com/something#entity1"/> <rdf:description rdf:about="http://www.summyurl.com/something#entity2"/> </owl:unionof> </owl:class> which anonymous node/resource. when try uri, like: "-50a5734d:15d839467d9:-1b8b" i neither able sparql query using such uris (due exception on parsing such uris), nor able find appropriate jena method handle it. i looking way explode such nodes , nested resources of it. for example in below case, should return <http:/.../entity1> , <http:/.../entity2> , <http:/.../entity3> <owl:class> <owl:unionof rdf:parsetype="collection"> <rdf:description rdf:about="http://www...

android - Problems with "Google Play App Signing" -

when first published app on google play, did not interact , enabled "google play app signing". now i'm dealing serious problem , want disable it, unfortunately not possible. when wanted remove app google play , publish again without "google play app signing", realized google not allow removal of published program. how can solve problem , publish app signature? please me my problem google signing want disable it unpublish first , remove.

plot - Matplotlib Wavy Arrow -

Image
is there way create 'wavy' arrow in matplotlib / python please? ideally, i'd recreate following: to reproduce wavy arrow question, may use line plot , triangle import numpy np import matplotlib.pyplot plt import matplotlib.path mpath import matplotlib.patches mpatches fig, ax = plt.subplots() x = np.linspace(0,9*np.pi,151) y = np.sin(x) ax.plot(x,y, color="gray", lw="3") verts = np.array([[0,1],[0,-1],[2,0],[0,1]]).astype(float)*1.3 verts[:,0] += 9*np.pi path = mpath.path(verts) patch = mpatches.pathpatch(path, fc='gray', ec="gray") ax.add_patch(patch) ax.axis("off") ax.set_aspect("equal",'datalim') ax.relim() ax.autoscale_view() plt.show()

Why 'delete' will not work with local variables in javascript ? -

here code (function(x){ delete x; return x; })(1); even after deleted variable x , still work , return value 1. is delete work object property , global variables? the delete operator only used deletion of properties on object . cannot leveraged delete variable-- nor there use cases in javascript such thing necessary. can set variable null or undefined substitute.

How to get input field value without using form in Python -

i need 1 help. need fetch input field value using python , field not inside form using name/id attribute. explaining code below. home.html: {% extends 'base.html' %} {% block content %} <center><h1>welcome</h1></center> <input type="hidden" name="id" value="{{sid}}"> {% endblock %} views.py: def home(request): """ function provides home page .""" pers = user.objects.get(pk=request.session['id']) user_name = pers.uname return render(request, 'bookingservice/home.html', {'username': user_name, 'count': 1,'sid':request.session['sid']}) here need hidden field value compare request.session['sid'] within if statement . please me. try this pers = user.objects.get(pk=request.post.get("id")) may you

How to create a executable jar file for Sabre red app plugin to install same plugin on others machine without using eclipse -

i new comer develop sabre red app using eclipse ide. have created sample plugin using eclipse on srw environment. need create executable jar file (or installer file)for sample sabre red app plugin can install app on others machine , shouldn't require eclipse ide. my sample plugin app running in machine using eclipse. want install app on others machine well. please advise how can achieve this. in order distribute created red app end users of sabre red workspace, have submit sabre certification. when comes distribution, can either public or private apps. private sabre red apps apps unique agency’s needs , available agency. not visible users browsing red app centre marketplace. more information can found here: https://www.sabreredappcentre.sabre.com/rac/about/overview.aspx

c++ - Shorten If Statement And Making It Less Redundant -

new here. wondering if it's possible make if statement shorter , less redundant. if (!a && b) { if (c == d && e > 0) { return; } } else if (a && !b) { if (c != d) { return; } } else if (!a && !b) { return; } here's i've ended with if ((!a && b && c == d && e > 0) || (a && !b && c != d) || (!a && !b)) { return; } all did join nested if statements && operator, , if - else if statements || operator. i'm stuck, possible make shorter? if share tips or way of approaching kind of scenario, i'd glad hear out. neither of approaches readable. better create function indicates kinds of checks performing. if ( !my_very_sensible_special_conditions_are_met(a, b, c, d, e) ) { return; } after that, whether use first approach or second approach in implementation of function less of issue.

machine learning - how to do Classification based on the correlation of multiple features for a Supervised scenario -

i have 2 features: 'contact_last_name' , 'account_last_name' based on want classify data: logic if 2 features same i.e. contact_last_name same account_last_name - result 'success' or else 'denied'. so. example: if contact_last_name 'johnson' , account_last_name 'eigen' - result classified 'denied'. if both equal - 'edison' - result 'success'. how, can have classification algorithm set of data? [please note discard high correlation columns on here correlation between columns seems have logic classification] i have tried use decision tree(c5.0) , naive bayes(naivebayes) in r both of these fail classify dataset correctly. first of not use case machine learning, because can done string match, still if want give classification algorith, create table values 'contact_last_name' , 'account_last_name' , 'result' , give decision tree , predict third column. note partition data traini...

android - Getting 0 item in beacon list in BeaconStream sdk -

below method in getting 0 item in beacon list. in "onbeaconsdiscovered" methods list size 0. manager.setbeaconstreamranginlistener(new beaconstreammanager.beaconstreamranginglistener() { @override public void onbeaconsdiscovered(beaconstreamregion beaconstreamregion, hashmap<integer, list<beacon>> list) { if (!list.isempty()) { beacon nearestbeacon = list.get(0).get(0); list<string> places = placesnearbeacon(nearestbeacon); log.d("airport", "nearest places: " ); } else { toast.maketext(beaconactivity.this, "no beacon found", toast.length_short).show(); } } });

ISOWeek error in SQL Server 2008 -

my problem sql server 2008. if execute: select dbo.isoweek(getdate()) i error msg 4121, level 16, state 1, line 1 cannot find either column "dbo" or user-defined function or aggregate "dbo.isoweek", or name ambiguous. running same command on database gives me expected response: "30" is there cause this? there no built in sql server function called isoweek , database you're running query in (where works) have user defined function called isoweek present? a syntax work built-in, using datepart function is: select datepart(iso_week, getdate()) which return 30 @ time of writing, i.e. if call with: select datepart(iso_week, '2017-07-28 00:00:00.000')

python - Windows command for merging multiple files in single file based on filename -

i trying merge multiple .dlt extension file types 1 works fine me using below command os.system('type *.dlt > finaldlt.dlt') there 2 problems me while trying merge thousands of files in 1 somehow type command doesn't work , skips merging. my .dlt file names coming different sources names a. tyre.dlt b. wiper.dlt c. engine.dlt , want merge these specific file single 1 tyre_all.dlt , wiper_all.dlt , engine_all.dlt tried doing os.system('type tyre*.dlt > finaldlt.dlt') not working. p.s. running windows command python 2.x

why spark still slow than mysql? -

i trying work apache spark data source mysql. have cluster having 1 master , 1 slave node , both have 8 gb ram , 2 cores submitting sql query spark using spark-shell , table having 6402821 many rows. performing group by onto table. , time taken mysql 5.2secs , using spark when performing query time 21secs . why happening? i setting configurations partitioncolumn, upperbound, lowerbound, , numofpartitions still no change. i have tried executing query using 1,2,4 cores time taken spark same 21secs . is problem occurs because of mysql database on single machine , spark nodes try query on data onto single machine? can 1 me solve issue? the database having table called demo_call_stats on trying query is: val jdbcdf = spark.read.format("jdbc").options( map("url" -> "jdbc:mysql://192.168.0.31:3306/cmanalytics?user=root&password=","zerodatetimebehaviour"->"converttonull", "dbtable" -> "cmanalyti...

elixir - Can't reproduce "start/loop" behaviour in GenServer -

i'm trying use process synchronisation mechanism can receive messages our of order still act properly. i've managed implement simplified version of problem plain process, i'm failing achieve same effect genserver. the simplified version this: defmodule fun def start_link spawn(fn -> loop(:initiated) end) end def loop(state) receive :join when state == :initiated -> io.inspect("handling join") loop(:initiated) :finish when state == :initiated -> io.inspect("finishing") loop(:finishing) :cleanup when state == :finishing -> io.inspect("cleaning up...") end end end the above process :join , :finish messages when state :initiated , , perform :cleanup , exit when :finish has been received. here i'm trying take advantage of messages being stuck in mailbox until can matched. it works this: iex(1)> pid = fun.start_link #pid<0.140.0...

javascript - How to make following clone function accept more than one param? -

i'm building simple clone function: function clone (value) { return json.parse(json.stringify(value)) } the problem need also: json.parse(json.stringify({}, object)) and: json.parse(json.stringify({}, value, object)) how modify clone fuction accept additional params without breaking it? one of uses of .apply method on function call array of arguments. can use solve problem. function clone(...args) { return json.parse(json.stringify.apply(null, args)) } if need support browsers not support spread operator , , can't use build tool whatever reason, can use arguments instead. note arguments deprecated function clone() { return json.parse(json.stringify.apply(null, arguments)) }

python - Trouble selecting a certain element -

i've written css selector select specific element webpage. upon execution can see selector able locate "genre:" want it's value in case "drama". how can ? i've tried with: .mdif li b elements within item is: <div class="mdif"> <ul> <li><b>genre:</b>drama</li> <li><b>quality:</b>1080p</li> <li><b>screen:</b>1920x1080</li> <li><b>size:</b>1.67g</li> <li><b>rating:</b>6.1/10</li> <li><b>peers:</b>17</li> <li><b>seeds:</b>0</li> </ul> <a href="/movie/55000/download-lake-mungo-2008-1080p-mp4-yify-torrent.html" class="small button orange" target="_blank" title="download lake mungo (2008) 1080p yify torrent">download</a> if have correctly been able understand question...

push notification - How to generate google-services.json for new android project? -

i trying implement push notification in android app using gcm. seems gcm deprecated , fcm in place new apps. whenever trying go google console redirects me firebase console generating configuration file. there way ca use old gcm new app ? if possible, how can generate configuration file ? thanks

javascript - Testing the redux store using Jest -

i've set following function configure redux store const configurestore = (initialstate) => { console.log(initialstate); const store = createstore( rootreducer, initialstate, applymiddleware( thunkmiddleware ) ); console.log(store.getstate()); return store; }; now, running normal app entry point, console logs show, example: -> initial state = { test: "test" } -> (store gets created) -> store state = { test: "test" } thats good, , expected. i'm trying confirm behaviour following jest test it("should set supplied initial state", () => { const initialstate = { teststate: "test" }; const store = configurestore(initialstate); expect(store.getstate()).toequal({ teststate: "test" }); }); this test failing, store.getstate() returning undefined. can see console logs configurestore function, , showing: -> initial state = { test: "te...

algorithm - Sorting and Selecting an almost sorted array -

given array of length n each item has distance of @ log(n) final position in sorted array, how efficiently sort it, , how find k-th valued item (select-k)? this starting ideas: for sorting, using comparison model can there approximately o((logn)^n) possible permutations, therefore max-depth of comparison tree should o(nloglogn) . also, select problem, have intuition if @ range of logn each side of k-th item ( 2logn - 1 ), can use deterministic selection algorithm in o(logn) , i'm not sure how prove correctness of method. please note i'm not looking code (in language), sketch of abstract algorithm , time complexity it. thanks. use minheap of length x=log(n) start beginning , push elements heap , accordingly after x insertions find smallest element , continue on scan other elements. complexity - o(n(log(x))) = x*log(x)(for heap operations first x elements) + (n-x)(log (x))(for remaining elements) x=log(n); you can identify k-th value on ...

Removing duplicate rows from table in Oracle -

i'm testing in oracle , populated table sample data, in process accidentally loaded duplicate records, can't create primary key using of columns. how can delete duplicate rows , leave 1 of them? use rowid pseudocolumn. delete your_table rowid not in (select min(rowid) your_table group column1, column2, column3); where column1 , column2 , , column3 make identifying key each record. might list columns.

java - Data validation with JOptionPane -

Image
i want perform data validation while joptionpane.i found following approach not satisfied it import javax.swing.*; import java.util.regex.*; public class validatejoptionpane { public static void main(string[] args) { string input = joptionpane.showinputdialog("enter number: "); pattern p = pattern.compile("[a-z,a-z,&%$#@!()*^]"); matcher m = p.matcher(input); if (m.find()) { joptionpane.showmessagedialog(null, "please enter numbers"); } } } it have been better , more sensible use regex detect characters can entered rather testing characters can't entered. is there better , simpler way data validation joptionpane ? . feel regex overkill here.correct me if wrong:p p.s beginner java the long answer is, use documentfilter , see implementing document filter , documentfilter examples more details. the problem is, need take contro...