Posts

Showing posts from September, 2015

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

it seems can't ssh virtual box. i have virtual box running win7. host pc in win7. virtual box created through vagrant following vagrantfile. vagrant.configure("2") |config| config.vm.box = "http://aka.ms/vagrant-win7-ie11" end open cmd. go root folder of vagrantfile. execute following command: vagrant cmd displays: bringing machine 'default' 'virtualbox' provider... ==> default: clearing set forwarded ports... ==> default: clearing set network interfaces... ==> default: preparing network interfaces based on configuration... default: adapter 1: nat ==> default: forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: booting vm... ==> default: waiting machine boot. may take few minutes... default: ssh address: 127.0.0.1:2222 default: ssh username: vagrant default: ssh auth method: private key timed out while waiting machine boot... time o

start chronometer from dialog box -

i chronometer start when click "ok" button dialogbox... can not. succeed start chronometer when dialog box open. when click "ok" button time has passed... thanks help... begin code. my code: import android.app.activity; import android.app.dialog; import android.os.bundle; import android.os.systemclock; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.chronometer; import android.widget.textview; public class activityone extends activity implements onclicklistener { private chronometer mychronometer; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.timerlayout); mychronometer = (chronometer) findviewbyid(r.id.chronometer); button buttonstart = (button) findviewbyid(r.id.startbutton); button buttonstop = (button) findviewbyid(r.id.pausebutton); button b

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

i trying use -wl,-wrap=sendto -wl,-wrap,sendto in final g++ link command links app replace standard sendto function own. i compile following source code gcc -c -o wrap.o wrap.c , include wrap.o in final g++ command links app (the rest of app c++ hence use of g++) #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> ssize_t __real_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); ssize_t __wrap_sendto ( int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen ) { printf("my wrap sendto ...\n"); return __real_sendto(sockfd, buf, len, flags, dest_addr, addrlen); } when use sendto in own source code, wrapper in fact used ok 3rd party shared objects linked against in final g++ command use sendto still use system sendto i.e. not wrapper. how can sendto wrapper used throughout ? i have tried ld_preload approach sendto , dlsym(rtld_nex

I could not debug scala remote application on eclipse or IntelliJ IDEs -

i have scala server side application on eclipse ide, followed remote configuration server side application on eclipse nothing worked me. there suggestion debug scala application on eclipse, intellij or other ides? after 3 days, got way debug scala server side application on eclipse is, create test class scala class want debug. put break points on method in scala class , run created test class using "debug scala test file" on eclipse.

ruby on rails - Why does Time.zone get set to nil inside Thread -

here mean ... require 'rubygems' gem 'activesupport','4.2.6' require 'active_support/all' time.zone = 'est' puts "print current time zone -- [#{time.zone}]" thread.new puts "time zone(will nil) instead thread -- [#{time.zone}]" end sleep 1 o/p print current time zone -- ((gmt-05:00) est) time zone(will nil) instead thread -- () clearly rails doing magic on here time.zone inside thread. so question .. why rails doing magic? where in rails code that.(a link code great) if have @ time.zone can see set current thread, seems intended behaviour. you can either store in variable , call way or set time.zone 'est' every time in create thread , call time.zone subsequently. here's example of what's happening thread.current[:foo] = 'bar' thread.current[:foo] #=> "bar" thread.new { p thread.current[:foo] } #=> nil i'm not able answer why rails magic ma

maven - jacoco coverage per test setup -

i'm using jacoco in order gather code metrics , import them sonarqube missing details coverage per test. after searching came this tutorial failed make work on project. here pom.xml <properties> <sonarversion>2.4</sonarversion> <spring-framework.version>4.0.0.release</spring-framework.version> <spring-framework.security.version>3.2.5.release</spring-framework.security.version> <jackson.version>1.9.13</jackson.version> <jacoco.version>0.7.7.201606060606</jacoco.version> <aspectj.version>1.7.4</aspectj.version> <sonar.java.coverageplugin>jacoco</sonar.java.coverageplugin> <sonar.dynamicanalysis>reusereports</sonar.dynamicanalysis> <sonar.jacoco.reportpath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportpath> <sonar.jacoco.itreportpath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.itreportpath>

android - How to determine if a in-app subscription on Google Play has been renewed? -

the following documentation describes result querying google play api subscription: https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource-representations however, if user cancels subscription when there still time left in current period, cancelreason empty or 0? in other words, cancelreason flag stay empty until there no time left in current period, or change on cancellation? in other words, cancelreason flag stay empty until there no time left in current period, or change on cancellation? i think, answer " it doesn't matter ", because documentation says : query subscription status only @ expiration — once server has retrieved expiration date of subscription tokens, should not query google play servers subscription status again until subscription reaching or has passed expiration date . typically, servers run batch query each day check status of expiring subscriptions, update database. in fact can change imm

