Posts

Showing posts from May, 2013

gmail api - Topic is created on cloud pub/sub but unable to create watch on that topic -

i want create watch on cloud pub/sub topic unable create it. i'm using rest request request_req.post({ url:'https://www.googleapis.com/gmail/v1/users/me/watch', headers:{ 'content-type': 'application/json', 'authorization': 'bearer '+ access_token, }, scope : [ 'https://mail.google.com/' ], 'body': json.stringify({ 'topicname' : "/projects/projectid/topics/topicid", 'labelids' : ["inbox"] }); }),function(error, resp, body){ }); but i'm getting error message error sending test message cloud pubsub/projects/projectid/topics/topicid : resource not found resource=topicid the google cloud pubsub topic must exist in same google console project, being used authenticate users. check /projects/ projectid /topics/ topicid project in google console , make sure pubsub topic exists. also, must grant access gmail services publish messages pubsub topic vi

c++ - "unsigned :(number)" and Unions -

this question has answer here: what colon in struct declaration mean, such :1, :7, :16, or :32? 3 answers i dont know whats mean "unsigned :5", for example if create these: int a:8; unsigned b:8; is b integer? and question: in union these values: union { long quad; long duble; char byte; struct { unsigned :16; unsigned :16; unsigned :16; unsigned :15; unsigned bit1:1; } bits; }pes; pes.quad=0x12345678; pes.duble=0xabcd; pes.byte=0xef; pes.bits.bit1=1; why in adress is: ef ab 00 00 cc cc cc cc i thought ef ab 34 12 00 00 00 80 the : introduces bit field , value in struct of particular logical type actual size measured in bits. useful defining structures access individual bits of value (e.g. extract flag bits word). for example, defining unsigned b:5; unsigned c:3;

google chrome extension - What is the name of the language in which the main program of Chromium is written? -

we develop new plugin chromium. to achieve goal, must learn @ least 1 computer language. we not know / name(s). do know name of computer language in written program contains 1) variable value @ time t url resources of chromium browser of mister x connected @ time t; 2) variable value @ time t text resources chromium browser of mister x connected @ time t. assembly? c? c ++? java? python? do know how find names of these variables in source code of chromium ? documentation designed developers of software ? thank much. sincerely, naomi , sophie chromium written in c++11. can view source on https://chromium.googlecode.com includes c++11 style guide: chromium c++11 style guide in git chromium c++11 style guide in html

bash - Doubts with for loop in Unix -

sorry if sounds dumb i'm studying exam apply job (administrative one) , learnt java , php , python not unix scripts. can see it's similar php in structure , have many questions . one of them loop, , why output b* ? for var in b* echo $var done i tried code , terminal output b* , why code answer me text (in case, b* ) or else happen? a loop in shell scripting takes each whitespace separated string input , assigns variable given, , runs code once each value. in case b* input , $var assigned variable. the shell perform expansion on input. basically, * acts wildcard part of file name. if have files beginning b in current directory, looped over: $ ls bean.java bean.class readme.txt $ var in b*; echo $var; done bean.java bean.class if don't have files beginning b (so pattern b* doesn't match anything) pattern remain unexpanded: $ rm bean.* $ ls readme.txt $ var in b*; echo $var; done b*

vb.net - how can i insert into? my error is no value given for one more required parameters -

my error no value given 1 more required parameters. fields new,rev1,rev2,rev3,rev4,rev5 need convert date . cmd.commandtext = "insert [sheet] ([empno],[empname],[projectname],[sheetno],[title],[new],[rev1],[rev2],[rev3],[rev4],[rev5) values (empno ='" _ & txtempno.text & "',empname ='" & txtemp1.text _ & "',projectname = '" & txtpro.text & "',sheetno = '" _ & txtdrawing.text & "',title = '" & txtdesc.text _ & "', _ new = cdate('" & date1txt.text & "'), _ rev1 = cdate('" & date2txt.text & "'), _ rev2 = cdate('" & date3txt.text & "'), _ rev3 = cdate('" & date4txt.text & "'),_ rev4 = cdate('&q

scalaz - Scala flattening an Option around a higher kinded type, looking for a more idiomatic approach -

