Posts

Showing posts from August, 2012

Git - submodules HEAD is always detached after running update? -

i have configuration submodule in .gitmodules file: [submodule "sub"] shallow = true branch = master path = sub url = https://path/to/repo.git now want when clones repo , runs these commands: git submodule init git submodule update is shallow master branch of submodule. happens not checkout master branch. detached head, need manually run git checkout master . instead of 2 commands, user needs run 1 additional. i looked this: why git submodule head detached master? but advice on accepted answers, not seem help: added branch want in .gitmodules file, added remote upstream master (this works cloned/updated repository after had checkout master myself). so intended detached head if clones repository , wants set submodule? i'm still investigating this, here script came , using now: #! /bin/bash

html - CSS - How to autonavigate to a color on the page when page loads -

i have page work on daily , need through page text has html of: <tr style="background-color:#33ff00"> how can use css auto navigate color or html code when page loads? there way? i cannot edit html it's not hosted locally , don't have access write access, read. using stylebot modify css own display purposes , want know if can same auto navigate colored section. if there way similar using style bot html userscripts etc, not familiar enough if have workaround tutorial great show me how implement it. thanks! updated copy , paste code below text file , save html file. open in browser. this code loads target page host 'result' element, uses post-load javascript navigate colored tr elements. if page requires scripts on external stylesheets, etc., these need loaded explicitly. <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

c# - XmlSerializer ignores attributes -

xmlserializer ignores class attributes. i'm writing simple serializer, , used [serializable] , [nonserialized] attributes, tried use [xmlroot] , [xmlignore] . , i've noticed, although field has attribute [nonserialized] serialized. and ignores other attributes such [xmatribute] . i've noticed it's not necessary use attributes, , can serialize class without these attributes, how can ignore fields? my class: [serializable] public class route { int busnumber; string bustype, destination; datetime departure, arrival; [nonserialized]datetime creationdate; ... } and i'm trying serialize list<route> private void savetoolstripmenuitem_click(object sender, eventargs e) { stream stream = file.openwrite(environment.currentdirectory + "\\routes.xml"); xmlserializer xmlser = new xmlserializer(typeof(list<route>)); xmlser.serialize(stream, ((fileform)activemdichild).routes); stream.close(); } i

r - different values by fitting a boosted tree twice -

i use r-package adabag fit boosted trees (large) data set (140 observations 3 845 predictors). i executed method twice same parameter , same data set , each time different values of accuracy returned (i defined simple function gives accuracy given data set). did make mistake or usual in each fitting different values of accuracy return? problem based on fact data set large? function returns accuracy given predicted values , true test set values. err<-function(pred_d, test_d) { abs.acc<-sum(pred_d==test_d) rel.acc<-abs.acc/length(test_d) v<-c(abs.acc,rel.acc) return(v) } new edit (9.1.2017): important following question of above context. as far can see not use "pseudo randomness objects" (such generating random numbers etc.) in code, because fit trees (using r-package rpart) , boosted trees (using r-package adabag) large data set. can explain me "pseudo randomness" enters, when execute code? edit 1: similar phenomeno

How to add Android.mk file to gradle by using UI -

i'm following below url add android.mk file gradle file . https://developer.android.com/studio/projects/add-native-code.html#link-gradle i've installed ndk before, don't know android.mk file . you select ndk-build, use field next project path specify android.mk script file external ndk-build project. android studio includes application.mk file if located in same directory android.mk file. my os windows 64.

java - countChars - So close, yet so far -

i feel there, i've starred blind after trying know(which isn't lot.) alright, trying input string method should read , give me numbers of each character or first. i'm lost. please help. public class sam { private static string countchars; public static void main(string[] args) { system.out.println(countchars); } static int countchars(string str, char searchchar) { // count number of times searchchar occurs in // str , return result. int i; // position in string, str. char ch; // character in string. int count; // number of times searchchar has been found in str. count = 0; (i = 0; < str.length(); i++) { ch = str.charat(i); // i-th character in str. if (ch == searchchar) { count++; } } return count; } } best regards, sam you not correctly calling countchars() function in main() function. you use following example system.out.println(countchars("hello,