excel - How to change and print multiple filters of a single pivot table at once? -

overview: i have pivottable filter. filter contains list 1 30, each of must printed separately. is, each time have change filter , print filtered result. my demand: what want print of them @ once. conditions: the list of numbers not continous or static. means numbers droped , new numbers may added later. my current situation , challange: by means of macro recorder command, arrive following situation. problem that, don't know how make dynamic. mean, how "do procedure existing numbers". can me please correct , complete following macro? sub makro1() ' ' makro1 makro ' activesheet.pivottables("leistungsnachweise").pivotfields("tour").currentpage _ = "1" activewindow.selectedsheets.printout copies:=1, collate:=true, _ ignoreprintareas:=false activesheet.pivottables("leistungsnachweise").pivotfields("tour").currentpage _ = "2" activewindow.selectedsheets.printou

mysql - Using one of the columns in a composite key as a foreign key -

i trying see whether can use 1 of columns in composite key foreign key. , got strange result. create table testparent( pk1 int, pk2 int, primary key(pk1,pk2) ); query ok, 0 rows affected (0.01 sec) create table testchild1( fk1 int, foreign key (fk1) references testparent(pk1) ); query ok, 0 rows affected (0.01 sec) create table testchild2( fk2 int, foreign key (fk2) references testparent(pk2) ); error 1005 (hy000): can't create table 'test.testchild2' (errno: 150) mysql allows create foreign key reference first column in primary key, not second column. strange? or being stupid! as mysql documentation on foreign keys indicates : innodb permits foreign key reference index column or group of columns. however, in referenced table, there must index referenced columns listed first columns in same order. ndb requires explicit unique key (or primary key) on column referenced foreign key. so, if use innodb, mysql n

Linux checking shell command (bash) -

how can check if shell command ends text? instance if type $ http://example.com/file.webm (ends .webm) automatically replaced $ wget http://example.com/file.webm of course if command consists of 1 part. i'm using bash shell. bash 4 provides hook handling "command not found" error. in case, http://example.com/file.webm not valid command, define following function in .bashrc file: command_not_found_handle () { if [[ $1 = http://*.webm ]]; wget "$1" else return 127 fi } when attempt run url command, command_not_found_handle called url first argument. function checks if command name matches webm url, , if does, runs wget url argument. (for other unrecognized command, return 127, command still unrecognized.)

python - Not able to remove a specific character from file via ansible -

i have file below data server1 10.10.10.10, server2 10.10.10.20, server3 10.10.10.30, and delete comma character( , ) third line i.e server3 10.10.10.30. when try use lineinfile method, removes commas, requirement remove comma third line. i wondering if there method can use in ansible remove character line x, row y more precise? thank in advance time , response. the lineinfile module not seem appropriate scenario. instead use sed command: - shell: sed -i 3s/,$// filetochange

plsql - How to call a sql function? -

Image
i have written function minimum2 take 2 numbers arguments , returns minimum number. function compiles without error. when call function minimum(1,2); errors pls-00103. here function , function call: create or replace function minimum2(v1 number, v2 number) return number begin if v1 < v2 return v1; else return v2; end if; end; --i call function asl follow minimum2(1,2); what did wrong? wrote code in sql developer you need run select select minimum2(1,2) dual you need end function / : for details on how , why use / see here are aware there built-in function that? select least(1,2) dual

objective c - Search Template tvOS -

