Posts

Showing posts from July, 2012

c# - MVVM Validation in UWP -

in last week i've been trying apply mvvm pattern universal windows plataform, in elegant possible way, means apply solid principles , popular design patterns. i've been trying reproduce exercise link: http://www.sullinger.us/blog/2014/7/4/custom-object-validation-in-winrt also link windows 8 apps applies windows 10 apps according msdn answer @ forum: https://social.msdn.microsoft.com/forums/windowsapps/en-us/05690519-1937-4e3b-aa12-c6ca89e57266/uwp-what-is-the-recommended-approach-for-data-validation-in-uwp-windows-10?forum=wpdevelop let me show classes, view final view: <page x:class="validationtestuwp.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:validationtestuwp" xmlns:conv="using:validationtestuwp.converters" xmlns:viewmodels="using:validationtestuwp.viewmodel" xmlns:d="http://schemas.micros

Android RecyclerView not showing the right xml -

i'm trying use recyclerview show horizontal list of contacts. spend hours find error , don't understand why keep happening. application tinder-like. my row item : <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="80dp" android:layout_height="80dp" xmlns:tool="http://schemas.android.com/tools" android:background="@color/white" android:layout_margin="8dp"> <textview android:id="@+id/tv_conversation_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_alignparentbottom="true" android:textalignment="center" android:textcolor="@color/black" android:textsize=

c# - Why is EDM class a partial class -