javascript - how to create dots(scatterplot) on a line in a d3 line chart -

Image
my code working fine, there issue first dot on line. first dot y=2 , x=1 position, other dots placed correctly. please me place first dot in correct place. graph:- json data graph:- var data = [{ "label": "execution: 6 - defadmin@gmail.com", "x": [1, 2, 3, 4, 5, 6], "y": [2, 1, 1, 1, 1, 1], "xaxisdisplaydata": ["1", "2", "3", "4", "5", "6"] }]; here code regarding dot creation, // set ranges var x = d3.time.scale().range([0, innerwidth]); var y = d3.scale.linear().range([innerheight, 0]); // scale range of data x.domain(d3.extent(datasets[0]['x'], function (d, i) { return datasets[0]['x'][i]; })); y.domain([1, d3.max(datasets[0]['y'], function (d, i) { return datasets[0]['y'][i]; })]); // add scatterplot svg.selectall("dot") .

android - Automatic silent update for corporative app -

i have private application 20 customers. we need update application manually via team viewer. i researched this, did not find solution or suggestion yet. for example: https://groups.google.com/forum/#!topic/android-developers/dpgbzi9qrgq for example: https://blog.vivekpanyam.com/evolve-seamlessly-deploy-android-apps-to-users/ do have suggestions application auto update itself. note: know google play store politic, not using google play store. thanks suggestions or solutions. you need have place @ server versions can downloaded from. you need have place, maybe database store version releases. whenever release new version, should store new version @ place can downloaded , need make sure store somehow have new version. you need installer extract newest version of application , installs instead of old version. should automatically placed @ users. your application needs check periodically requesting server whether there new version. if so, installer should e

node.js - How deal with the multiple messages from SQS? -