Image
anybody know how implement search template in apple tvos human interface guidelines, using native development in objective-c or swift, without tvml ? so, after 1 day of research found solution: objective - c if in application tabbar, created subclass uitabbarcontroller e.g. aptabbarcontroller. in aptabbarcontroller, in method - (void)viewdidload i next: uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; searchresultsviewcontroller *myviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"searchresultsviewcontroller"]; uisearchcontroller *searchcontroller = [[uisearchcontroller alloc] initwithviewcontroller:myviewcontroller]; uisearchcontainerviewcontroller *containervc = [[uisearchcontainerviewcontroller alloc] initwithsearchcontroller: searchcontroller]; containervc.title = @"search"; uinavigationcontroller *navigationcontroller = [[uinavigationcontroll

sql server - Finding a referenced table in multiple views using SQL -

i have huge database 50+ views, tables , stored procedures. want run search find specific piece of text, i.e table name, see if being referenced anywhere. i tried c# route suspecting easier in sql. logic thinking possibly creating query loops through tables, views , stored procedures , returns data if available. any ideas? in below query, instead of matchingstring replace tablename, returns list of objects related search string select distinct so.[name] sysobjects join syscomments sc on sc.id = so.id sc.[text] '%matchingstring%'

visual studio - Aurelia binding causes VS editor to show "Unexpected token" error -

Image
i've opened app.html sample aurelia in visual studio 2015 update 3. although applications works properly, editor shows error because doesn't find value.bind valid html. what remove annoying error in editor?

filter - Exclude empty sub buckets ElasticSearch -

i wrote aggregation query 2 levels: { "size": 0, "aggregations": { "colors": { "terms": { "field": "color" }, "aggregations": { "timestamps": { "date_histogram": { "field": "timestamp", "interval": "1m", "order": { "_key": "desc" } }, "aggregations": { "timestamps_bucket_filter": { "bucket_selector": { "buckets_path": { "counterts": "_count" }, "script": { "lang": "expression", "script": "counterts == 0" } } }

django - Get all functions inside a Python Package for getattr -

i have 2 python files , both @ same directory level this project |> tasks.py |> queue.py i have function in tasks.py file def foo(message): # perform functions on message data # blah blah and function in queue.py file this import project.tasks def run_task(function_name, data): # function name string tells function call in tasks.py file return getattr(project.tasks, function_name)(data) i not want hard code function name. want access them dynamically on basis of function_name parameter. tasks.py has become large therefore want divide in parts. thing did moved tasks.py file in python package this. project |> tasks |> __init__.py |> tasks.py |> queue.py the question want ask how can modify run_task function in order work struction. getattr function task first argument object. there other option avilable can used access function inside task package.? answer @jonrsharp

javascript - CodeIgniter - Create dynamic html table using form helper functions? -

i've dynamic table adds more rows. here table. <table> <thead> <tr class="success"> <th>bank/lender</th> <th>add more</th> </tr> </thead> <tbody > <tr> <td> <?php $data = array( 'name' => 'debt_info_bank_name[]', 'id' => '', 'class' => 'form-control', 'placeholder' => 'bank/lender name' ); echo form_input($data); ?> </td> <td> <input class="add btn btn-success btn-sm" type="button" value="add more" /> </td> </tr> </tbody> and here javascript part: $(document).on('click','.add',function(){ $(this).val('delete'); $(this).attr('class','del btn btn-danger

qt - Translating a Q_ENUM keys -

i use q_enum macro in code, , use associated qmetaenum populate qcombobox . is there "standard" way manage translation of q_enum keys (retrieved qmetaenum::key() method)? i didn't find in qt's documentation, , main problem automatically add translations keys in *.ts files keys of q_enum . thanks you have provide translation keys yourself, series of qt_tr_noop() expansions, lupdate pick them up. if that's onerous, write small program generate suitable input file lupdate meta-object.

php - Creating a URL encoded string in smarty -

i trying create string of values taken variables in backend following structure: before encoding: transaction_id=0815/2009;transaction_cid=54ab;item_id=402163045080;item_va lue=25.20;item_quantity=1; transaction_id=0815/2009;transaction_cid=54ab;item_id=402163045080;item_va lue=25.20;item_quantity=1; after encoding: transaction_id%3d0815%2f2009%3btransaction_cid%3d54ab%3bitem_id%3d40216304 5080%3bitem_value%3d25.20%3bitem_quantity%3d1%3bitem_id%3d847163029054%3bi tem_value%3d16.81%3bitem_quantity%3d2 i have managed create array necessary data in form: '[{"transaction_id":"233684","transaction_cid":"d2871c13c507583048d8ecf4a16f94c0","i tem_id":"3524","item_value":"4915.13","item_quantity":"1"}]', but need these elements of array in url encoded string. i out of ideas since try seems not work. using json.stringify keeps ":" , ""&qu

java - Hbase byteArray to Long -

i have row key being created put put = new put(bytes.tobytes(tweets.getcontact_unique_id()+"^"+bytes.tobytes(epoch))); where epoch long timestamp. now when scan row 3857^[b@7c8f4424 now wish convert part of rowkey ie long [b@7c8f4424 how achieve this. edit -> if use put put put = new put(bytes.tobytes(tweets.getcontact_unique_id() + "^" + epoch); not rows gets inserted , when use put put = new put(bytes.tobytes(tweets.getcontact_unique_id()+"^"+bytes.tobytes(epoch))); all rows gets inserted , please note time values different. also note have used "^" seperate out 1st , 2nd part of rowkey. thanks you save long value in a wrong way ! because when use + array bytes of long value converts string, converted value shows the current address in memory of bytes array, not value ! the correct way of saving: put put = new put(bytes.add(bytes.tobytes(tweets.getcontact_unique_id()

php - display data from mysql using json to listview in fragment -

i trying load data database using json , display in listview in fragment. have 2 classes, 1 called downloader , 1 called perser. add data listview in fragmnet. how can achieve because work fine in content_mani want fragment import android.app.progressdialog; import android.content.context; import android.os.asynctask; import android.widget.listview; import android.widget.toast; import java.io.bufferedinputstream; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; import info.androidhive.materialtabs.fragments.onefragment; /** * created george on 25/06/2016. */ public class downloader extends asynctask<void ,integer,string>{ context c; string urladdress; listview lv; progressdialog progressdialog; public downloader(mainactivity context, listview listview, string urladdress) { t

java - Can I associate attributes to the role in wso2? -

is there way associate custom attributes role in wso2? similar way assign claims profile. i understand, can associate permissions user. afaik, roles cannot have claims in wso2 environments. doubt common requirement. trying achieve in particular?

excel - Max value from within ranges -

i've searched question i'm not repeating anything... i have 3 columns: column - names (ie david, collin, mary) column b - sales (50, 60, 45, 88) column c - week (1, 2, 3, 4, 5) for example names sales week david 1000 1 david 2000 1 david. 500 2 david 1000 2 collin 300 1 collin 500 1 collin 800 2 collin 100 2 at quick glance can see david's best weekly total 3000 week 1 , collins 900 week 2. is there formula work out above - 1 gives highest total each person having calculated between weeks? sorry if haven't been clear :) try one, works me: range a1:a8 refers = names range b1:b8 refers = sale amount range c1:b8 refers = week number =max(sumproduct(($a$1:$a$8="david")*($c$1:$c$8=1)*($b$1:$b$8)),sumproduct(($a$1:$a$8="david")*($c$1:$c$8=2)*($b$1:$b$8)),sumproduct(($a$1:$a$8="david")*($c$1:$c$8=3)*($b$1:$b$8)),sumproduct(($a$1:$a$8="

amazon ec2 - How do I enable PHP functions from CLI? -

i need check , enable php functions in aws ec2 instance. (listed them below). i've gone through php.ini file can't find reference of these. don't see them when run php -i . need install them 1 one? if so, how do on unix command line? these functions mbstring modules, zip , enabled gd2. php functions enabled: - dir - readdir - opendir - eval - exec - set_time_limit - ini_alter - ini_set - ini_restore - php_uname - popen - proc_close - proc_get_status - proc_open - shell_exec - system any appreciated you dealing php extensions/modules, reconfigure php installation , rebuild or add library. located in {your php installation dir}/extensions/ also see http://php.net/manual/en/function.dl.php personally, build php scratch extension need.

xcode - Core Data mapping model -

Image
i' trying make custom core data migration. created .xcmappingmodel, when try compile project error: can me?

c++ - How to solve this Object Slicing issue with GoogleMock -

below 1 of line in method. here have mock method "findchild" , make "chino::mock_button" instance assigned "close_button". requirement. chino::button* close_button = findchild<chino::button>("closebutton"); methods tried: since findchild template, can't mock it. changed implementation of findchild template specialize chino::button type , mock new function "getchinobuttoninstance(qstring,bool)" , make return chino::mock_button instance rather chino::button instance. template<> inline chino::button* mediator::findchild<chino::button>(const qstring &name, bool recursive) { return getchinobuttoninstance(name,recursive); } then, in unittestclass have mocked "getchinobuttoninstance". mock_method2(getchinobuttoninstance,chino::mock_button*(qstring,bool)); and expect_call : expect_call(*wlighting,getchinobuttoninstance("a",true)).times(testing::atleast(1)).willonce(test

vb.net - How do you calculate a result from a listbox selection in Visual Basic? (The data in the listbox is being read off a text file) -

so asked in school create railway ticketing system program allow buy either single or return ticket , based off cost displayed. information of destinations read via text file. text file given below: knapford , 1 crosby , 8 weltworth , 15 maron , 23 cronk , 28 kildane , 31 keltthorpe road , 46 crovan's gate , 56 vicarstown , 76 barrow , 77 i have managed separate integers destination names via code below displayed in listbox: public class purchasescreen dim filename string private sub form2_load(byval sender system.object, byval e system.eventargs) handles mybase.load filename = "stationfile.txt" dim sr new streamreader("stationfile.txt") dim word string = "" dim words(11) string dim integer = 0 until sr.peek = -1 'grab 1 word @ time text file word = sr.readline() 'place word array words(i) = word 'increment array counter = + 1 loop return end sub

javascript - Expose compiled Julius templates as a seperate file, instead of directly placing them in the DOM -

when debugging js, chrome allows edit js , reload page. can happen if js editing provided separate resource. far can tell, it's not possible debug js code fashion because of way yesod drops included js on page directly. editing julius template file without changing variable interpolation allows instant reloading of page. however, if include small snippets of javascript with: towidget [julius|dostuff();|] i can't edit javascript debugging without causing reload of model, our case, takes ~1minute. there way around this? there multiple choices here: if put julius content in external file, can use juliusfilereload , edit file , reload webpage without recompile. scaffolded site default. have generated javascript placed in separate file. default behavior of scaffolded site.

php - laravel 5.2 Displaying related data in the view -

in controller use eager loading load properties along related files , addresses: public function search_results(request $request) { $properties = property::with('residential', 'file', 'addresses')->get(); return view('result', ['results' => $properties]); } and pass straight onto view. in view.blade.php how access related data. here example of view not seem work regards related data. @forelse ($results $result) <div class="row"> <div class="col-md-7"> @foreach($result->file() $file) <a href="#"> <img class="img-responsive" alt="" src="{{ url::to('/') }}/images/properties/{{$file->filename}}"> </a> @endforeach </div> <div class="col-md-5"> <h3>{{ $result->title }}</h3> <h4>subheading</h4>

php - Binding data to request object in middleware [Slim Framework 3] -

i decoding jwt tokens in middleware following this example in documentation of slim framework. want bind userid decoded jwt token request object. how in expressjs can't figure out how in slim framework. there anyway bind data request object? i tried: $request->setparam('userid', $userid); ok, have solved problem. how can bind data request object in slim framework. $request = $request->withattribute('userid', $userid); and in route or controller, how can data: $userid = $request->getattribute('userid');

elasticsearch - Querying Kibana using grok pattern -

we have configured elk stack on our daily logs , using kibana ui perform basic search/query operation on the set of logs. some of our logs have field in message while others don't. therefore have not configured separate field while configuring logstash . i have logs like: [28/jun/2016:23:59:56 +0530] 192.168.xxx.xxx [api:profile]get_data_login: project password success: 9xxxxxxxxx0 [28/jun/2016:23:59:56 +0530] 192.168.xxx.xxx [api:profile]session_end: logout success: 9xxxxxxxxx0 totaltime:1.1234 in these 2 logs, wish extract totaltime session_end logs. , visualize it. how should it? i can search logs listed under session_end , not able perform grok on set of logs. inside filter in logstash can have : filter { ... if ([message] ~= "session_end") { grok { #write grok second format of log here } } else if ([message] ~= "get_data_login") { grok { #write grok first for

javascript - AngularJS Avoid duplicates when updating a CRUD table (normal add to table works) -

i trying create simple crud table not allow duplicate names. have been able duplicate work when adding contact table, not seem working when updating table. below simple function verified uniqueness of contact: // (allowed) dupcount 0 when adding, , 1 when in update // mode allow saving contact without making changed. var isunqiue = function(newcontact, dupcount) { var returnval = true; var count = 0; (var contact in $scope.model.contacts) { if (newcontact.name.touppercase() === $scope.model.contacts[contact].name.touppercase()) { count++; } } if (count > dupcount) { returnval = false; } return returnval; } for reason, duplicate in update mode not working @ all! if update 3 or 4 contacts same name, 'if (count > dupcount) ... ' statement seem compare 1 , 1. here jsfiddle entire code: https://jsfiddle.net/7ay9nslv/ simple scenario: add 'adam, smith' 1. edit 'adam, smith', save wi

node.js - loopback PersistedModel find() error handling -

i'm following loopback framework tutorial, page https://docs.strongloop.com/display/public/lb/extend+your+api there example code finds instance id, modified bit handle non-existent instances coffeeshop.getname=function(id, cb) { coffeeshop.findbyid(id, function(err, shop){ if(err) { console.log(err); cb(err); } else cb(null, 'name of coffee shop '+shop.name); }); }; it works fine when call existing id, when enter invalid id, instead of calling err handler it's omitted entirely, else statement called , whole app crashes following console error /app/path/here/node_modules/mysql/lib/protocol/parser.js:78 throw err; // rethrow non-mysql errors i'm new node.js , i'm pretty sure i'm missing here shouldn't error passed callback function rather being thrown top level? this doesn't seem mysql backend specific, switched mongo connector , got similar pro