i added new ado.net edm item in visual studio porject. using system; using system.data.entity; using system.componentmodel.dataannotations.schema; using system.linq; using system.diagnostics; namespace rajat.personal.ef { public partial class practicecontext : dbcontext { public practicecontext() : base("name=localcontext") { this.database.log = s => debug.writeline(s); } public virtual dbset<user> users { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<user>() .property(e => e.firstname) .isunicode(false); modelbuilder.entity<user>() .property(e => e.lastname) .isunicode(false); modelbuilder.entity<user>() .property(e => e.emailaddress) .isunicode(false); modelbuilder.entity<user>() .pro

mapreduce - Hadoop MR - HLL : Union of two different size HLL is throwing exception -

i'm using hll in mapreduce code. in combiner side, hll size of log2m=8, registerwidth=8 used store data. on reducer side, hll size of log2m=26, registerwidth=8 used union map side hll. i'm getting exception when trying union. 2 questions are, 1) possible union 2 different size hll? 2) if answer question 1 yes, missing? combiner: hll maphll = new hll(8,8) ; maphll.addraw(murmurhash64(userid)); valueobject.sethll(maphll); reducer: hll reducehll = new hll(26,8) ; for(iterator itr : values){ reduerhll.union(itr.gethll()); } also, i'm using hll tobytes & frombytes method serializing hll data. below exception stack trace, 17/04/06 10:56:20 info mapreduce.job: task id : attempt_1490152294761_13920_r_000040_1, status : failed error: java.lang.arrayindexoutofboundsexception: 4512149 @ net.agkn.hll.util.bitvector.setmaxregister(bitvector.java:201) @ net.agkn.hll.hll.addrawprobabilistic(hll.java:466) @ net.agkn.hll.hll.addraw(hll.java:373) @ net.agkn.hl

javascript - node git returning blame object -

i trying use nodegit nodegit.org blame of file using blame.file() returns me blame object rather actual git blame output. please correct me im using wrong. git.repository.open("./tmp").then((repo) => { git.blame.file(repo, "package.json", "-p").then((b) => { console.log(b); }); });

NodeMCU - ESPlorer unable to use custom builds ESP8266 -

i have esp-01, esp8266, 8mb i'm able flash nodemcu_float_0.9.5 ok, , use esplorer on baud 9600. responds ok, i'm able connect , load innit files. i tried use custom nodemcu firmware builder latest flasher tool, repeating same flashing process step above, flash successful esplorer cannot establish connection - acts baud rate not correct.(random symbols populating window) @ point have tried baud rates , firmware types (master, dev , frozen). any advice? here things can try. completely erase flash e.g. esptool.py --port /dev/ttyusb0 erase_flash then flash custom firmware again e.g. esptool.py --port /dev/ttyusb0 \ write_flash -fm dio 0x00000 nodemcu-master-18-modules-2017-03-27-08-03-59-float.bin try different flash mode. instance dio, qio... esptool.py --port /dev/ttyusb0 \ write_flash -fm qio 0x00000 nodemcu-master-18-modules-2017-03-27-08-03-59-float.bin try different baud rates e.g. 115200 i can't remember ever having used baud rat

javascript - how to create an alert prompt in the controller before redirecting to a new view? -

is possible create alert prompt in controller before redirecting new view? want make users acknowledge message in current view before directing them next view using system.web.mvc; using system.web.security; using mvcapplication.models; [httppost] public actionresult login(loginmodel model, string returnurl) { if (!this.modelstate.isvalid) { return this.view(model); } if (membership.validateuser(model.username, model.password)) { formsauthentication.setauthcookie(model.username, model.rememberme); ***// here! create alert close button using javascript , make user acknowledge clicking button , closing alert before redirecting user*** if (this.url.islocalurl(returnurl) && returnurl.length > 1 && returnurl.startswith("/") && !returnurl.startswith("//") && !returnurl.startswith("/\\")) { return this.redirect(returnurl); } r

java - Spring Security Authentication on Spring Boot using Spring Data JPA and Custom User/Group DB table -

i have spring boot project using mysql , hibernate , spring security dependencies. security pretty simple. each of different users belongs particular user group( eg. admin, customer, helpdesk etc ). codes below: users model @entity @table(name = "user") public class user extends baseentity implements serializable { private static final long serialversionuid = -999620920601692072l; @id @generatedvalue(strategy = identity) @column(name = "user_id", unique = true, nullable = false, insertable = false, updatable = false) private long id; @column(name="user") private string name; @column(name="user_password") private string password; @manytoone( fetch=fetchtype.lazy ) @joincolumn(name = "group_id", nullable = false) private usergroup usergroup; @manytoone( fetch=fetchtype.lazy ) @joincolumn(name = "status_id", nullable = false) private statususers status; public user() { } public user(user user) { this.name =

API JSON get ID from bash -

just wondering if me "snapshotid" first record output curl command outputs below? have tried jq "parse error: invalid numeric literal @ line 1, column 6" any other ideas? { "9875a8e4fc31f3":{ "snapshotid":"98758e4afc31f3", "date_created":"2017-04-05 10:16:17", "description":"centminmod", "size":"42949672960", "status":"complete" }, "b0d58e5b0d46e":{ "snapshotid":"b0d58e5b0d46e", "date_created":"2017-04-05 23:07:00", "description":"serverpilot", "size":"42949672960", "status":"complete" }, "d3158e6fbaa204":{ "snapshotid":"d3a158e6fba204", "date_created":"2017-04-06 22:38:26", "descrip

javascript - How to avoid reading previous JSON array value which are stored in page before page refresh -

Image
i want avoid reading previous objects pushed in json array. shown in image. i'm self learning these concepts. need help, right method add , read values. also dont know how ask question technically. appreciate if tell me how question should asked. can atleast improve better understanding. jquery $("#click").click(function(event) { event.preventdefault(); var $form = $('#myform'); var $boxes =$("input[id=mycheckboxes]:checked").length; if($boxes==0) { alert("choose atleast 1 category"); } else if($form.valid() && $boxes>0) { //if form valid action performed var data = $( "#myform" ).serializearray();//serialize data var valuesarray = $('input:checkbox:checked').map( function() { return this.value; }).get().join(","); data.push({ name: 'panel', value: valuesarray}); //convert json array object var loginfor

javascript - jquery mouseleave animation sometimes freeze -

i'm trying create when mouse on over image box, texts slide in left, right , when on mouse leave, texts slide out left, right. here's link actual project im on. below codes exact codes used unto referred site. can see if mouse over, animation triggered once on mouse leave, texts wont animate out (slide out right, left) , no animation triggered or texts wont hide. please check referred link, can see abnormalities there. help, ideas please? have tried .stop() but seems not working. $(window).load(function(){ $('.hover-box-image').mouseover(function(){ var dis = $(this); dis.find('.hover-box-image-text').show(); //animate hover box image text left dis.find('.hover-box-image-text[data-position="left"]') .stop().animate({ 'left' : dis.find('.hover-box-image-text[data-position="center"]').offset().left-dis.closest('.hove

c - Alsa library configuration -

i using alsa library find maximum value of sound samples stereo output.i using s32_le pcm format. python code , can able acheive max values instantaneously. c alsa lib ,instant values not able get. please me solve . have attached python script c code reference. python code: #!/usr/bin/env python import alsaaudio, time, audioop, math card = 'sysdefault:card=default' inp=alsaaudio.pcm(alsaaudio.pcm_capture,alsaaudio.pcm_normal,card) inp.setchannels(1) inp.setrate(64000) inp.setformat(alsaaudio.pcm_format_s32_le) inp.setperiodsize(1024) val=0 loop=0 myarr=[] count=math.pow(2,24) while true: l,data=inp.read() if l: amplitude=audioop.max(data,4) val=int(amplitude) val=val>>8 if val > 0: db=(20* math.log(val/count))+120 c code: #include <alsa/asoundlib.h> #include <stdio.h> #include <math.h> #define pcm_device "default" int max=0

python - Is there a Windows equivalent to PyVirtualDisplay -

i have written web scrapper mate save him time @ work. written in python , using selenium , opening firefox browser. when write type of code myself on linux machine use pyvirtualdisplay firefox doesn't open , disturb work. how can make run within virtual display on windows pc?

sql - Simple query: mysql - very slow , mariadb - good performance -

simple query: select * data.staff staff left join data.contact workphones on staff.id = workphones.staff_with_work_phone_id mysql run time: 5.3 sec. mariadb run time: 0.016 sec. contact has ~50000 rows. staff has ~600 rows. what reason? possible achieve same result on mysql? thank you! explain mysql (v5.7.14): +----+-------------+------------+------------+------+--------------------------------+------+---------+------+-------+----------+---------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | | +----+-------------+------------+------------+------+--------------------------------+------+---------+------+-------+----------+---------------------------------------+ | 1 | simple | staff | null | | null | null | null | null | 606 | 100.00 | null

wordpress - Can I duplicate the Easy Digital Downloads plugin , give it another name and use it along with EDD as a different store? -

can duplicate easy digital downloads plugin (wordpress), give name , use along edd different store? my client wants add 3 services separately, not want use them separate categories want them 3 different post types. duplicating plugin work? thanks in advance, charles

amazon web services - Not able to register Snapshot repository for AWS es domain -

i trying register snapshot repository. have used below role , policy: { "version": "2012-10-17", "statement": [{ "sid": "", "effect": "allow", "principal": { "service": "es.amazonaws.com" }, "action": "sts:assumerole" }] } and policy below: { "version": "2012-10-17", "statement": [{ "action": ["s3:listbucket"], "effect": "allow", "resource": ["arn:aws:s3:::es-backuptest"] }, { "action": ["s3:getobject", "s3:putobject", "s3:deleteobject", "iam:passrole"], "effect": "allow", "resource": ["arn:aws:s3:::es-backuptest/*"] }] } and using below python script:

Confusion about x < y <= z in python -

this question has answer here: why expression 0 < 0 == 0 return false in python? 9 answers is `a<b<c` valid python? 3 answers i'm newbie in python. have 3 variables x , y , z int . have comparison 3 variables in if condition. i'm confused following code result. the expression x < y <= z evaluates false. let's assume x = 10 , y = 5 , z = 0 . if x < y become false , false <= 0 become true . but output false. why? my python script: #!/usr/bin/python x = 10 y = 5 z = 0 if (x < y < z): print"true" else: print"false" the document say: comparisons can chained arbitrarily; example, x < y <= z equivalent x < y , y <= z, except y evaluated once (but in both cases z no

javascript - Force a background image to be loaded before other background images -

is there way force downloading specific image (priority image) before other images downloaded? i use many background images. landing page has gradient fill used second image of landing page. landing page css: .bg-img1::before { background-image: url(https://mywebsite/images/myimage.jpg), linear-gradient(to top, #206020, white); background-size: cover, cover; } i switched using dom ready detection background image gradient displaying 3 or 4 seconds before landing page image downloaded... $(function() { // dom ready, image hasn't downloaded yet. }); now use window.onload , working fine, adding more , more images , downloading delay becoming substantial. window.onload = function() { // delay, delay... landing page gradient displays }); to reiterate question, able make downloading landing page priority. there way ensure background image displays before gradient displayed if switch using dom ready? add image tag , place source in it. make sure add

C++ void pointers -

pthread_mutex_t mutexread; int main(int argc, char *argv[]){ pthread_t readerthreads; pthread_mutex_init(&mutexread, null); string *fname; cin>> *fname; pthread_create(&readerthreads, null, reader_thread, (void*) fname); } void *reader_thread(void *param){ string fname = *(string *) param; cout<<"filename "<< fname<<endl; ifstream myfile(fname.c_str()); return null; } the code above throw segmentation fault. messed pointers, not know went wrong , how can fix it? you declared pointer string , use string , pass address. pthread_mutex_t mutexread; int main(int argc, char *argv[]){ pthread_t readerthreads; pthread_mutex_init(&mutexread, null); string fname; cin>> fname; pthread_create(&readerthreads, null, reader_thread, (void*) &fname); pthread_join(&readerthreads,null); } void *reader_thread(void *param){ string fname = *(string *) param;

windows - Python: Pass a "<" to Popen -

i want start testrunner.bat of readyapi parameters. try pass xml parts (periodend in code below) arguments subprocess.popen: argslist = ['c:/program files/smartbear/readyapi-1.9.0/bin/testrunner.bat', '-a', '-s', 'testsuite', '-c', 'testcase', '-f', 'c:/temp/', '-p', 'periodend=<periodend>2017-04-11t00:00:00.000z</periodend>', 'c:/temp/soapui-project.xml'] proc = popen(argslist, stdout=pipe, stderr=pipe) this produces following error: the system cannot find file specified. i found out, "<" , ">" problems. how can escape them or pass them popen? the escape character in cmd ^ . c:\> echo asdf<123> syntax of command incorrect. c:\> echo asdf^<123^> asdf<123>

php - Magento product image not uploading in localhost -

Image
product image not getting upload on localhost, whenever click "upload images" shows red border on images , not uploading. thing working fine @ live site

font awesome - increase clickable area around tiny icon -

i using font awesome icon ellipsis-v (which tiny; see here ) in clickable row, it's frustrating click, because of time end clicking on row. tried putting link on td, it's not working (because whole row clickable?). are there css tricks increase clickable area around fa-icon? (below code tried) <tr class='clickable-row' data-href='details.html'> <td></td> <td class="client-status"><span class="label label-warning"></span></td> <td> <a class="dodropdown"> <div class="ibox-tools"> <a class="dropdown-toggle dodropdown" data-toggle="dropdown"> <i class="fa fa-ellipsis-v"></i> </a> <ul class="dropdown-menu"> <li> <a href="details.html">view</a> </li> <li>

how to activate kite in pycharm? -

Image
i have downloaded exe file,install it, verify email, not work in pycharm, can't find solutions google. , offical website of kite has no specific tutorial this. in advance. download .dmg file , open it. ask programs you'd activate kite. select pycharm , you're gtg.

Still behind the origin after git pull -

i have cloned repository behind origin x commits. git pull looks works fine, compressing, receiving etc. when try git status after git pull there's message i'm still behind. cause of problem? that's message after git status : on branch release/xxxx branch behind 'origin/release/xxxx' 351 commits, , can fast-forwarded. (use "git pull" update local branch) nothing commit, working tree clean` pull branch name: $ git pull origin release/xxxx note: running git pull origin/release/xxxx (give space instead '/' after origin )

android - Application force close when printer device off -

i developed app can connect device printer. firstly connect app device, when printer device off application force closed, dont know why happens on devices. below script connect it: public boolean openbtbyaddress(context _context,string address) { activity activity = (activity) _context; boolean cek = false; try { mbluetoothadapter = bluetoothadapter.getdefaultadapter(); if(mbluetoothadapter == null) { // mylabel.settext("no bluetooth adapter available"); toast.maketext(_context,"no bluetooth adapter available",toast.length_short).show(); cek= false; } if(!mbluetoothadapter.isenabled()) { intent enablebluetooth = new intent(bluetoothadapter.action_request_enable); activity.startactivityforresult(enablebluetooth, 0); } set<bluetoothdevice> paireddevices = mbluetoothadapter.getbondeddevices(); if(paireddevices.size() >

javascript - localstorage value is changed on page refresh -

i creating welcomescreen html app. , im using welcomescreen plugin github. can check here https://github.com/valnub/welcomescreen.js now want show welcome screen when localstorage value 0. , when close button of welcomescreen clicked changing localstorage value 1. on page refresh localstorage value again set 0. how js file. /*jslint browser: true*/ /*global console, welcomescreen, $*/ // init method $(document).ready(function () { localstorage.setitem("welscreen", "0"); var welcometour = localstorage.getitem("welscreen"); if (welcometour == 0) { $(document).ready(function () { var options = { 'bgcolor': '#0da6ec', 'fontcolor': '#fff', 'onopened': function () { console.log("welcome screen opened"); console.log(welcometour); }, 'onclosed': function () { locals

hadoop - chainReducer notworking -

i used map1->reduce1->map2 sequence, not able map2 output. instead, reduce1 output. here driver code: public static void main(string[] args) throws exception { configuration conf = new configuration(); conf.set("mapred.textoutputformat.separator",":"); job job = job.getinstance(conf, "lsh1"); configuration mymapper = new configuration(false); chainmapper.addmapper(job, mymapper.class, longwritable.class,text.class,longwritable.class, text.class, mymapper); configuration reduceconf = new configuration(true); chainreducer.setreducer(job, reducer1.class, text.class, longwritable.class,text.class,longwritable.class, reduceconf); configuration reducer2 =new configuration(false); chainreducer.addmapper(job, reducer2.class, text.class, longwritable.class,text.class, longwritable.class, reducer2);` fileinputformat.addinputpath(job, new path(args[0])); fileoutputformat.setoutputpath(job, new path(arg

Create model class for XML files with multiple hierarchical levels using JAXB and Java -

i'm working jaxb , try create model class xml-file multiple hierarchical levels. in first try created every xmlwrapper seperated modelclass, guess theres way handle in 1 class. the proper way not put in 1 class, instead use several classes: a class notesdocument , annotated @xmlrootelement(name="notes_document") a class item a class value not needed, string enough the notesdocument class contain among other things: private list<item> items; @xmlelementwrapper(name="items") @xmlelement(name="item") public list<item> getitems() { return items; } the item class contain similar construct list<string> values . you figured out correctly how use @xmlelementwrapper(name="items") , don't need separate class items modeling <items> collection. same go modeling <values> collection. i think that's enough details you, don't want spoil learning experience. ;-)

stanford nlp - Does Tokens Regex have support for dependency annotations? -

i building rule based ner platform , wanted know if make use of dependency based patterns identify named entities. e.g cyld inhibits ubiquititnation of both traf2 , traf6. here use prep_of relation/pattern identify proteins traf2 , traf6 trigger being ubiquitination.(as mentioned in odin's runes research paper). if tokensregex support dependency annotations please share example of how implemented in rules file? ever grateful! naively no. but, work around attaching custom annotations corelabel s; e.g., have annotation incoming dependency arc. then, can have tokensregex pattern on custom annotation key.

reactjs - React doesn't change to LoggedInView when Meteor user logs in -

i developing react + meteor application , i'm having trouble user login functionality. i have header navbar displays different component based on whether or not user logged in. like this: export default class header extends component { constructor(props) { super(props) this.state = { user: meteor.user() } } render() { return ( <header classname="main-header"> <nav classname="navbar navbar-static-top"> <div classname="navbar-custom-menu"> {this.state.user() !== null ? <loggedinnavigation /> : <loggedoutnavigation />} </div> </nav> </header> ) } } now works doesn't change upon user being logged in. have refresh page in order change views (which not ideal). here login code: meteor.loginwithpassword(th

android - how could I refresh a webview? -

so made website turned mobile app using webview. when first time install apk, work problem after that, web static or it's not loaded anymore. it open same content first time install though change whole website. don't know if problem webview or android. i try made auto refresh/autoreload function in php work in mobile browser , didn't work in app... know solution? since i'm newbie in android developping i'll put whole code of main activity public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { //initializing webview private webview mwebview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new

javascript - Regex URL validation for angularjs -

i'm trying create validation url accept following cases http or https or without, www or without, subpages or without http://website.com https://website.com http://website.com/ http://www.website.com website.com http://website.com/page/id/sdf i tried following, did not cover cases above $scope.urlpattern = '^(([a-z]+[.])?[a-z0-9-]+([.][a-z]{1,4}){1,2}(/.*[?].*)?$' $scope.urlpattern = '^((https?|ftp)://)?([a-z]+[.])?[a-z0-9-]+([.][a-z]{1,4}){1,2}(/.*[?].*)?$' i not have permission add comment, editing answer only. below link has type of url validation, hope you: all type url validation link if want validate url, don't need concern 'www' condition (since included in other condition) something simple can done this: '^(https?:\/\/)*[a-z0-9-]+(\.[a-z0-9-]+)+(\/[a-z0-9-]+)*\/?$' jsfiddle: https://jsfiddle.net/q0d69jq3/2/

addition - add up all 1 bits in x86 assembly -

i don't have clue of i'm doing... goal add 1's , if , if odd c/c++ section gives variables passed asm #include <stdint.h> #include <stdio.h> #include <iostream> using namespace std; extern "c" { bool isbitcounteven(int32_t); } static int32_t testdata[] = { 0x0, 0x1, 0x2, 0x4, 0x8, 0x40000000, 0x80000000, 0x00000002, 0xe, 0xff770001, 0xffeeeeff, 0xdeadbeef, 0xbaddf00d, 0xd00fefac, 0xfaceecaf, 0xffffffff, 0xaaaa5555 }; #define num_test_cases (sizeof (testdata) / sizeof (*testdata)) int main() { printf(" ice#10 \n\n"); (int = 0; < num_test_cases; i++) { printf("isbitcounteven(0x%8x) yields: %s\n", testdata[i], isbitcounteven(testdata[i]) ? "true" : "false"); } system("pause"); return 0; } and asm. doesn't output anything. prologue , epilogue things ive copped , pasted other work