the following function receive multiple messages sqs . each message has processed , database updated accordingly. i can deal single message, calling pull function worker module. how deal multiple messages? cannot keep calling pull method of worker module in loop, since block thread. best way possible here? function checkmessage(){ var params = { queueurl : constant.queue_url, visibilitytimeout: 0, waittimeseconds: 20, maxnumberofmessages: 10 } sqs.receivemessage(params,(err,data) => { if(data){ var workerid = uuidv4(); // worker pull message processing // worker response returned in callback function worker.pull(data,workerid,(err,respdata) => { if(respdata){ // if message processed // set final job status complete , // progress 100% }else

C Program - How to validate a specific string in a file -

please bear me i'm still new c programming, goal serial number saved in file called mtd0 , validate serial number. in bash, command is: dd if=/dev/mtd0 bs=1 skip=$((0x1fc30)) count=16 2>/dev/null and output should be: 1866203214226041 but want in pure c language, have tried far this: #include <stdio.h> #include <string.h> int main () { file *fp; file *s; fp = fopen("/tmp/mtd0","rb"); if(null == fp) { printf("\n cannot open file!!!\n"); return 1; } typedef unsigned char byte; byte s_no[16]; fseek(fp, 0x1fc30, seek_set); fread(s_no, 1, 16, fp); printf ("serial number: %s\n", s_no); fclose(fp); char mtd0[16]; char defser[16]; int ret; memcpy(mtd0, s_no, 16); memcpy(defser, "1866203214226041", 16); ret = memcmp(mtd0, defser, 16); if(ret == 0) { printf("serial number correct!\n"); } el

javascript - Restart Vue transition -

i have defined transition group in vue <transition-group name="staggered-scale" tag="div" :css="false" @before-enter="animationbeforeenter" @enter="animationenter" appear> <span v-for="i in range" :key="i" :data-index="i">{{ }}</span> </transition-group> i have javascript hooks control animation. animationbeforeenter(el) { el.style.transform = 'scale(0.1)'; } animationenter(el, done) { const delay = el.dataset.index * 30; settimeout(() => { el.style.transform = 'scale(1.0)'; done(); }, delay); } when component rendered, animation plays fine. however, can programmatically trigger animation run again? you can bind parameter special attribute :key transition-group , each time parameter's value changes causes re-render , animation runs again. define parameter: data(){

ios - Present a ViewController from the AppDelegate -

i have 3d force touch action set in info.plist . want when 3d action running presents view controller gave storyboard id , need in appdelegate . i used performactionforshortcutitem function. func application(_ application: uiapplication, performactionfor shortcutitem: uiapplicationshortcutitem, completionhandler: @escaping (bool) -> void) { if let tabvc = self.window?.rootviewcontroller as? uitabbarcontroller { if shortcutitem.type == "hausaufgaben" { tabvc.selectedindex = 1 tabvc.performsegue(withidentifier: "gotohausaufgaben", sender: nil) } } } func application(_ application: uiapplication, performactionfor shortcutitem: uiapplicationshortcutitem, completionhandler: @escaping (bool) -> void) { if shortcutitem.type == "hausaufgaben" { self.window = uiwindow(frame: uiscreen.main.bounds) let storyboard = uistoryboard(name: "main", bundle: nil)

c++ - Make std's data-structure use my existing non-static hash function "hashCode()" by default -

i have moderate-size codebase (>200 .cpp ) use function hashcode() return hash number:- class b01{ //a class //..... complex thing .... public: size_t hashcode(){ /* hash algorithm #h01 */} }; class b02{ //just unrelated class //..... complex thing .... public: size_t hashcode(){/* #h02 */} //this same name above }; i have used in various locations, e.g. in custom data-structure. works well. now, want make hash algorithm recognized std:: data structure:- here should :- (modified cppreference , call code #d ). //#d namespace std { template<> struct hash<b01> { std::size_t operator()(const b01& b) const { /* hash algorithm #h01 */ } }; } if insert block #d (with appropriate implementation) in every class ( b01 , b02 ,...), can call :- std::unordered_set<b01> b01s; std::unordered_set<b02> b02s; without passing second template argument, , hash algorithm ( #h01 ) called. (by de

typescript - Angular 2 export component into template -

i want create custom tabs component able display contents of [root] inside itself. works when use selectors in html tags ( <tab1> ), not know selector be. tabs components need way render component view my tab.ts should display root component inside viewport @component({ selector: 'tab', template: `<div [hidden]="!active"> <ng-content></ng-content> </div>` }) export class tab { @input('tabtitle') title: string; @input() active = false; @input('root') root: any; } then here tabs.ts glues tabs (enables switch between them) @component({ selector: 'tabs', template: `<div class="tabbar"> <div class="tab-button" *ngfor="let tab of tabs" (click)="selecttab(tab)"> <a href="#">{{tab.title}}</a> </div> </div> <ng-content></ng-

Use R to iteratively download all tiff files from shared Google Drive folder -

i use r to: 1) create list of tif files in shared google drive folder 2) loop through list of files 3) save each file local drive i've tried rgoogledocs , rgoogledata , both seem have stopped development , neither support downloading tif files. there googlesheets , again, doesn't suit needs. know of way accomplish task? -cherrytree here's part of code (cannot share of it) gets list of urls , makes copy on hard drive: if (download == true) { urls = dataframe$productimagepath (url in urls) { newname <- paste ("academy/",basename(url), sep =" ") download.file(url, destfile = newname, mode = "wb") } }

android - Multipart request is getting error code 400 java -

i'm requesting web service in android using multipartutility , request sent is: post / http/1.1 connection: keep-alive enctype: multipart/form-data content-type: multipart/form-data;charset=utf-8;boundary=--===1487292689114=== accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding: gzip, deflate, br accept-language: es-419,es;q=0.8,en-gb;q=0.6,en;q=0.4 cache-control: max-age=0 upgrade-insecure-requests: 1 user-agent: dalvik/1.6.0 (linux; u; android 4.4.4; 5042a build/ktu84p) host: 192.168.10.171:8080 content-length: 990 payload: ----===1487292689114=== content-disposition: form-data; name="new_id" 171 ----===1487292689114=== content-disposition: form-data; name="file"; filename="img_20170216_195118.jpg" content-type: image/jpeg content-transfer-encoding: binary ���� ( ----===1487292689114===-- this service: @post @path("/reportnewimage") @consumes(mediatype.multipart_form_data+&q

javascript - How to target bootstrap datepicker's its own '.datepicker-dropdown' when there is multiple datepickers in a page.?(without container option) -

in project - app, have multiple datepicker version 2.0. client wants me customise datepicker showing date of calendar top, did tweaks, working on page 1 datepicker it's story when comes multiple datepicekers on 1 page.my code follows. $(elem).datepicker(options); //customized datepicker plugin 03/07/2017 //author - jithin raj var date = new date(); var today = new date(date.getfullyear(), date.getmonth(), date.getdate()); $(elem).on('show', function() { var cpicval = '', ypicval = ''; if ($('.datepicker-dropdown').find('.new-date-wrap').length <= 0) { $('.datepicker-dropdown').prepend('<div class="new-date-wrap"><div class="custom-year-pic-view"><span></span></div><div class="custom-day-pic-view"><span></span></div></div>'); } if ($(elem).va

html - Body and Div height/overflow issues -

i'm working on project using vue.js 2.0 framework , bit of bootstrap 3. project has required me work more on front-end used wondering if here give me useful insight few css issues appear having. the project can found here: http://rgmotorhomehire.com/project if give source quick inspection, notice body element height of navbar, , container div's various 'pages' totally outside of parent body element. the main thing i'd know is: how can force body 100% height via css, wraps it's child elements properly, , can add footer html. please note have tried: html, body { margin: 0; height: 100%; } however, if try in inspector, notice introduces new issue of html element having empty space below it. this whole scenario has left me more little lost , confused. hoping out there can inform me on whats causing issues. note: i'd apologise in advance pointless info post contains (including note), i've had complaints in past questions not bei

php - Wordpress site sits idle before loading the page -

i have wordpress website, loading extremely slow. http://shop.fertan.bg the issue website sits ideal long time before beginning load webpage. unable isolate issue, used same theme , plugins (and few other plugins) on other website, http://52.57.164.181/ this page loading extremely smooth , fast. has had same issue before? , me understand this!

php - saving and displaying embedded video in WooCommerce / WC Vendor Pro -

i have added custom text field woocommerce , displayed in frontend of wc vendor pro . vendors can add youtube or vimeo link embed movies. however reason can't save , display in product page on front end. the code have far in functions.php : // display fields add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); // save fields add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' ); function woo_add_custom_general_fields() { global $woocommerce, $post; echo '<div class="options_group">'; // text field woocommerce_wp_text_input( array( 'id' => 'video_url', 'label' => __( 'your product video link (youtube/vimeo)', 'woocommerce' ), 'placeholder' => 'https://', 'desc_tip' => 'true', 'description' =>

xcode - Slow app compilation with new Sierra update -

when updated mac macos sierra 10.12.1 time of running application on real device increased. "run custom script 'embed pods frameworks'" , "copy swift standard libraries" take more 30 minutes build. do face same issue? check keychain. after updating sierra 10.12.1, had on 500 copies 1 of certificates, , few others duplicated few hundred times. i removed duplicates , kept 1 of each, , code signing time went 30 seconds per framework down 1 second per. i don't know how or why certificates duplicated, timing of issue suggests due updating sierra.

multithreading - java ThreadPoolExecutor time-out not honored -

in application have used thread pool, have specified timeout thread pool seems timeout not called, below code : import java.sql.timestamp; import java.util.arraylist; import java.util.date; import java.util.concurrent.arrayblockingqueue; import java.util.concurrent.executionexception; import java.util.concurrent.future; import java.util.concurrent.threadpoolexecutor; import java.util.concurrent.timeunit; import java.util.concurrent.timeoutexception; public class threadpooldemo extends thread{ public void run(){ system.out.println("starting---" + new timestamp((new date()).gettime()) + "--" + thread.currentthread().getname()); try { thread.sleep(30000); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } system.out.println("finishing---" + new timestamp((new date()).gettime()) + "--" +thread.currentthread().getname()); } public static void main (string[

data structures - How to insert 100 million entries in FireBase databas without painting myself into a corner -

i learning , trying understand how optimizing firebase databas use case. looking @ code below: lets us/street_address pushed 150 million entries(the number of street addresses in us), , want sort on "path": key, since unique identifier addresses. performance here when comes responce time? if setup regarding question not advicable how can change us/street_address ? reading fan-out dont think need because of no multichat or other multi anything. in case want create databas holdes intere worlds street addresses, whatever reason :). should denormalize us/street_address more, splitting 10 million entries us/a/street_address , us/b/street_address , us/c/street_address . can done since "path": "us/california/orange county/3138 e maple ave" in sample code below unique, , used key instead of firebase postsref.push() auto key, code sample use. still there 100 millions { "ae": { "name": "united arab emirates"

linux - Bash Script to loop through list to check server status -

i'm trying create script ping amongst other things, remote servers held in list. this have have, keep getting error: ./monitor_sats.sh: cannot make pipe command substitution: many open files. this code, helping. #!/bin/bash function ping { in `cat server_list` ping -c1 ${i} > /dev/null if [ ${?} -eq 0 ]; echo "$(tput setaf 2)on$(tput sgr0)" else echo "$(tput setaf 1)off$(tput sgr0)" fi done } echo "amsterdam - server $(ping) " echo "hong kong - server $(ping) " echo "london - server $(ping) " echo "singapore - server $(ping) " change function name below; #!/bin/bash function pingtoserver { in `cat server_list` ping -c1 ${i} > /dev/null if [ ${?} -eq 0 ]; echo "$(tput setaf 2)on$(tput sgr0)" else echo "$(tput setaf 1)off$(tput sgr0)" fi done } echo "amsterda

mysql - How get birthday with an interval, around New Year -

on website have overview of birthdays, 7 days 7 days forward current day. this working query: select * , date_format(birthday,'%m-%d') date_order employees date_add(birthday, interval year(curdate())-year(birthday) year) between date_sub(curdate(), interval 7 day) , date_add(curdate(), interval 7 day) order date_order asc but goes wrong last days in december , first days of january. how can change query, list this: birthdays: 2016/12/28: john 2016/12/30: (current day) ali 2016/12/31: mike 2017/01/04: mark

java - what is the special case that make `str1 == str2` a logical error? -

this question has answer here: how compare strings in java? 23 answers i know java stores string literals in common pool , 2 string literals having same text refer same place in common pool. take below code: string str1 = "amir"; string str2 = "amir"; now both str1 , str2 refer same place in common pool. know must use equals() compare these 2 strings , str1.equals(str2) true . now read here says str1 == str2 true becuase strings both have same address (sounds pretty logical) states logical error so. my question special case may cuase trouble , inconsistency code if use str1 == str2 ? not special cases, common cases: string base = "amir123"; string str1 = base.substring(0, 4); string str2 = "amir"; system.out.println(str1.equals(str2)); // true system.out.println(str1 == str2); // false live c

angularjs - Cannot inject a service to a config.js of a textangular button in jhipster -

i tried inject service returns interceptor's method config using: $injector.get() but returns "error: [$injector:unpr] unknown provider: tempservice". i've tried adding dependencies this: newprovide.$inject = ['$provide','$injector','tempservice']; // & function newprovide($provide,$injector,tempservice){ /* configurations */ }

java - Understanding Spark's closures and their serialization -

disclaimer: starting play spark. i'm having troubles understanding famous "task not serializable" exception question little different see on (or think). i have tiny custom rdd ( testrdd ). has field stores objects class not implement serializable ( nonserializable ). i've set "spark.serializer" config option use kryo. however, when try count() on rdd, following: caused by: java.io.notserializableexception: com.complexible.spark.nonserializable serialization stack: - object not serializable (class: com.test.spark.nonserializable, value: com.test.spark.nonserializable@2901e052) - field (class: com.test.spark.testrdd, name: mns, type: class com.test.spark.nonserializable) - object (class com.test.spark.testrdd, testrdd[1] @ rdd @ testrdd.java:28) - field (class: scala.tuple2, name: _1, type: class java.lang.object) - object (class scala.tuple2, (testrdd[1] @ rdd @ testrdd.java:28,<function2>)) @ org.apache.spark.serializer.serializationdebugger