Posts

Showing posts from February, 2010

java - Reasons for declaring a private static final variable -

why declare static final variable private immutable type? could possibly harm declare them public on case? so nobody can access outside , rely on value, giving freedom change without risk of side-effect (at least outside of class it's declared).

javascript - how to present a pop-up message based on Observable property? -

i have pop-up message want present when observable delivered, string observable. this function returns string observable: public sendupdate() { this._mtservice.sendcurrentupdate(this.mylist).subscribe( res => this.messagetodisplay = res, error => this.messagetodisplay = error ); } this function present pop relevant message: public showmessagedialog(message) { let config = new mddialogconfig() .title('message:') .textcontent(message) .ok('got it'); this.dialog.open(mddialogbasic, this.element, config); } now, want know , how should call message present messagetodisplay when observable ready. i t better if can tell me how can show loader while observable waiting receive string , when there present it... i tried this: public sendupdate() { this._mtservice.sendcurrentupdate(this.mylist).subscribe( res => this.messagetodisplay = res, error => this.messagetodisplay = error ); this.showm

maven - Quick way to programmatically deploy artifacts to Nexus (in Java) -

i write java program deploys lot of legacy jars nexus. approach invoke process starts deploy:deploy-file goal on command line mvn deploy:deploy-file ... this quite slow. wonder if there faster way this? if target nexus, might find simpler use their rest api perform upload: here examples using curl. uploading artifact , generating pom file: curl -v -f r=releases -f haspom=false -f e=jar -f g=com.test -f a=project -f v=1.0 -f p=jar -f file=@project-1.0.jar -u admin:admin123 http://localhost:8081/nexus/service/local/artifact/maven/content uploading artifact pom file: curl -v -f r=releases -f haspom=true -f e=jar -f file=@pom.xml -f file=@project-1.0.jar -u admin:admin123 http://localhost:8081/nexus/service/local/artifact/maven/content in java program, can use httpurlconnection make post call ( example of here authentication here , documentation of curl here ). basically, in post parameters, need have r=releases , haspom=true (or false if

jquery - Text opacity fade when at edge of viewport -

i'm trying .title fade when it's close top/bottom of screen. think problem jquery document targetting. can see, initial fade works perfectly, text not fade when close top/bottom. you can view codepen here . any appreciated! function scrollbanner() { $(document).scroll(function() { var scrollpos = $(this).scrolltop(); $('.title').css({ 'top': (scrollpos / 3) + 'px', 'opacity': 1 - (scrollpos / 100) }); $('.title').css({ 'background-position': 'center ' + (-scrollpos / 200) + 'px' }); }); } scrollbanner(); $(document).ready(function() { $(".title").delay(1000).hide().fadein(2000); }); /* parallax base styles --------------------------------------------- */ .parallax { height: 500px; /* fallback older browsers */ height: 100vh; overflow-x: hidden;

javascript - Google API offline access -

i have enabled proper api in google console. not issue. need write node js app accesses user's data when offline. have managed implement oauth2 authorization, , have gotten refresh_token, later used fresh access token. now i've gotten point of accessing api's themselves. have url works perfectly when called curl shell: curl https://www.googleapis.com/calendar/v3/calendars/primary/events?access_token=mytoken it returns json events, , works constantly. no matter how many times call it. yet exact same url fails when pasted in address bar of browser. here's response sent google: { "error": { "errors": [ { "domain": "usagelimits", "reason": "dailylimitexceededunreg", "message": "daily limit unauthenticated use exceeded. continued use requires signup.", "extendedhelp": "https://code.google.com/apis/console" } ], "code"

apache spark - DataProc Avro Version Causing Error on Image v1.0.0 -

we running few dataproc jobs dataproc image 1.0 , spark-redshift . we have 2 clusters, here details: cluster -> runs pyspark streaming job, last created 2016. jul 15. 11:27:12 aest cluster b -> runs pyspark batch jobs, cluster created everytime job run , teardown afterwards. a & b runs same code base, use same init script, same node types etc. since sometime last friday ( 2016-08-05 aest ), our code stopped working on cluster b following error, while cluster running without issues. the following code can reproduce issue on cluster b (or new cluster image v1.0.0) while runs fine on cluster a. sample pyspark code: from pyspark import sparkcontext, sqlcontext sc = sparkcontext() sql_context = sqlcontext(sc) rdd = sc.parallelize([{'user_id': 'test'}]) df = rdd.todf() sc._jsc.hadoopconfiguration().set("fs.s3n.awsaccesskeyid", "foo") sc._jsc.hadoopconfiguration().set("fs.s3n.awssecretaccesskey", "bar"

php - Displaying many rows using JSON -

i retrieving data database using json.the problem when try retrieve entire rows nothing displayed.if display single row successful.how display multiple rows.am using while loop . code trying display multiple rows : <?php header('access-control-allow-origin: *'); $con=mysqli_connect("localhost","root","?l:@colo2016//?[$^*@!(><)my~~~server~~2000]1620","test") or die("error in server"); $sql="select * test"; $qry=mysqli_query($con,$sql) or die(mysqli_error($con)); while($row=mysqli_fetch_row($qry)){ $table_data[]= array("first name"=$row['fname'],"last name"=$row['lname']); } echo json_encode($table_data); ?> any guide please? inside loop need use => assignment operator rather = $table_data[]= array( "first name" => $row['fname'], "last name" => $row['lname'

git - How do I clone an entire GitHub repository (commits, issues, wiki, everything) to a GitHub organization -

i added company's github organization. how go duplicating private repository on personal github account company github? i'm trying preserve previous commits, issues, wiki, etc. look @ howto https://developer.atlassian.com/blog/2016/01/totw-copying-a-full-git-repo/ seems looking for. show how can move full git repository 1 remote server another.

excel - Limitation in counting down loop -

i have following simple excel spreadsheet: b c 1 10 2 =b1+a2 3 =summe(b1:b2) 4 in cell a2 counting down values inserted following macro: sub test () sheets("sheet1").range("a2").value = sheets("sheet1").range("a2").value - 1 until sheets("sheet1").range("b3") > 0 sheets("sheet1").range("a2").value = sheets("sheet1").range("a2").value - 1 loop end sub this works fine far. however, want limit loop in macro. should countdown numbers in cell a2 until reaches number 0. should never go below 0. do have idea how can insert such "limit" in code? it should never go below 0. before writing value, check if <0 , exit do loop. is want? do until sheets("sheet1").range("b3") > 0 if sheets("sheet1").range("a2").value - 1 < 0 exit

java - How to add a score counter to my tic tac toe -

i have tic tac toe game created java swing , want add counter score how many games have been won either player. need counter counts score , don't know how add this this code below: package game; import java.util.scanner; public class main { public static boolean playerturn = true; public static boolean playerwon = false; public static boolean computerwon = false; public static boolean playing = true; public static scanner scan = new scanner(system.in); public static boolean playagain = false; public static tictactoe board = new tictactoe(); public static void main(string[] args){ if(board.isvisible() == false){ board.setvisible(true); if(playerwon == true || computerwon == true){ system.out.println("would play again!? true or false"); playagain = scan.nextboolean(); if(playagain == true ){ board.setvisible(false); system.out.println("player1 won: " + player

sdl 2 - SDL/C++ camera bether ways? -

at moment handle camera that: if (window.rightarrow) { //player.addxposition(player_speed); if (player.getposition().x > 400 - 50 / 2 && !cam.active) { cam.active = true; } if (cam.active && !blockedleft) { rect.updatecameraleft(player_speed); enemygrp.updatecameraleft(player_speed); } else { player.addxposition(player_speed); } //rect.updatecameraleft(player_speed); } else if (window.leftarrow) { if(cam.active && !blockedright) { rect.updatecameraright(player_speed); enemygrp.updatecameraright(player_speed); } else { player.subxposition(player_speed); } //player.subxposition(player_speed); //r

python - How to compare two matrices (numpy ndarrays) element by element and get the min-value of each comparison -

so want make comparison between 2 matrices (size: 98000 x 64). comparison should done element element , want min value of each comparison stored in third matrix same dimensions. want comparison being done without use of loops! here's small example: a=np.array([1,2,3]) b=np.array([4,1,2]) a function compares 1 , 4, 2 , 1 , 3 , 2 , stores in vector c answer c=[1,1,2] is there efficient way this? numpy has minimum feature, below: c = np.minimum(a,b)

c# - Webapi 2 Attribute Routing -

i have following routes set in user controller: [enablecors("*", "*", "*")] [routeprefix("api/users")] [authorize] public class usercontroller : apicontroller { [route("")] public ihttpactionresult get() { } [httpget] [route("{id:int}")] public ihttpactionresult get(int id) } [httppost] [route("validateuser")] public ihttpactionresult validateuser() { } [httppost] [route("verify/{identityid}/{emailaddress}")] public void verifyuseremailaddress(string identityid, string emailaddress) { } } the first 3 routes work fine. fourth fails 404. i'm using fiddler make call: http://localhost:39897/api/users/verify/asldkfj/jb@test.com (post selected) does post require data sent in body? can see i'm doing wrong , why verify route not being found? the .com in email issue. sure valid email, iis treats requests fi

javascript - Nodejs send to specific user get Cannot read property 'emit' of undefined error -

i want send message specific user connected , logging server sample code, error: cannot read property 'emit' of undefined this below code sample test: var socket = require('socket.io'), express = require('express'), app = express(), server = require('http').createserver(app), io = socket.listen(server), port = process.env.port || 3000, redis = require("redis"), redisclient = redis.createclient(); var io_redis = require('socket.io-redis'); io.adapter(io_redis({host: 'localhost', port: 6379})); io.sockets.on('connection', function (socket) { socket.on('login', function (data) { console.log(data.username); login(data.username, data.password, function (success, value) { if (success) { redisclient.set([data.username, socket.id]); socket.emit('l

c# - Manipulating a list with dynamically created controls -

let's say, have list<person> people , person class containing 3 strings: name , surname , age . have 6 dynamically created textbox controls, placed on panel control, , have name assigned them using for loop. as, dynamically created textchanged event said textbox controls. list consists of 2 entries people.add(new person { name = john, surname = johnson, age = 25 }); , people.add(new person { name = jack, surname = jackson, age = 30 }); . need user able change list<person> entries, inputting text in corresponding textbox . so, first textbox changes people[0].name , second - people[0].surname , third - people[0].age , fourth - people[1].name , , on... have @ textbox tag property, should here. https://msdn.microsoft.com/en-us/library/system.windows.forms.control.tag(v=vs.110).aspx you'd store person object in tag, , when textbox updated, can update tag object in turn update list you. you'd need way of telling textbox (firstname, lastname a

php - Joomla JUser return 0 -

hi (sorry bad english :c) have trouble in code. there 2 versions of site in web - dev , main. both use php 5.4 , have 1 host provider. in dev site work , on main - not. problem i'm use xmlhttprequest send ajax requests php file, included in start other file (head of ajax controller). here source of (last) file : <?php define( '_jexec', 1 ); define('jpath_base', dirname(__file__).'/../../../../../' ); define( 'ds', directory_separator ); require_once ( jpath_base .ds.'includes'.ds.'defines.php' ); require_once ( jpath_base .ds.'includes'.ds.'framework.php' ); jfactory::getapplication('site')->initialise (); $user = jfactory::getsession()->get( 'user' ); $___temp_user =& jfactory::getuser(); $user_id = $___temp_user->get('id'); but, how said, on main $___temp_user return 0; (im loggined in) please, tell me why happen. (joomla 1.5.9) this code define('jp

parse.com - withinkilometers geoquery in parse cloud fails with MongoDB error -

i'm trying closest parse object within 20 kms of location. var testpoint = new parse.geopoint({latitude: fromlatlng.lat, longitude: fromlatlng.lng}); var bkcity = parse.object.extend("bkcity"); var cityquery = new parse.query(bkcity); //throws mongo error cityquery.withinkilometers("location", testpoint, 20); cityquery.find({ ... however query fails with: �[31merror�[39m: uncaught internal server error. { [mongoerror: can't canonicalize query: badvalue geo near accepts 1 argument when querying geojson point. field found: $maxdistance: 0.003139224611520954] name: 'mongoerror', message: 'can\'t canonicalize query: badvalue geo near accepts 1 argument when querying geojson point. field found: $maxdistance: 0.003139224611520954', '$err': 'can\'t canonicalize query: badvalue geo near accepts 1 argument when querying geojson point. field found: $maxdistance: 0.003139224611520954',

php - Composer update `The following exception is caused by a lack of memory and not having swap configured` error in vagrant -

i got php5.5 composer installed in vagrant virtualbox environment. when try composer's commands following error appears randomly: the following exception caused lack of memory , not having swap configured how can around ? this thread suggest not fix that. here 2 workarounds. can use each separately or both @ same time. 1st workaround: increase memory limit command in vagrant machine. increase php memory limit current command. run: php -dmemory_limit=2g /path/to/composer update 2nd workaround: increase guest machine memory add configuration vagrant file, can temporary increase allocated memory: $memory = env.has_key?('vm_memory') ? env['vm_memory'] : "512" vagrant.configure("2") |config| [...] config.vm.provider "virtualbox" |v| [...] v.memory = $memory [...] end [...] end then reload vagrant machine follow: vm_memory=2048 vagrant reload then, in vagrant machi

ruby on rails - Sass::SyntaxError: Undefined variable. But variable is defined -

i'm crashing head on wall stupid scss error: sass::syntaxerror: undefined variable: "$darker-grey" app/assets/stylesheets/mobile/general.scss:36 app/assets/stylesheets/mobile/main.scss:6 in main scss file have: @import "compass"; @import "compass/reset"; @import "bourbon"; @import "mobile/variables.scss"; @import "mobile/mixins.scss"; @import "mobile/general.scss"; @import "mobile/general-profile.scss"; @import "mobile/buttons.scss"; @import "mobile/form.scss"; variables imported before every other file use them. this variables file. /**************************************************** * * varibles * ****************************************************/ $imgs: "mobile/"; /**************************************************** * colors ****************************************************/ $background-color : #ffffff; $foreground-color : #1f1f1f; $light-gra

how to use "consistency" parameter in java api when put data to elasticsearch -

i have used "consistency" parameter in python program put data elasticsearch ,but can not find usage of "consistency" in java api. can me? you can write: client.prepareindex("index", "doc", "doc1") .setsource("doc") .setconsistencylevel(writeconsistencylevel.quorum) .execute() .actionget()

php - Signature does not match in Amazon Web Services -

Image
i writing php code amazon web services. code. <?php function amazonencode($text) { $encodedtext = ""; $j = strlen($text); ($i = 0; $i < $j; $i++) { $c = substr($text, $i, 1); if (!preg_match("/[a-za-z0-9-_.~]/", $c)) { $encodedtext .= sprintf("%%%02x", ord($c)); } else { $encodedtext .= $c; } } return $encodedtext; } function amazonsign($url, $secretaccesskey) { // 0. append timestamp parameter $url .= "&timestamp=" . gmdate("y-m-dth:i:sz"); // 1a. sort utf-8 query string components parameter name $urlparts = parse_url($url); parse_str($urlparts["query"], $queryvars); ksort($queryvars); // 1b. url encode parameter name , values $encodedvars = array(); foreach ($queryvars $key => $value) { $encodedvars[amazonencode($key)] = amazonencode($value); } // 1c. 1d. reconstruct encoded que

producer consumer - How to achieve high speed processing using Azure Event Hub? -

Image
i working on poc azure event hubs implement same our application. quick brief on flow. created tool read csv data local folder , send event hub. we sending event data in batch event hub. with 12 instance of tool (parallel), can send total of 600 000 lines of messages event hub within 1 min. but, on receiver side, receive 600 000 lines of data, takes more 10 mins. need achieve i match/double egress speed on receiver process data. existing configuration the configuration have made user are tu - 10 1 event hub 32 partition. coding logic goes same mentioned in msdn only difference is, sending line of data in batch. eventprocessorhost options {maxbatchsize= 1000000, prefetchcount=1000000 azure producer-consumer azure-eventhub share | improve question edited aug 19 '16 @ 21:09 james z 10.7k 7 15 35