Posts

Showing posts from July, 2015

how to call variable or property inside an object in javascript or jquery -

i getting dates(start , end dates) dynamically servers in json format, need implement in bootstrap date picker, not working here code note: implementing using variables names // var start = obj1.start; // var end = obj1.end; var start = 01/02/1906; var end = 01/02/1998; $('#datepicker').datepicker({ autoclose: true, startdate: 'start', enddate: 'end', }); the quotes ' or " around variables make them strings, not variable reverence. remove them quotes. but on other hand, have add quotes on variable declaration, because these strings. // add quotes here var start = '01/02/1906'; var end = '01/02/1998'; $('#datepicker').datepicker({ autoclose: true, // , remove quotes here startdate: start, enddate: end, }); working example.

Can I call a 64bit DLL from a 32bit version of Excel VBA? -

i'm in unusual situation of having 32bit install of excel , libraries call have been compiled 64bit libraries when try call functions error "cannot find xyz.dll". i know can't call 32bit processes (easily) 64bit ones, vice versa? no can't that. 64 bit dll cannot loaded 32 bit process. (you can't converse either way, correct can call 32 bit process 64 bit process , , vice-versa).

How do I convert a string into a string of bytes in python 2.7 -

i'm trying convert string coming raw_input() "string of bytes". when type variable manually (in code) works fine, returns me length of 5. however, when try enter "string of bytes" raw_input() returns me length of 20. >>> x='\xb2\xb2\xb3\xb4\x01' >>> len(x) 5 >>> x=raw_input() \xb2\xb2\xb3\xb4\x01 >>> len(x) 20 i know why happening , how can fix it. in advance. when submit string "\xb2\xb2\xb3\xb4\x01" raw_input() automatically escapes \ characters because thinks mean enter them part of string. results in representation of string read this: in [2]: x=raw_input() \xb2\xb2\xb3\xb4\x01 in [3]: x out[3]: '\\xb2\\xb2\\xb3\\xb4\\x01' in [4]: print x \xb2\xb2\xb3\xb4\x01 unfortunately answer question shouldn't manually entering string of bytes raw_input() .

python - concurrent.futures not parallelizing write -

i have list dataframe_chunk contains chunks of large pandas dataframe.i write every single chunk different csv, , in parallel. however, see files being written sequentially , i'm not sure why case. here's code: import concurrent.futures cfu def write_chunk_to_file(chunk, fpath): chunk.to_csv(fpath, sep=',', header=false, index=false) pool = cfu.threadpoolexecutor(n_cores) futures = [] in range(n_cores): fpath = '/path_to_files_'+str(i)+'.csv' futures.append(pool.submit( write_chunk_to_file(dataframe_chunk[i], fpath))) f in cfu.as_completed(futures): print("finished @ ",time.time()) any clues? one thing stated in python 2.7.x threading docs not in 3.x docs python cannot achieve true parallelism using threading library - 1 thread execute @ time. you should try using concurrent.futures processpoolexecutor uses separate processes each job , therefore can achieve true parallelism on multi-core cpu.

javascript - Transparent form bootstrap over background image -

i'm working bootstrap , can't figure out how texts , forms overlay background image. i've tried other solutions found here, none of them work. i've tried adding bootstrap page creating own css , trying in html page well. <form class="form-horizontal"> <div class = "form-group"> <label for="inputname" class="control-label col-xs-2">first name</label> <div class = "col-xs-10"> <input type = "text" class="form-control transparent-input" id="inputname" placeholder="name"> </div> </div> <br> <div class = "form-group"> <label for="inputlast" class="control-label col-xs-2">last name</label> <div class = "col-xs-10"> <input type = "text" class="form-control transparent-in

Spring boot multi module - Reload sub modules without running maven install -

Image
i have spring boot multi module maven project configured parent pom, web application , sub module web project dependent on. is there eclipse plugin can use allow me make change in sub module, , have change reflected when restart web application without running maven install on sub module every time? pom.xml | web application pom.xml | sub module pom.xml i starting application in eclipse run configuration goal: spring-boot:run it not necessary install plugins resolve this. right click on project want run select run configurations, select resolve workspace artifacts.