given higher kinded type m, , monad type class, can operate on values within m through for-comprehension. working function return options, im looking more appropriate way flatten these options solution have. follows class test[m[+_]:monad](calc:calculator[m]) { import monad._ def dosomething(x:float):m[option[float]] = { { y:option[float] <- calc.divideby(x) // divideby returns m[option[float]] z:option[float] <- y.fold[m[option[float]]](implicitly[monad[m]].point(none))(i => calc.divideby(i)) } yield z } } so following i'm looking correct: y.fold[m[option[float]]](implicitly[monad[m]].point(none))(i => calc.divideby(i)) also case instead of calling second divideby, call multiplyby returns m[float] y.fold[m[option[float]]](implicitly[monad[m]].point(none))(i => calc.multipleby(i).map(some(_)) maybe case monad transformers im not sure how go it. it seems monad transformers can here. example, following compiles

javascript - Using String.raw() with Node JS -

i'm working on node.js app , use string.raw() part of es 6 standard. however, when using in documentation: text = string.raw`hi\n${2+3}!` + text.slice(2); it returns syntaxerror: unexpected token illegal character after string.raw . i think there problem because string.raw() new technology available chrome , firefox yet. however, can use in node.js , how? the grave character after raw denotes template strings, feature in es6 harmony. can invoke node --harmony flag, feature not yet implemented. reason of syntax error. raw strings unsupported too. if want experimenting feature in server side, check out io.js , fork of node, many es6 features implemented , enabled default.

sql - Retrieving Online Users By Login and Logout Records -

Image
consider userlog table above. save login or logout operation of users table. how can retrieve online users , login time? something this: select * userlog l1 operation = 'enter' , not exists(select * userlog l2 l1.user = l2.user , l2.operation = 'exit' , l2.time > l1.time)

Android Default SMS App permissions kitkat -

after going through lots of codes provided on internet, still unable list sms app in default android kitkat version. don't know whether can done adding permissions manifest file or through .java code. the thing want to, provide me to-the-point code can make new blank project(abc), set code in , should set app (abc) default sms app. you can't directly set app default, nasty security risk. can signal user want status changed , user decide: intent intent = new intent(telephony.sms.intents.action_change_default); intent.putextra(telephony.sms.intents.extra_package_name, activity.getpackagename()); activity.startactivity(intent); however, eligible becoming default sms app, have implement all of functionality required such app, , includes handling of sms/mms related functionality (sending , receiving, notifications, etc). practically means have rewrite complete related functionality of phone, including receivers, intents, filters , code (and should aware sms , m

android - how to open a resource located on my local server on my mobile browser? -

i have file on local server (localhost) on computer. want open file on android phone's browser in same wifi network local computer. how can this? do want programmatically or users point of view? as user: use kind of filebrowser on mobile device , somehow share file (samba, nfs, etc.) on localhost. there dozen ways , hard sugggest best way without knowing setup. in code : on localhost, provide file server based approach. example, set web server host file via http , access file smartphone via http library (okhttp, etc.) or use different protocol fits use case (again, samba or else). for better answer, please provide more information local setup.

c# - An item with the same key has already been added in Dictionary -

i working on sql clr application, after integrating sql, getting error (for english it's working problems while adding unicodes dictionory): **msg 6522, level 16, state 2, line 1 .net framework error occurred during execution of user-defined routine or aggregate "sqlcompare": system.argumentexception: item same key has been added. system.argumentexception: @ system.throwhelper.throwargumentexception(exceptionresource resource) @ system.collections.generic.dictionary`2.insert(tkey key, tvalue value, boolean add) @ system.collections.generic.dictionary`2.add(tkey key, tvalue value) @ translate_class_num..ctor() @ stringpercentagecompare..ctor() @ userdefinedfunctions.sqlcomparison()** here code in c# private dictionary<string, string> mydictionary; //private string[,] myarray; public translate_class_num() { mydictionary.add("?", "01"); mydictionary.add("?", "02"); mydictionary.

android - onDeviceReady never gets called in Cordova app -

i trying run simple page within inappbrowser plugin. running cordova 5.0, , plugin version 1.0. run app splashscreen plugin , seems work fin. default splashscreen runs when app start in app browser plugin not seem work. here code below: <!doctype html> <html> <head> <meta http-equiv="content-security-policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>hello worl

html - Remove Container Sides -

Image
i'm having problems styling page , i'm not sure do. the issue i'm running container class in bootstrap has sizable amount of padding on each side, can't seem reliably remove it. want red background flush against grey image, , have blue in background. way i've been able work around using css property background-clip: content-box begin run issues when start adding things box-shadows. this have right now: this want have: here code: <div class="container content-color"> <div class="row"> <div class="col-md-12"> <img class="img-responsive" src="http://placehold.it/1140x360"> </div> </div> <div class="row"> <div class="col-md-4"> <div class="circle center-block"></div> </div> <div class="col-md-4"> <div c

java - Using an individual String with a JList<String> for an action -

i writing pokedex in java swing , plan have each pokemon represented string in jlist object. upon user clicking pokemon, want open new tabbed panel within main frame holds information specific pokemon sorted categories. can't figure out how string implement action. willing change type of list if fixes problem. current code below: //this intermediate pokedex application windows. code application below. //import needed jlibraries program import javax.swing.*; import java.awt.*; import java.awt.image.*; import java.awt.color; import java.awt.event.*; import javax.swing.uimanager.*; import javax.swing.border.*; import javax.imageio.*; import java.io.*; import java.lang.*; import javax.swing.jradiobuttonmenuitem.*; import java.util.*; import javax.swing.joptionpane; //everything below pokedex class public class pokedex extends jframe { string[] gen1 = {"bulbasaur", "ivysaur"}; jlist<string> gen1list = new jlist<string>(gen1); jscr

javascript - Pagination with alethes:pages using a subscription -

folks. i'm using alethes:pages pagination in meteor app, , i'm needing use existing subscription control data it's displaying. seems way works paginates of records in collection, , not specific stuff want shown. the code i've got far looks this, defining pagination: browsepages = new meteor.pagination(mods, { perpage: 15, sort: { createdat: -1 }, templatename: "browsemodslist", itemtemplate: "browsemoditem", table: { fields: ["name", "category", "createdat"], header: ["name", "author", "category", "date added", "rating", "current version"], class: "table table-striped" }, divwrapper: false, auth: function(skip, sub) { var thecat = categories.findone({slug: router.current().params.slug}); return mods.find({category: thecat._id}); } }); i assuming limit

python - AttributeError: 'HTTPResponse' object has no attribute 'replace' -

hi above error. why pop up, missing , how around ? thanks try: import urllib.request urllib2 except importerror: import urllib2 html2text import html2text sock = html2text(urllib2.urlopen('http://www.example.com')) htmlsource = sock.read() sock.close() print (htmlsource) im running idle 3.4.3 on windows 7 os. html2text expects html code passed in as string - read response: source = urllib2.urlopen('http://www.example.com').read() text = html2text(source) print(text) it prints: # example domain domain established used illustrative examples in documents. may use domain in examples without prior coordination or asking permission. [more information...](http://www.iana.org/domains/example)

swing - Java: What Layout Manager would be best for a game menu? -

=================== game name play exit =================== the above previous game menu looked like. used box layout create tedious. there there better layout manager use? here code asked of main pane. private jbutton jb; private jbutton eb; private joptionpane jo; public startupwindow(){ super("pong"); jpanel outside = new jpanel(); jpanel inside = new jpanel(); setlayout(new borderlayout()); outside.setlayout(new boxlayout(outside, boxlayout.line_axis)); inside.setlayout(new boxlayout(inside, boxlayout.page_axis)); outside.add(box.createhorizontalstrut(280)); outside.add(inside); outside.add(box.createhorizontalstrut(20)); inside.add(box.createverticalstrut(20)); jlabel title = new jlabel(" "+"pong"); title.setfont( new font("serif", font.bold, 40)); inside.add(title); inside.add(box.createverticalstrut(20)); jbutton btt1 = new jbutton("s

Having trouble understanding $$$$(dir $$$$@) in Makefile using eval -

the makefile template follows: # cc compile template, generate rule dep, obj: (file, cc[, flags, dir]) define cc_template $$(call todep,$(1),$(4)): $(1) | $$$$(dir $$$$@) @$(2) -i$$(dir $(1)) $(3) -mm $$< -mt "$$(patsubst %.d,%.o,$$@) $$@"> $$@ $$(call toobj,$(1),$(4)): $(1) | $$$$(dir $$$$@) @echo + cc $$< $(v)$(2) -i$$(dir $(1)) $(3) -c $$< -o $$@ allobjs += $$(call toobj,$(1),$(4)) endef # compile file: (#files, cc[, flags, dir]) define do_cc_compile $$(foreach f,$(1),$$(eval $$(call cc_template,$$(f),$(2),$(3),$(4)))) endef i know eval expand twice, should use $ . why should use $$$$(dir $$$$@) here? have tried understand this, failed. when make parses file, expands. if sees $$ expands $ . $$$$ expand $$ (two dollars). eval, once applied want expand once more $ . need 4 dollars (note $$$ expand $ followed expansion of $( , or whatever next character happens be, likley result in error)

android - Ability to resolve module dependencies dynamically based on version -

backstory: in eclipse, when have multiple projects open pom files (and therefore versions), automatically use local-references if versions match 1 of listed dependencies. if don't match, relies on artifact in repo. (this handy allows live-edits/linking on active versions, while having fixed dependencies on unstable project/dependency versions). question in gradle, there doesn't seem way say i depend on sub-module, version x rather, seems able say i depend on sub-module, don't care version, i'll take current/active one. so, there better syntax regular: compile project(':submodules:submodule1') perhaps like?: compile project(':submodules:submodule1:0.1-snapshot') or compile project('com.mydomain:submodule1:0.1-snapshot') perhaps not want use project references if need depend on particular version. project reference says mentioned in question. more not "i don't care version" rather &q

ios - cannot assign a value of type json to a value of type NSArray -

i trying send info segue following error cannot assign value of type json value of type nsarray when try do: self.pageimages = apiresult["images"] i have apiresult setup as: var apiresult: json! = [] then i'm using alamofire swiftyjson in order fetch result , cast json, need nsarray. my data returned as: { "somedata": { info }, "somedata": { info.. }, "images": [ "url1", "url2", "url3" ] } if apiresult json object returned swiftyjson , if apiresult["images"] array of urls want assign pageimages array variable, have use array property of json typed swiftyjson object: self.pageimages = apiresult["images"].array

VBA Excel auto select space delimited data range for formula use -

fairly new programming. have data in excel delimited empty cell @ top , bottom of each group (example, a1=empty, a2=a number, a3= number, a4= number, a5=empty, a6=a number, a7=a number, a8=empty) pattern repeats thousands of rows. i use vba take sum of numbers between each set of empty cells , place value 6 cells right of top-most empty cell each group. i hand, there ton of data. needs continue until reaches 2 empty cells in row(signifies end of data). in advance here example should help: sub sumgroups() dim long ' rows counter dim j long ' first row of current group, having empty cell dim s double ' summ = 1 ' start row until cells(i, 1).value = "" ' loop first group begin = + 1 ' next row loop j = ' new group start s = 0 if cells(i, 1).value = "" ' empty cell found if j = - 1 exit ' finish if previous cell empty cells(j, 2).value =

javascript - Adding polyines to polylines to create a complex itinerary -

Image
is possible add polylines existing polylines using leaflet without modifying lib? if how should go doing it? in image above can see 2 polylines seem connected, in reality not. ideal solution point of intersection shared point of both polylines. i've thoroughly looked through leaflet documentation , existing plugins, , seems functionality not yet exist. i've thought creating own plugin, how should structure it? thought creating "multiple itinerary handler" handle "connected" polylines. heavy though layers there be?

c# - RoleManager working but UserManager gives "The entity type IdentityUser is not part of the model for the current context." error -

i'm building mvc 5 app using ef6 code first , running issue while trying build basic user management interfaces. error i'm receiving "the entity type identityuser not part of model current context". the code: service layer: public class coreservice { private iprincipal user; private identitydb identdb; private coredb coredb; private rolemanager<identityrole> _rolemanager; private usermanager<identityuser> _usermanager; public coreservice() { user = httpcontext.current.user; identdb = new identitydb(); coredb = new coredb(); _rolemanager = new rolemanager<identityrole>(new rolestore<identityrole>(identdb)); _usermanager = new usermanager<identityuser>(new userstore<identityuser>(identdb)); } public void testidentitymanagers(string rolename, string username) { var role = _rolemanager.findbyname(rolename); var user = _usermanage

python - Best Way to add group totals to a dataframe in Pandas -

i have simple task i'm wondering if there better / more efficient way do. have dataframe looks this: group score count 0 5 100 1 1 50 2 3 5 3 b 1 40 4 b 2 20 5 b 1 60 and want add column holds value of group total count: group score count totalcount 0 5 100 155 1 1 50 155 2 3 5 155 3 b 1 40 120 4 b 2 20 120 5 b 1 60 120 the way did was: grouped=df.groupby('group')['count'].sum().reset_index() grouped=grouped.rename(columns={'count':'totalcount'}) df=pd.merge(df, grouped, on='group', how='left') is there better / cleaner way add these values directly dataframe? thanks help. df['totalcount'] = df.groupby('group')['count'].transform(sum) some other options discussed here .

reactjs - How to disable ESLint react/prop-types rule in a file? -

i'm using react , eslint eslint-plugin-react. want disable prop-types rule in 1 file. var react = require('react'); var model = require('./componentmodel'); var component = react.createclass({ /* eslint-disable react/prop-types */ proptypes: model.proptypes, /* eslint-enable react/prop-types */ render: function () { return ( <div classname="component"> {this.props.title} </div> ); } }); just put on top of file: /* eslint react/prop-types: 0 */

uniqueidentifier - Is there an external library equivalent to BasicFileAttributes in Java? Specifically the method fileKey? -

for project i'm working on need locate inode/fileid. unique identifier individual files in operating system can keep track of them if renamed or moved. it recommended use basicfileattributes::filekey find , should work perfectly. problem need develop java 6 , basicfileattributes needs java 7. unfortunately it's not option use java 7, have suggestions external library can provide same functionality? it mentioned scripting command prompt (i'm using windows 7) try locate it. thanks , help/suggestions. this implementation came with: public static class filekey { private file file; public filekey(file file) { this.file=file; } @override public int hashcode() { long res = file.length(); res+=file.lastmodified(); if(file.ishidden()) res+=2; if(file.isdirectory()) { res+=3; } return (int) res; } @override public boolean equals(object dst) {

python 2.7 - Annotate a column field from relation on django -

i got 2 models defined owner , dog class dog(models.model): name = models.charfield(max_length=255) owner = models.foreignkey(owner) adopted_date = models.datetimefield() class owner(models.model): name = models.charfield(max_length=255) i want make list owners amount of dogs adopted date. example: ownername date amount richard 15/11/24 2 jow 15/11/24 2 i making query dog.objects.values('owner', 'adopted_date').annotate(count('owner')).order_by() the problem here query return owner id not name. { 'owner':1, 'adopted_date': 'date', 'owner_count': 2 } i need on owner name of owner, like. { 'owner':'richard, 'adopted_date': 'date', 'owner_count': 2 } any appreciated. edition this solution works , i'm having few doubts it, making query dog.objects.values('owner__name', 'owner', 'adopt

cluster computing - Memsql, set follower on a primary host -

i install memsql on host run functional tests, added additional host b using memsql ops ui. however, host b not show on host memsql ops ui. verified memsql ops running on host b connect port 9000 on host b. receive error when running memsql-ops follow -h a failed connect primary agent follower: agent @ a:9000 cannot follow both hosts running primary right now. is there chance memsql ops install on host b sharing data host a? instance, did copy data directory host host b when installed memsql ops on host b (by default, data directory in /var/lib/memsql-ops/data)? memsql ops automatically generates , saves agent ids when memsql ops install first starts, uuids used distinguish between different memsql ops agents in cluster. error you're seeing indicates you're trying follow agent same agent id; 1 way occur if you're using same data directory on both machines.

javascript - ESLint: How to set "new-cap" rule's "capIsNewExceptions" option within a file? -

here attempt set eslint's new-cap rule accept "s" allowed function name: /*eslint new-cap : [capisnewexceptions : ["s"]] */ var s = require("string"); var lines = s(text).lines(); // <-- eslint still gives warning cap 's'! my eslint parser (within intellij) continues give me new-cap warning, noted. i have tried apply eslint documentation carefully. from here , see example rule, looks this: /*eslint quotes: [2, "double"], curly: 2* /, in gather quotes , curly rules being set, , quotes rule contains 2 options, therefore contained in brackets because documentation says if rule has additional options, can specify them using array literal syntax (it says right above example). then, the actual documentation new-cap , find capisnewexceptions provided option, , value of option should array of desired function names - i've tried in code, above. but doesn't work. still receive eslint warning. what correct

javascript - How to get the value of a field with ng-change -

i know how react user input in textarea ng-change in angularjs. how can current input inside angular controller? missing $(this).value(); in jquery. <script> angular.module('changeexample', []) .controller('examplecontroller', ['$scope', function($scope) { $scope.evaluatechange = function() { console.log("how current content of field?"); }; }]); </script> <div ng-controller="examplecontroller"> <textarea ng-change="evaluatechange()" id="ng-change-example1"></textarea> </div> ng-model it'll store value of input, textarea, or select. your html should this: <div ng-controller="examplecontroller"> <textarea ng-model="myvalue" ng-change="evaluatechange()" id="ng-change-example1"></textarea> </div> then in controller can reference $scope.myvalue hope helps! :)

Cmake: Cross generate build systems from Linux possible? -

is possible generate build systems on 1 platform using cmake? example, , case i'm interested in, possible generate set of visual studio solution files, or mingw32-make makefiles, or nmake files, project linux? the intention make analogous make dist target produces in automake. however, don't need as make dist does, i.e. want generate solution files though i'd run cmake in windows. users can build package using created build system on own machines. if possible, how do it? cmake doesn’t report windows based generators being available on linux. after further research believe answer question no. reason makefiles , solution files etc. produced cmake depend on cmake itself, path hard-coded files. one solution windows might bundle cmake executable files , replace definition of cmake_command (for instance) added makefiles path bundled version of cmake somehow. suggestion though, haven't tried or researched much. if do, please post process comment or answe

Java arrays and methods issues -

i need program following below. create function called tostring returns printable string values of array in “array literal format”. create function called rangeinarray returns range of values in array. in math, range magnitude of difference between minimum , maximum (inclusive). have methods min , max use them , not need include loops method. this code have currently. public class westandersonasmnt9 { /** * @param args */ public static void main(string[] args) { int sample_array_1[] = {4,7,9,3,2,8,15,6,8,7}; int sample_array_2[] = {12,6,4,8,3,7,11,1,6}; integerarray arr = new integerarray(sample_array_1.length); integerarray arr2 = new integerarray(sample_array_2.length); integerarray arr3 = new integerarray(sample_array_1); integerarray arr4 = new integerarray(sample_array_2); arr.fillrandom(100, 200); arr.printliteral(); arr2.fillrandom(100, 200); arr2.printliteral();

c# - How to supply dynamic data set to a single view using ViewModels -

(first time posting , new mvc) have mvc/c# application user selects list of id's , chooses report type (8 possible different reports calling 8 different database views). passing of these parameters controller. based on report type chosen, want fetch data, send view , display data in grid/table format. i tried sending data via viewbag , viewdata had trouble parsing actual columns/data using @foreach. when decided try viewmodels. //my viewmodel.... //i know missing {get;set;} code // need with. need pass selected id's each database view , // perform additional query requests (i.e. distinct, order by). // sample query: // var dd = (from p in _db.report1 select new { sid = p.reportid, username = p.submitted_by, // balance = p.totaldebt}).distinct(); // dd = dd.where(w => chosenuserids.contains(w.sid)); // dd.orderby(p => p.sid).thenby(p => p.username).thenby(p => p.balance); public class userreportsviewmodel { public list<namespace.report1>

android - Progress Bar With Different Messages For Different Files -

i have implemented progress bar downloading 2 files, progressbar follows @override protected dialog oncreatedialog(int id) { switch (id) { case progress_bar_type: // set 0 pdialog = new progressdialog(this); if (x.equals("xp")) { pdialog.setmessage("downloading file. please wait..."); } if (x.equals("xv")) { pdialog.setmessage("updating file. please wait..."); } pdialog.setindeterminate(false); pdialog.setmax(100); pdialog.setprogressstyle(progressdialog.style_horizontal); pdialog.setcancelable(true); pdialog.show(); return pdialog; default: return null; } } i display different massage each of 2 files (downloading , updating). i press button it calls class (x = xp) downloads file (message downlaoding) class calls class b (x = xv) downloads second file(message updating) ho

java - How can i store the frequency of the tags in any website page in Hashmap? -

i using paired hashmap in storing tags , frequency confused how can store frequency in variable. code follows : package z; import java.awt.list; import java.io.ioexception; import java.util.arraylist; import java.util.hashmap; import java.util.hashset; import org.jsoup.jsoup; import org.jsoup.nodes.document; import org.jsoup.select.collector; import org.jsoup.select.elements; import org.jsoup.select.evaluator; import org.jsoup.nodes.element; public class crawler { static string url=""; public static void main(string[] args) { int val=0; string url = "http://stackoverflow.com/"; hashmap<integer, string> mymap = new hashmap<integer, string>(); mymap.clear(); try { document document = jsoup.connect(url).get(); arraylist<string> tags = new arraylist<string>(); system.out.println("number of tags select(\"*

python - How to return a value from a function and reference it in a while loop -

basically want return value healthcheck function can stop pokemons attacking eachother. see have left out rest of "if" line, unsure put here. need way return function healthcheck function, can't return statement work. class enemy(): global enemylives global dead dead=0 enemylives=10 def healthcheck(): if enemylives<=0: print("you defeated enemy!") while true: time.sleep(1) enemy1.attacked() enemy1.healthcheck() if break; time.sleep(1) squirtle.attacked() squirtle.healthcheck() (this isn't whole code) not sure logic of game should create attributes , avoid use of global, use instances attributes , methods. can exit loop sys.exit if enemys life gets 0. import time import sys random import random class enemy(): def __init__(self): self.dead = 0 self.life = 10

sockets - No transports available -

Image
i trying upgrade react-native app use react-native 0.5.0 , firebase. according article react-native sockets working , full firebase sdk should available. i using firebase-debug , @badfortrains react-native fork success following example project https://github.com/badfortrains/wsexample . since upgrading getting error when looking @ issues on react-native repo came across https://github.com/sjmueller/firebase-react-native/issues/1 @stephenplusplus says pushed bunch of buttons , activated magic. idea referencing?? there other question error creating user: { [error: there no login transports available requested method.] code: 'transport_unavailable' } any on understanding issue between using badfortrains firebase-debug , newest version of react-native firebase appreciated. i don't know if implementing incorrectly or if article mentioned above bit overzealous. thoughts??? thanks. oddly enough starting new project scratch using react-native-cl

ruby on rails - Run block once before all capybara tests -

i'm using capybara rspec integration testing rails app. there way run before block once before first capybara test runs without running before every feature spec? putting block in rspec.configure block such causes run before each feature spec: rspec.configure |config| config.before(:all, type: :feature) # stuff end end i think overengineering task. since run once , run it: cb = lambda { puts 'i run once' } rspec.configure |config| cb.call end

Is there standalone (similar to yii) actions in laravel 5? -

http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html (reference standalone actions in yii2) is there similar in laravel 5

Is there a way to access the iteration number in Postman REST Client? -

i'm using postman api testing. i'm running large number of tests , want print iteration number console on of them. there way iteration number environment-like variable? it possible now! can access iteration variable, in same way access other variables responsebody .

google chrome - "Tainted canvases may not be loaded" Cross domain issue with WebGL textures -

Image
i've learnt lot in last 48 hours cross domain policies, apparently not enough. following on this question. html5 game supports facebook login. i'm trying download profile pictures of people's friends. in html5 version of game following error in chrome. detailmessage: "com.google.gwt.core.client.javascriptexception: (securityerror) ↵ stack: error: failed execute 'teximage2d' on 'webglrenderingcontext': tainted canvases may not loaded. as understand it, error occurs because i'm trying load image different domain, can worked around access-control-allow-origin header, detailed in this question. the url i'm trying download is https://graph.facebook.com/1387819034852828/picture?width=150&height=150 looking @ network tab in chrome can see has required access-control-allow-origin header , responds 302 redirect new url. url varies, guess depending on load balancing, here's example url. https://fbcdn-profile-a.akamaih

ruby on rails 4 - adding models to backbone collections -

i have rails app 4 model classes, multiple instances in each table. have created backbone model , collection classes in coffeescript match. can load of collections , can render them in views. far, good. here 1 of collections, associated model: class window.coffeewater.collections.histories extends backbone.collection url: '/api/histories' model: history class window.coffeewater.models.history extends backbone.model i need able create history model object, , add histories collection. documentation states have set 'collection' property when creating new model, in order 'url' property collection. problem can't seem set 'collection' property value correctly, because url property not set on model instance attributes = {'start_time': new date (1434740259016), 'stop_time': new date (1434740259016 +(86400*1000)), 'valve_id': 2} options = { collection: window.coffeewater.collections.histories } history = new window.coff

javascript - Convert innerHTML to text and put into textarea not working -

i want take inner html (both tags , text) of element , put in textarea, somehow not working. how can make work , why not working? html: <div id="element"> <p>some text</p> <p>some text</p> </div> <button>click me</button> js: $("button").click(function(){ $("#element").html("<textarea>"+$("#element").text($("#element").html())+"</textarea>"); }); demo $("#element").text($("#element").html()) there's problem should be $("#element").text() jsfiddle edit: updated fiddle

java - Weird App not working on different mobile -

i develop google map related app on samsung mobile , release in play store shows approx 7000 supported devices. when downloaded app on samsung mobile it's working fine not working on moto , sony mobiles. when try debug moto mobile it's shows "shutting down vm" 06-20 00:17:25.276 457-457/com.mycompany.mypackage d/androidruntime﹕ shutting down vm 06-20 00:17:25.281 457-457/com.mycompany.mypackage e/androidruntime﹕ fatal exception: main process: com.mycompany.mypackage, pid: 457 java.lang.runtimeexception: unable instantiate activity componentinfo{com.mycompany.mypackage/com.mycompany.mypackage.mapsactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.content.context.getpackagename()' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:2225) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2388) @ android.app.acti

jquery - iPhone Safari and Chrome ignore JavaScript DOM changes -

right have javascript code gets data parse. when done getting data, appends select box user can make further selections. here's full code: parse.cloud.run("listevents", {}, { success: function (results) { var listitems = buildoptionfromparse("", "select date"); var today = new date(); (var = 0; < results.length; i++) { var object = results[i]; var eventdate = object.get("eventdate"); var datestring = eventdate.getmonth() + 1 + "-" + eventdate.getdate() + "-" + eventdate.getfullyear(); var eventdate = new date(datestring); if (eventdate > today) { listitems += buildoptionfromparse(datestring, datestring); } } $("#date").html(listitems); }, error: function (error) { } }); buildoptionfromparse doesn't special, returns string: return "<optio

scala - Mock a Spark RDD in the unit tests -

is possible mock rdd without using sparkcontext? i want unit test following utility function: def myutilityfunction(data1: org.apache.spark.rdd.rdd[myclass1], data2: org.apache.spark.rdd.rdd[myclass2]): org.apache.spark.rdd.rdd[myclass1] = {...} so need pass data1 , data2 myutilityfunction. how can create data1 mock org.apache.spark.rdd.rdd[myclass1], instead of create real rdd sparkcontext? thank you! i totally agree @holden on that! mocking rdds difficult; executing unit tests in local spark context preferred, recommended in programming guide . i know may not technically unit test, close enough. unit testing spark friendly unit testing popular unit test framework. create sparkcontext in test master url set local, run operations, , call sparkcontext.stop() tear down. make sure stop context within block or test framework’s teardown method, spark not support 2 contexts running concurrently in same program. but if interested , still want try mocki

Android Espresso: How do I assert that a view should not be displayed -

this seem correct... onview (withid (r.id.menu_delete)).check (matches (not (isdisplayed ()))); ...but throws exception: android.support.test.espresso.nomatchingviewexception: no views in hierarchy found matching: id: com.just10.android:id/menu_delete if target view not part of view hierarchy, may need use espresso.ondata load 1 of following adapterviews:com.github.ksoichiro.android.observablescrollview.observablelistview{3169f0f3 vfed.vc. .f...... 0,0-480,724 #102000a android:id/list} what's best way assert view should not displayed? what should have used this: onview (withid(r.id.menu_delete)).check (doesnotexist ()); this maybe particular fact view in options menu , may or may not exist @ given time, depending on implementation in oncreateoptionsmenu , onprepareoptionsmenu edit this method worked me non-menu views: onview (withid(r.id.menu_delete)) .check(matches(witheffectivevisibility(viewmatchers.visibility.gone)));

node.js - What happens when an attacker gains access to the secret used to generate JWTs? -

as understand jwt authentication works this: user sends login credentials server if login credentials correct, server issues jwt containing users id , username (or whatever want in payload identify user) this jwt generated using application-wide secret, should stored in environment variable the jwt stored user, example in localstorage , send every request server in header the jwt auth header verified using app-wide secret. if verification successful know sends request , if request authorized. but happens if attacker gains access secret used generate jwts? isn't master password? secret , users id/username issue jwts user , take on account. isn't massive flaw since 1 little piece of information compromise whole system (and not 1 users account)? or mistaken? if crypto stuff i'd suggest read on diffie-hellman key exchange technique. allows 2 parties have secure conversation without first knowing common secret. utilizes pk cryptography , following analog

sdk - ?:0: attempt to index field 'parent' (a nil value) -

full error: runtime error ?:0: attempt index field 'parent' (a nil value) stack traceback: ?: in function <?:565> ?: in function <?:221> i've read multiple topics it, none helpful. code works on other computer, there's no error in code. i've noticed error provided scrollview widget.if insert element that's been required .lua file , change scene-s error stay in loop @ simulator output. i have uninstalled/installed corona multiple times, restarted computer several times, no changes. full project code copied other computer , worked w/o errors. is there way uninstall every little bit of corona? since project history stays after uninstall. have cleared appdata, need format computer working again? edit also have multiple projects, older ones have same error now.. seems problem corona's widget library. noticed people finding similar errors last year here https://forums.coronalabs.com/topic/49750-attempt-to-in

PHP SQL Query - Select All Associated w/ Specific Value? -

i use assistance sql query. have small 3 column table, id, ip, , birthday. id auto increments. i'm trying select birthdays associated specific ip, i'm not sure if sql statement wrote correct. if check me appreciated. $query = "select birthday, count(ip) $table group ip having ( count(ip) > 1) ip=$ip"; to birthdays specific ip you'd query: select birthday table ip="desired value here" if you're trying count information, use: select ip, count(*) `total` table id="desired value here" group ip

javafx - Scene change vs Pane change -

Image
i'm relatively new java , espacially javafx. i'm trying make menu, switches displayed content on buttonclick. i've done clearing pane , asigning new fxml-file it. 1 method controller: protected void customstart(actionevent event) { content.getchildren().clear(); try { content.getchildren().add( (node) fxmlloader.load(getclass().getresource( "/view/customstartstructure.fxml"))); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } it works fine far wuld to changing scenes well. i want initiate scenes whit fxml-file in constructor. works within method. if try initiate in constructor invocationtargetexception caused runtimeexception caused stackoverflow error. if in other method, nullpointerexception when try change scene. this constructor public game() throws ioexception { this.mainmenu = n