typescript - Using an injected angular service as a dependency within a static method -

i trying use injected dependency within static method , of course injected dependency instance-scoped , can't used within static method . here class: @injectable() export class passwordvalidationservice { constructor(private useraccountservice:useraccountservice) { } static passwordvalidator(control:abstractcontrol) { return control .valuechanges .debouncetime(400) .switchmap(()=> this.useraccountservice.checkcurrentpassword(control.value)) .map(res=> { if (res.json() === true) { return null; } else { return {invalid: true}; } } ); } } my question best practice in order use useraccountservice (dependency) within static method? edit : redesigned app towards using instance methods instead of static methods follows: here validator: import {injectable} "@angular/core"; import {useraccountservice} "../../useraccount/useraccount.servi

android - Can't use onClickImageListener on a Fragment swipetabs -

i've been trying add images fragment of swipe tab clicked open activity not yet working! i have swipe tab activity has 3 fragments first intro second made menu , third information can't make menu want menu manually made image , clicked next relating activity inside it. me fragment code:- import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.imageview; public class twofragment extends fragment { imageview img; public twofragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { return inflater.inflate(r.layout.fragment_two, container, false); img = (imageview)getview().findviewbyid(r.id.imageview); img.setonclicklistener(new view.onclicklistener() { @override

java - Eclipse:Get and set caret position of the editor -

i'm developing voice recognition plugin eclipse. example when writing code can "for" , "for(){}" printed editor. works great, however, when scope of cursor goes out of eclipse e.g. when click on browser search next thing printed here instead of eclipse editor. is there way find out caret position on eclipse editor when goes out of scope, because when click on part of eclipse ui old caret position pops up. i using javarobot api emulate string screen. don't believe has option of setting caret position, courser position. update: needed text editor caret position x , y co-ordinates, can use java robot move mouse(caret position x,y) , mouse press bring eclipse platform scope before emulation occurs. assuming have ieditorpart interested in can caret position using: ieditorpart editor = .... part .. control control = editor.getadapter(control.class); // text editor control styledtext if (control instanceof styledtext) { styledtext tex

javascript - Maintaining Key values when converting from Map to List ImmutableJS -

i'm having utility function converts map list. supposed still have key values attached it, reason doesn't. rather need read of index, of not useful use case. know how preserve keys when transfer map? here's source function getmetastatearray(metastatearrayorobject) { let metastatearray; if (metastatearrayorobject && immutable.map.ismap(metastatearrayorobject)) { metastatearray = metastatearrayorobject.tolist(); } else { metastatearray = metastatearrayorobject; } return metastatearray; } solved making list wrapper around map, while doing list.of() inside wrapper, map inside won't turn regular array: metastatearray = list(list.of(metastatearrayorobject));

html - Materialize alignment issue with cards -

Image
hey guys i'm using materialize framework , added normal image cards this. <div class="row"> <div class="col s12 m6 l3"> <div class="card"> <div class="card-image"> <img src="img/websiteicon.png" alt="websites"> <span class="card-title">title here</span> </div> <div class="card-content"> <p>text here</p> </div> <div class="card-action"> <a href="diensten.php">check out possibilities</a> </div> </div> </div> (4 div cards) </div> this appears @ medium browser size , @ widths. does know how fix this? pretty sure it's not bug. this because cards have different heights, causes cards appear on w

AngularJS - Filtering when targeting another page -

i have built simple filter angularjs, html <a class="filterbutton" ng-click="filters.grade = '7'">7 grade</a> <a class="filterbutton" ng-click="filters.grade = '6'">6 grade</a> <a class="filterbutton" ng-click="filters.grade = ''">x clear filters</a> <ul> <li ng-repeat="name in names | filter:filters">{{name.student}}, {{name.grade}} grade</li> </ul> and controller: var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.filters = { }; $scope.names = [{ "student": "jimmy", "grade":7 }, { "student": "johny", "grade":7 }, { "student": "little joe", "grade":6 }]; }); this works expected. wanted able check 1 of filters , jump page same controller, when loaded second page filtered. exa

java - type mismatch between read and write methods wildfly 9.0.0 -

i'm getting error when run application in eclipse wildfly 9.0.0.final, wildfly 8.0.0.final it's working fine, it's same code , configuration. i'm working hibernate. i copy server logs 11:16:01,536 error [org.jboss.msc.service.fail] (serverservice thread pool -- 64) msc000001: failed start service jboss.undertow.deployment.default-server.default-host./ws: org.jboss.msc.service.startexception in service jboss.undertow.deployment.default-server.default-host./ws: java.lang.runtimeexception: org.springframework.beans.factory.beancreationexception: error creating bean name 'cfilter': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: com.service.residentservice com.security.customfilter.residentservice; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'residentservice' defined in "/c:/program files/wildfly/wild

c# - Disable paging in GridView to Excel export -

i've got function export data gridview excel, bound checkboxes. exports rows checked. works fine, can't seem disable paging export? code: private void exportgridtoexcel() { bool isselected = false; foreach (gridviewrow in gridview1.rows) { checkbox cb = (checkbox)i.findcontrol("chkselect"); if (cb != null && cb.checked) { isselected = true; break; } } if (isselected) { gridview gvexport = gridview1; // below line not export checkbox excel file gvexport.columns[0].visible = false; foreach (gridviewrow in gridview1.rows) { gvexport.rows[i.rowindex].visible = false; checkbox cb = (checkbox)i.findcontrol("chkselect"); if (cb != null && cb.checked) { gvexport.rows[i.rowindex].visible = true; } } response.clear(); respons

javascript - Get the value of datepicker on change in jquery -

i need value of datepicker on change , returning undefined . html : <input id="#return" name="start" class="date-pick form-control" value="" data-date-format="dd/mm/yyyy" type="text" /> js : $('input.date-pick').datepicker().on('changedate', function (ev) { var firstdate = $('#return').val(); alert(firstdate); }); use onselect event , can selected value in datetext variable $('.date-pick').datepicker({ onselect: function(datetext, inst) { alert(datetext); } });

classification - Azure machine learning even sampling -

i'm trying basic multi-label classification in azure ml. have basic data in following format: value_x value_y label x1 y1 label1 x2 y2 label1 x3 y3 label2 ..... my problem in data labels (out of total of five) overrepresented, 40% of data label1, 20% label 2 , rest around 10%. i sampling out of these train model, each label represented in equal amounts. tried stratification option in sampling module on labels column, gives me sampling same distribution of labels in initial dataset. any idea how module? i able using combination of split data , partition , sample , , add rows modules. there may easier way it, did confirm works. :) published work @ http://gallery.azureml.net/details/1245147fd7004e91bc7a3683cda19cc7 can grab directly there, , run confirm expect. since said wanted sampling of data, reduced each of labels 10% have labels represented equally. since have understanding of distribution in dataset, leave label 3, 4

javascript - Grunt task for combining multiple Jquery ready functions into single ready function -

i have ready functions spread across multiple files looking merge , minify. there grunt task merge ready 1 function ? // file1.js $(document).ready(function(){ $(".class1").click(function () { // action }) }) // file2.js $(document).ready(function(){ $(".class3").on("blur", function () { // action }) }) // file3.js $(document).ready(function(){ $(".class2").on("change", function () { // action }) }) // file4.js $(document).ready(function(){ $(".class3").click(function () { // action }) }) i looking ... // file.js $(document).ready(function(){ $(".class1").click(function () { // action }) $(".class3").on("blur", function () { // action }) $(".class2").on("change", function () { // action }) $(".class3").click(function () { // acti

c++ - Why is an allocator allowed to override the ctors and dtors of its value_type? -

as far know, containers supposed use std::allocator_traits<alloc>::construct , std::allocator_traits<alloc>::destroy either alloc::construct , alloc::destroy respectively or value_type::value_type , value_type::~value_type (the defaults). why allow allocator override default ctor , dtor of value_type ? when useful? this allows allocator construct objects in custom ways. an example based on standard library features std::scoped_allocator_adaptor pass allocator objects constructs (as long support construction allocators). useful when want elements of container use same allocator container itself. when container's allocator constructs element passes (or copy of rebound element type) element. another example if have huge vectors of trivial type double don't want pay cost of zero-initializing vector elements if you're going re-assign them new values anyway. can have custom allocator nothing in construct function, elements left uninitializ

postgresql - How to remove white spaces for column value in database -

Image
i collecting tweets twitter , storing them in database. in tweets of tweets coming greater white space. when storing tweets database shown in below picture. i tried remove white spaces using regex. here query select '(' || regexp_replace(text, e'[[:space:]]', '', 'g') || ')'from persons; i getting following output **output :** ('rt@cristiano:grandejogodetodaaequipa.vencemosjuntos,celebramosjuntos.@realmadrid#halamadrid#rmclasico:soccer::grinning::muscle::v::facepunch:https://t.co/…') in above output when tried using reg-ex, original spaces missing out. how store data getting neat english text regular spaces (i.e., removing white spaces,tabs).

caching - How to set http header in magento -

with reference post i need set http header. how in magento? can set http header? there procedure in mangento this? you need more clear on want header ? if want on every page, can write observer , listen event predispatch , set http headers on there.. alternatively can try implement using htaccess.. try inserting ur htaccess file .. header set cache-control "no-cache, no-store, must-revalidate" header set pragma "no-cache" header set expires "0" to check, can load page of site, , check headers using network tab..

c++ - Const-ness when returning reference to an internal object -

this question has answer here: c++11 auto: if gets constant reference? 1 answer i trying understand following case, behaves differently expect. given following code example: class consttestclass { std::deque<unsigned long long> deque; public: const std::deque<unsigned long long int> &getdeque() const{return deque;} }; int main() { consttestclass consttestclass; auto constdeque = consttestclass.getdeque(); constdeque.emplace_back(1ull); } i expect call constdeque.emplace_back(1ull); fail, since expecting constdeque reference const std::deque<> , compiles without error on gcc 5.4.0. if change line above const auto constdeque = consttestclass.getdeque(); fails compile expected, since constdeque of expected type. i trying understand why auto can remove const-ness return type , error in understanding lies. edit:

java - Updating timestamp of row if exists in HBase -

tl;dr: possible update row timestamp if exists? is possible make hbase act in lru fashion? mean if row exists in hbase want update timestamp i know can invoke create data if doesn't exist (like this ) i'm looking opposite, updating data (specifically timestamp) if data exist the reason wanting i'm working on component uses hbase cache urls , content, way when new request url arrives want check if content exists , if want update timestamp, otherwise content doesn't exist , want go , fetch it. reason need timestamp other side of program have component reads urls arrived in last day, that's reason why need update timestamp thanks in advance it's been long since posted question figured i'll @ least accept ended using (even though not hoping use) i ended sending , put timestamp automatically increased

Javers IlegalArguementException -

javers team, thomas , using javers 2.0.3 , getting below error java.lang.illegalargumentexception: argument should not null @ org.javers.common.validation.validate.argumentsarenotnull(validate.java:33) @ org.javers.core.javerscore.compare(javerscore.java:119) looks not able handle nulls. using javers compare 2 entity of same type diff = javers.compare(oldentity,newentity); has many entities defined inside having 1 one, 1 many relationships. i read in stackflow post, issue resolved 1.2.1. javers breaking above respective error it's not error, illegalargumentexception means have put illegal data compare() function. both arguments have non-null. inside domain objects can have many null need, javadoc compare() method says: * calculate diff, provide 2 versions of * same domain object (entity or valueobject) * or handles 2 versions of same object graph.

Create one to many relation in Excel Filter -

Image
i creating dependency list our products. example; *product 1* uses a.dll, b.dll, c.dll *product 2* uses a.dll, d.dll *product 3* uses b.dll, c.dll well, when user product 2 combobox (filter) in excel, , b dll names must shown on dependency column. i dont want add like product 1 a.dll product 1 b.dll product 1 c.dll product 2 a.dll product 2 d.dll product 3 b.dll product 3 c.dll i think should done in advanced filter, tried didnt work me. choose range product 2, shows me 1 dependend dll name while not 100% clear want... simple helper-column should doable... the formula used(d2 , copied down): =countif(index(j:l,match($g$1,i:i,0),),c2)>0 and filter helper column showing true

google cloud dataflow - How do I specify a network subnet -

when create network custom subnet error: invalid value field 'resource.networkinterfaces[0].subnetwork': ''. subnetwork not specified custom network how specify subnet job use? (updated): dataflow supports subnetworks, using --subnetwork flag. expected format " regions/region/subnetworks/subnetwork ".

How do I save information and make it show up on the screen for my Android app? -

i have following code android application, have written using sharedpreferences. got of information stackexchange, still unable values save appear on screen. here code: package com.example.shivamgandhi.gyrosafe; import android.content.intent; import android.os.bundle; import android.content.context; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.view; import android.view.menu; import android.app.activity; import android.view.menuitem; import android.util.log; import android.widget.button; import android.content.sharedpreferences; import android.widget.edittext; import android.widget.toast; import android.widget.textview; import org.w3c.dom.text; public class settings_page_activity extends appcompatactivity implements view.onclicklistener{ edittext ed1, ed2; button btnarray2[] = new button[5]; publ

javascript - How to create a super simple AngularJS directive for using GSAP TweenMax? -

i'd use tweenmax animation in angularjs project, , instead of justwriting code in controller, i'd correct way, , use via directive. here's element: <ul> <li class="foo">a</li> <li class="foo">b</li> <li class="foo">c</li> </ul> here's animation: var ease = elastic.easeout; tweenmax.staggerfrom(".foo", 1.5, { scale: 0.7, opacity: 0, delay: 0.5, ease: ease }, 0.1); how do wrap in directive? you can have directive on wrapper element below, have element.children() apply effect on each dom queuing them up. markup <ul tween-max-stragger> <li class="foo">a</li> <li class="foo">b</li> <li class="foo">c</li> </ul> directive .directive('tweenmaxstragger', function() { return function(scope, element, attrs) { var ease = elastic.easeout;

Opening a file in C in write mode -

i writing c program converts text file binary file , vice versa. first question have opening file in "w" mode. there need have check output file opened correctly? file *output; output = fopen("output.bin", "w"); if(output == null) { printf("error opening output file\n");} basically question whether or not output ever == null. because if there problem opening output wouldn't create new file named "output.bin"? also other question how characters saved in binary file. know i'm supposed save each character unsigned char can have values between 0 , 255 , should write char output file. actual logical path of how happens not making sense if can me or point me in right direction appreciate it! yes, opening file in write mode might still fail. here's bunch of possible reasons, not ones: you don't have permission create or change file. the file read-only, or directory in read-only. the file inside file.

c - If Statement in linked list not working as expected -

so have if statement in getnth function im trying test. when inserted printf function, made me notice goes through if statement if condition not met, however, when remove printf statement program works flawlessly. explanation appreciated. notice! not code, im trying study linked lists , changing code around trying learn! the code: #include <stdio.h> #include <stdlib.h> #include <assert.h> /* link list node */ struct node { int data; struct node* next; }; /* given reference (pointer pointer) head of list , int, push new node on front of list. */ void push(struct node** head_ref, int new_data) { /* allocate node */ struct node* new_node = (struct node*) malloc(sizeof(struct node)); /* put in data */ new_node->data = new_data; /* link old list off new node */ new_node->next = (*head_ref); /* move head point new node */ (*head_ref) = new_node; } /* takes head pointer of linked list , index argu

java - Wait until complete onChildAdded in firebase querys, Android -

i'm new firebase , working on simple project. have method list of teachers firebase , add emails arraylist , return. public arraylist<string> getteacherlist() { temp = new arraylist(); firebase node = ref.child("teachers"); query query = node.orderbychild("subject").equalto(selected_subject); query.addchildeventlistener(new childeventlistener() { @override public void onchildadded(datasnapshot datasnapshot, string s) { map<string,object> value = (map<string, object>) datasnapshot.getvalue(); log.d("teacher"," "+value.tostring()); iterator entries = value.entryset().iterator(); while (entries.hasnext()) { map.entry thisentry = (map.entry) entries.next(); string key = (string) thisentry.getkey(); object data = thisentry.getvalue(); if(key.equals("email")) {

sql - regex for oracle "create procedure" definition -

i need regex capture full "create procedure" statement. here 1 of examples, used testing regex: create or replace procedure sp_for_comp (p_varname in varchar2, p_value in out number) v_if_exists number(10,0); begin select count(*) v_if_exists pkg_var variablename = p_varname; if v_if_exists > 0 begin select value p_value pkg_var variablename = p_varname; exception when others null; end; else begin insert pkg_var values(p_varname, p_value); exception when others null; end; end if; end; / current regex: /create\s+(or\s+replace\s+)?procedure\s+(\w+)\s*\(((?!.*\bend\b\s*(\w+\s*)?\;\s*\/).*\s*)+.+/ as issue: use qregularexpression class , program failed when run on large files. also, when run on small file - works correctly. after lot of tests on online debuggers, regexr.com, not find problem in regex. how should change , may problems?

python - How to write a ndarry to a structure file with numpy? -

i have 22 * 25 arrays in numpy ar : 0.1 0.0 ..... 0.25 0.2 0.1 ..... 0.0 ... 0.0 0.01.... 0.6 and tried: ar.tofile("f.txt",sep = " ") what got long string, how can got file 22 rows , 25 columns? thanks. you better off using np.savetext() : np.savetxt('f.txt', ar, fmt='%.2f')

c# - Asynchronous LINQ -

i looking async .where() not find 1 after research i've created one. public static class linqextension { public static async task<ienumerable<t>> whereasync<t>(this ienumerable<t> source, func<t, task<bool>> @delegate) { var tasks = source.select(async t => new { predicate = await @delegate(t).configureawait(false), value = t }).tolist(); var results = await task.whenall(tasks).configureawait(false); ienumerable<t> typelist = results.where(pred => pred.predicate).select(val => val.value); return typelist; } } when try use runtime error cannot convert implicit type bool task , yes it's correct this how i've tried var q = await context.stockhistories.whereasync(x => x.productid == productid); i've tried context.stockhistories.whereasync(task.run(() => { x => x.productid == productid; })); but getting

Telegram webhook: Is ssl mandatory? -

i want know if ssl certificate , url starting https:// mandatory webhook of telegram bot? noticed in https://core.telegram.org/bots/api#setwebhook seems necessary, i'm not sure this. as telegram bot documentation says: all queries telegram bot api must served on https , need presented in form. you need valid ssl certificate webhooks work. to use self-signed certificate, need upload public key certificate - using certificate parameter in setwebhook. please upload inputfile, - sending string not work. ports supported webhooks: 443, 80, 88, 8443. wildcard certificates may not supported. redirects not supported. cn must match domain. setting ssl not hard , there or free ways too(like free valid ssl certs or self-sign methods)

java - Spring Security Failed to load resource: the server responded with a status of 404 -

Image
when ever navigate authenticated url, static contents url's inside href has been attached route's url because of i'm getting 404 resources in page , urls inside href element for e.x <security:http auto-config="true" use-expressions="false"> <security:intercept-url pattern="/reports/**" access="role_user"/> <security:intercept-url pattern="/**" access="role_anonymous"/> <security:form-login login-page="/login.do" login-processing-url="/login.do" username-parameter="custom_username" password-parameter="custom_password" authentication-success-handler-ref="authsuccesshandler" default-target-url="/" always-use-default-target="true" authentication-failure-url="/login.do?error=true"/>

c++ - Creating a new file avoiding race conditions -

i need develop c++ routine performing apparently trivial task: create file if not exist, else nothing/raise error. as need avoid race conditions, want use "ask forgiveness not permission" principle (i.e. attempting intended operation , checking if succeeded, opposed checking preconditions in advance), which, knowledge, robust , portable method purpose [wikipedia article] [an example getline] . still, not find way implement in case. best come opening fstream in app mode (or fopen ing "a" ), checking output position tellp (c++) or ftell (c) , aborting if such position not zero. has 2 disadvantages, namely if file exists gets locked (although short time) , modification date altered. i checked other possible combinations of ios_base::openmode fstream , mode strings of fopen found no option suited needs. further search in c , c++ standard libraries, boost filesystem, proved unfruitful. can point out method perform task in robust way (no collateral eff