Posts

Showing posts from September, 2012

javascript - Mansory works only after refreshing (jquery) (Ruby on rails) -

my posts.js.coffee $ -> $('#posts').masonry itemselector: '.box' $container = $('#posts') $container.imagesloaded -> $container.masonry() return return work after refreshing page, otherwise have posts in 1 column. 1 after other. can do? answers i solved problem using jquery-turbolinks gem when configured app jquery-turbolinks documentation mansory gem works well!

In python, is there a simple way to pass 1+ args to pool.map -

i want use pool.map simplify concurrency in scripts , find same question below link, not concise method issue. python multiprocessing pool.map multiple arguments from multiprocessing.dummy import pool threadpool def run_multiple_args(tuple_args): args_1 = tuple_args[0] args_2 = tuple_args[1] print args_1, args_2 pool = threadpool(2) arg_list = [(1,2), (4,8)] pool.map(func=run_multiple_args, iterable=arg_list) pool.close() pool.join() i want use def run_multiple_args(args_1, args_2): replace tuple_args . no 3rd party lib, less code more better. idea? you can use lambda unpack argument tuple: from multiprocessing.dummy import pool threadpool def run_multiple_args(args_1, args_2): print args_1, args_2 pool = threadpool(2) arg_list = [(1,2), (4,8)] pool.map(func=lambda args: run_multiple_args(*args), iterable=arg_list) # <-- see here pool.close() pool.join()

java - Checking out code from github into netbeans/ecplise -

Image
it first time trying checkout else code github. i have downloaded jar https://github.com/wittawatj/jtcc however, there src folder unsure of how insert netbeans or ecplise without having rename packages , classes. i believe there shorter way. i edit java code own source code make tweaks for netbeans can directly clone source repository within netbeans: use team -> git -> close checkout source code github , supply necessary information in following dialog: in final page of wizard can enable "scan netbeans project" option: as project not contain netbeans project, netbeans prompt create new project after code has been downloaded: use option "java project existing sources" setup netbeans project sources github. details on setting project in netbeans can found in manual: http://docs.oracle.com/cd/e50453_01/doc.80/e50452/create_japps.htm#babcgjjb

linux - Trying to redirect in script -

i'm trying redirect results of zgrep directory using shell script. but, i'm getting following error. line 7: /home/johnm/http_files/: directory #!/bin/bash files=/data/log/2015/09 file in $files echo "processing $file" zgrep 'sans' $file > /home/johnm/http_files/ done thank you. you have redirect file not directory. add file name after path , should work ok.

java - Get concrete Class realization from interface reference -

is possible in java obtain concreetclass.class interface reference isomeinterface . avoid 'instance of' keyword. on other words, there: isomeinterface intref = new concreetclass(); class realization = intref.getrealizationclass(); realization == concreetclass.class; // true if java doesn't support operation. recommend me way deal it? getclass returns class of instance . class<? extends isomeinterface> realization = intref.getclass(); system.out.println(concreetclass.class.equals(realization)); //true

c++ - Array of structs prints zeros when called, but displays correct input when not called (short code) -

the purpose of program bank account interface, user can create 4 accounts , can transfer funds between them. opted array of structs handle “bank account” info, , switch handle user options. problem: the account creation function, called in case ‘a’, appears create accounts intended, , displays them properly. however, results in other cases not designed. case ‘b’ display inputted array information, only if nothing called (including function displays array information), otherwise when display() called prints zeros (what initialized before account creation). case ‘c’ display inputted array information if nothing called, if function displays date/time called. otherwise prints zeros. question: why array of structs displaying zeros when call display function, display user input when it’s not called, long nothing else (except time function in case ‘c’), , can fix it? notes: i converted account creation function return pointer struct hoping might help, didn’t seem change a

python - Web2py - Sharing a list among modules -

i have list of id's, got database insertion, send other functions in other modules. have main module asd.py , want share list id_list functions in other 2 modules : foo.py , bar.py . simply: in asd.py def asd(): id_list = list() # insertion append id_list foo.f1(id_list) bar.f1(id_list) my question id_list copied value or reference, assume big list. , approach "performance-wise" ? thank you. id_list copied reference, although mutable objects weird edge-case in regard. if foo.f1 call executes id_list = 7 , copy of id_list in asd function not change. however, if foo.f1 calls id_list.append(9) , 9 appear @ end of id_list in asd function call. there no implicit copying of list.

javascript - Unable to export table to excel using tableExport -

i have scripts mentioned , searching have written following html code: <table id="customers" class="table table-striped" > <thead> <tr class='warning'> <th>country</th> <th>population</th> <th>date</th> <th>%ge</th> </tr> </thead> <tbody> <tr> <td>chinna</td> <td>1,363,480,000</td> <td>march 24, 2014</td> <td>19.1</td> </tr> <tr> <td>india</td> <td>1,241,900,000</td> <td>march 24, 2014</td> <td>17.4</td> </tr> <tr> <td>united states</td> <td>317,746,000</td> <td>march 24, 2014</td> <td>4.44</td> </tr> <tr> &l

How to convert a String consisting of Binary Number to Hexa Decimal no in Java? -

my string 010101010111111111101010101010101010111101010101010101010101 , large in size (more 64 characters). i cannot use integer or long class parse methods due size limitation. expected output 557feaaaaf55555h . use biginteger this: string s = "010101010111111111101010101010101010111101010101010101010101"; biginteger value = new biginteger(s, 2); system.out.println(value.tostring(16)); this shows: 557feaaaaf55555 or exact output: system.out.println(value.tostring(16).touppercase() + "h");

Why the keyup event is not fired on an element in JavaScript while moving the mouse with the left button held down? -

i guess came across pretty strange (to me) situation. have "keyup" event bound div (with tabindex set, of course) contains google map. need disable map dragging functionality when shiftkey pressed down , enable again when key goes up: mapelement.setattribute("tabindex", 0); mapelement.focus(); google.maps.event.adddomlistener(mapelement, "mouseover", function(e) { mapelement.focus(); }); google.maps.event.adddomlistener(mapelement, "mouseout", function(e) { mapelement.blur(); }); google.maps.event.adddomlistener(mapelement, "keydown", function(e) { var isshift; if (window.event) { isshift = !!window.event.shiftkey; } else { isshift = !!e.shiftkey; } if (issh

stream - stringstream >> uint8_t in hex? c++ -

i confused output of following code: uint8_t x = 0, y = 0x4a; std::stringstream ss; std::string = "4a"; ss << std::hex << a; ss >> x; std::cout << (int)x << " "<< (int)y << std::endl; std::cout << x << " "<< y <<std::endl; std::cout << std::hex << (int)x << " " << (int)y << std::endl; uint8_t z(x); std::cout << z; the output above is: 52 74 4 j 34 4a 4 and when change replace first line with: uint16_t x = 0, y = 0x4a; the output turns into: 74 74 74 74 4a 4a j i think understand happens don't understand why happens or how can prevent it/work around it. understanding std::hex modifier somehow undermined because of type of x , maybe not true @ technical level writes first character reads. background: input supposed string of hexadecimal digits, each pair representing byte( bitmap except in string). want a

c - Return pointer to a subarray -

let's have function has char array parameter , char* return type. want return pointer subarray of parameter array. for example : char str[] = "hi billy bob"; i want function return "billy bob" ; let's in body of function able index of want subarray start. char* fun(const char s1[]) { int index = random int; /* char *p = *(s1[index1]); */ return p; } i'm having trouble commented out line. simply use const char *p = &str[index]; /* may write p = str + index */ return p; the above takes address of character @ index index -- pointer char array beginning @ index. string continues until first '\0' character end of original str . in case, if want output "billy bob" (note cannot change capitalization unless modify string or return new one) should set index = 3; . it gets more involved when want take substring of str . either have set str[end_index]='\0' or use malloc allocate new

r - Seed function in Brownian motion -

when simulate brownian motion, need 10 20 seeds in r. code following, think fixed seed , how create under different seeds, thank you u <- 0.05 sigma <- 0.2 t <- 1 steps <- 252 s0 <- 100 dt <- u / steps set.seed(10:20) epsilon_t_vec <- rnorm(steps) epsilon_t_vec <- append(0, epsilon_t_vec) dwt_vec <- epsilon_t_vec * sqrt(dt) st_vec <- c() st_vec[1] <- s0 for(i in 1:steps) { dwt <- dwt_vec[i+1] st_vec[i+1] <- st_vec[i] + u * st_vec[i] * dt + sigma * st_vec[i] * dwt } st_vec you can this. seed being changed in second loop every time , output appended list length of seeds. u <- 0.05 sigma <- 0.2 t <- 1 steps <- 252 s0 <- 100 dt <- u / steps seeds <- 10:20 st_vec <- list() for(s in 1:length(seeds)) { set.seed(seeds[s]) epsilon_t_vec <- rnorm(steps) epsilon_t_vec <- append(0, epsilon_t_vec) dwt_vec <- epsilon_t_vec * sqrt(dt) st_vec[[s]] <- c(s0) for(i in 1:steps) { dwt <- dwt_vec[i

unit testing - Java Refactoring Strategy for Legacy Code -

i have been asked unit test legacy code. currently, code tightly coupled 3rd party library both in terms of method calls , types used. my first thought stub 3rd party library (using appropriate mocking framework) such can test code of interest rather 3rd party library. however, this, need refactor of code code of interest isolated external library dependency. my initial thought extract interface , use wrapper make calls library. however, entirely decouple library need remove library specific types too, not method calls e.g. libraryspecifictype[] myvar = wrappedlibrary.dox(); although have wrapped library call in above example, still returns library specific type, still coupled. how around this? best strategy refactor code enable this? thanks! i agree producing facade third party lib idea. talk facade , not 3rd party lib. place lib referred in facade. the issue libraryspecifictype bit more problematic. again wrap them help? not sure as testing. use mockito/

html - Highlight Deepest Child DOM Element with Div Overlay when Moused Over in Pure Javascript -

the short version: i want mimic google chrome's inspect element tool in pure javascript. the long version: i working on extension google chrome. want implement similar inspect element tool in pure javascript (no jquery or other libraries/frameworks/dependencies) . if uses adblock, want mimic "block ad on page" functionality allows user select element on page. while extension active, user should able to: mouse on element if 'p' element 'code' element nested inside being moused over, entire 'p' element should have 'div' overlay on if mouse moves on nested 'code' element should re-size 'div' overlay cover only deeper nested 'code' element when clicked, underlying element should stored , 'div' overlay hidden why use 'div' overlay instead of adding class element adds border/outline/background color? the overlay prevents user directly interacting element. if there href/on

javascript - When I get the cookie, it is null -

Image
i want cookies have setted, when use console.log(document.cookie), value null.why? code: document.cookie="name=hi"; document.cookie="displayname=hello"; var strcookie=document.cookie; console.log(strcookie); //output '' why? query relevant information, dont's find solution of problem.can me? thank you!

python - Thinking Recursively when it comes to list manipulation -

from random import * def number(n): if n>0: return [ choice( [0,1] ) in range(n)] else: return ("only positive #'s!") how recursively? let's n=5 , [0,1,2,3,4] each # replaced either 0 or 1 . can't seem wrap head around doing list manipulation recursively. here's 1 option: from random import choice # don't use * imports def number_recursive(n): if n < 0: raise valueerror('n must positive') if n == 0: return [] return [choice((0, 1))] + number_recursive(n-1) note raising of error rather returning string; tells caller more directly went wrong.

c# - multiply textbox value by factor from combobox? -

i have textbox numeric input. , combobox, list of factors 'behind' it. i want have combobox multiply value visible in textbox factor chosen list, each time change combobox choice. way go here? sorry, not clear: say, value in tb 3. chose cb item (the 1 says "10") , tb value multiplied 10. next time chose cb item (the 1 says "100"), original value of tb box multiplied 100. use convert input textbox int: int = int32.parse(textbox1.text); maybe paste code in? can better way

java - Access the method inside the addMouseListener() method -

i want return count of mouse clicks every time panel clicked. have basepanel class has code snippet: basepanel(){ //inside basepanel class addmouselistener(new mouseadapter(){ public void mousereleased(mouseevent e){ if(clicked == troop1){ count1--; count = count1; //i want count accessible in class system.out.println("troop1 count: "+count); }else if(clicked == troop2){ count2--; count = count2; system.out.println("troop2 count: "+count); } } public int getcount(){ //how can method accessible in class return count; } }); } here, wanted return count variable. want buttonspanel class able access getcount() method in basepanel class. buttonspanel(){ //inside buttonspanel class basepanel pane =

sql server - Sql query with join and group by and -

Image
i have 2 table in sql. first 1 patient list, second 1 report. patient's reports in report, id can join them. each patient has reports (maybe fields of record not filled). want make report last report of each patient if field empty in last record of patient should fill last filled record of patients records. have date in table of reports. i want patients. here add pic 1 patient example in example above, want highlighted ones patient in report. i have write query give when filed in last record null while has data in previous records. select patient.bartar_id,patient.bartar_enteringthesystem,patient.bartar_proviencename, patient.bartar_cityname,patient.bartar_coloplastrepname,patient.bartar_consultorname, patient.bartar_provienceofsurgeryname,patient.bartar_cityofsurgeryname, patient.bartar_surgeryhospitalname,patient.bartar_doctor,patient.bartar_patientstatusname, patient.bartar_ostomytypename, patient.bartar_ostomytimename, r.bartar_d

html - javascript return URL onClick -

i have html form dropdown list of car models , blank frame below that. i'd display url related selected car in frame when submit button pushed. have working , displays current cars value in frame, don't know how insert , have js return url value. the js goes this: (and may wrong i'm new stuff...) function carformselect (form) { var car = form.selcar.value; if (car == 'camry'){ document.queryselector('.carselected').innerhtml = (car); } html this: <select id="selcar" name="selcar"> <option value="camry">camry</option> <option value="corolla">corolla</option> </select> i'm assuming need url placed (car) is. tried putting url in quotes didn't work. appreciated. thanks! you can using jquery/ajax request. you need value when user clicks on select element , send page have iframe treated src want (in case car site)

android - EditText doesn't work inside AlertDialog v7 -

i using alertdialog v7 create custom dialog. inside custom view have edittext inputtype "phone|numberpassword". in case when try type text - doesn't work, mean edittext doesn't show changes, new symbols... here custom view alertdialog: <linearlayout android:id="@+id/ll_login_reglayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="visible" android:paddingright="@dimen/dialog_padding" android:paddingleft="@dimen/dialog_padding" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <edittext android:id="@+id/et_p1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="phone

python - generalisation between vector and matrix, matrix and tensor with numpy ndarray -

i found interesting thing when comparing matlab , numpy. matlab: x = [1, 2] n = size(x, 2) % n = 1 python: x = np.array([1, 2]) n = x.shape[1] # error the question is: how handle input may both ndarray shape (n,) , ndarray shape (n, m). e.g. def my_summation(x): """ x : ndarray each column of x observation. """ # solution ndarray shape (n,) # if x.ndim == 1: # x = x.reshape((-1, 1)) num_of_sample = x.shape[1] sum = np.zeros(x.shape[0]) in range(num_of_sample): sum = sum + x[:, i] return sum = np.array([[1, 2], [3, 4]]) b = np.array([1, 2]) print my_summation(a) print my_summation(b) my solution forcing ndarray shape (n,) shape (n, 1). the summation used example. want find elegant way handle possibility of matrix 1 observation(vector) , matrix more 1 observation using ndarray. does have better solutions? i learned numpy.atleast_2d python control toolbox. don'

java - How to enable SSL for Oracle connections in JDBC from Rails? -

i have rails application (running on jruby) connecting oracle database, database.yml looks this: default: &default adapter: jdbc username: ... password: ... driver: oracle.jdbc.driver.oracledriver development: <<: *default url: jdbc:oracle:thin:@host:1526 as far i'm aware, oracle supports using tls connect database, how enable in database.yml ?

java - Polymorphism on simple example -

i think i'm starting understand topic, not completely. can explain me on example: public class solution { public static void main(string[] args) { cow cow = new whale(); system.out.println(cow.getname()); } public static class cow { public string getname() { return "im cow"; } } public static class whale extends cow { public string getname() { return "im whale"; } } } what difference when called this: cow cow = new whale(); system.out.println(cow.getname()); and this: whale whale = new whale(); system.out.println(whale.getname()); i have same output, in cases or maybe when should call methods cow class, , when form whale class. sorry if gave stupid or simple example. hope undeerstood wanted say. in advance. it's question understand polymorphism. not sure whale should extends cow ;), can show bit of different st

Query works in Sql Server Management Studio, but not ColdFusion with MSSQL -

update: strange clue--if change table1 table3, works in cf. figured dropping table clear out. somehow being zombie. how fix? this iteration of question "query works in sql server management studio, not in...." this code, copied , pasted, works in ssms, not in coldfusion query. get: error executing database query. [macromedia][sqlserver jdbc driver][sqlserver]invalid column name 'studentid'. sql: if object_id('tempdb.dbo.##table1') not null drop table ##table1 create table ##table1 ( [recordid] [integer] identity not null, [studentid] [varchar](15) not null, [coursenumber] [varchar](6) not null, [compdatetime] [datetime] not null, [systeminfo] [varchar](250) null, [writetime] [datetime] default getdate() null, primary key clustered ( [studentid], [coursenumber], [compdatetime] ) ); insert ##table1 (studentid, coursenumber, compdatetime, systeminfo, writetime) valu

c# - How to draw a circle on Canvas? -

i'm newbie in wpf , doing mypaint application. when draw circle or square in canvas, follow mouse when move along oy pivot. have no idea solve problem. here . reading. point p1, p2; point currclick; //int = 0; //private bool flag = true; rectangle myline; solidcolorbrush scb = new solidcolorbrush(colors.black); private void mycanvas_mouseleftbuttondown(object sender, mousebuttoneventargs e) { p1 = e.getposition(mycanvas); myline = new rectangle(); myline.stroke = scb; myline.strokethickness = 1; doublecollection mydash = new doublecollection { 5, 3 }; myline.strokedasharray = mydash; canvas.setleft(myline, p1.x); canvas.settop(myline, p1.y); //myline.fill = scb; mycanvas.children.add(myline); } private void mycanvas_mousemove_1(object sender, system.windows.input.mouseeventargs e) { if

linux - Invalid compressed data--format violated? -

i want extract data xxx.tar.gz file using tar -zxvf command, wrong occurs me, here's detail: suse11-configserver:/home/webapp/wiki # tar -zxvf dokuwiki.20151010.tar.gz ./dokuwiki/ ./dokuwiki/._.htaccess.dist ./dokuwiki/.htaccess.dist ./dokuwiki/bin/ ./dokuwiki/conf/ ./dokuwiki/._copying ./dokuwiki/copying tar: jump next head gzip: stdin: invalid compressed data--format violated tar: child returned status 1 tar: error not recoverable: exiting but command tar -zxvf dokuwiki.20151010.tar.gz goes in macos x system, can not figure out reason. your command correct. seems file corrupted. it's easy tell, when files correctly extracted (for example ./dokuwiki/.htaccess.dist ), not rest. recreate dokuwiki.20151010.tar.gz file, , make sure doesn't report errors while doing so. if downloaded file somewhere, verify checksum, or @ least file size. the bottomline is, either file incorrectly crea

vb.net - Datagridview to CrystalReport Error "Input array is longer than the number of columns in this table." -

i trying datagridview data crystal report, getting error message "input array longer number of columns in table." any idea how fix error? sub printtocr() dim dt new datatable each dr datagridviewrow in me.datagridview1.rows dt.rows.add(dr.cells("productid").value, dr.cells("brandname").value, dr.cells("genericname").value, _ dr.cells("expirationdate").value, dr.cells("price").value, _ dr.cells("unit").value, dr.cells("quantityonhand").value) '<<<<< error here. next ' dim rptdoc crystaldecisions.crystalreports.engine.reportdocument rptdoc = new crystalreport1 rptdoc.setdatasource(dt) ' crystalreportviewer.crystalreportviewer1.reportsource = rptdoc crystalreportviewer.showdialog() crystalreportviewer.dispose() end sub this database transaction public class data dim connstring new

r - Convert spline interpolation to linear interpolation? -

this function below doing job spline interpolation wonder how can modify linear interpolation instead! ## function interpolate using spline imagespline = function(x, y, xout, method = "natural", ...){ x.max = max(xout) x.spline = spline(x = x, y = y, xout = xout, method = method, ...) x.spline } see ?approx approx() , approxfun() . these linear interpolation counterparts spline() , splinefun() . depending on detail of linear interpolation want perform (see ?approx details , things tweak), simple as: imageapprox <- function(x, y, xout, ...) { x.linear <- approx(x = x, y = y, xout = xout, ...) x.linear }

java - Android alarm manager does not wait -

i try start simple method every 20 seconds, idea start alarm in method again. create class again, in method executed , starting alarm... , on method should create notification. public class createnotification extends broadcastreceiver{ public void onreceive(context context, intent intent) { dostuff(); notificationcompat.builder mnotebuilder = new notificationcompat.builder(context) .setsmallicon(r.drawable.icon) .setcontenttitle("...") .setcontenttext(shownstring) //get instance of notificationmanager service notificationmanager mnotifymgr = (notificationmanager) context.getsystemservice(context.notification_service); //build notification mnotifymgr.notify(mnotificationid, mnotebuilder.build()); createnewalarm(context); } private void createnewalarm(context context){

ios - Asset Catalog: Access images with same name in different folders -

Image
there images.xcassets in project, contains icons folder , 2 subfolders ( firstfolder , secondfolder ) images. both of subfolders have same number of icons , same icons names (for different themes of app). so i'm looking for: need needed icon(for current theme) bundle. i've tried this: nsbundle* bundle = [nsbundle bundleforclass:[self class]]; nsstring *imagename = [bundle.bundlepath stringbyappendingpathcomponent:@"icons/firstfolder/neededicon"]; it not work. click on each folder in assets catalog , select provides namespace in utilities view: you see folder becomes blue , can see path image above images. you can access image this: imageview.image = uiimage(named: "folder1/image") or in objective-c: imageview.image = [uiimage imagenamed:@"folder1/image"];

javascript - How can I make my CSS update consistently? -

when click on button layout falls apart. when click on button css breaks apart layout. how update css layout divs properly? $(document).ready(function(e) { totalcount = 100; (var = 0; < totalcount; i++) { var newdiv = document.createelement("div"); newdiv.innerhtml = "number " + i; var applyclass = "bgcolor"; //identify class document.getelementbyid("maincontainer").appendchild(newdiv); newdiv.id = "div" + i; document.getelementbyid(newdiv.id).classname = applyclass; $('#div' + i).click(callbackfunction()); } function callbackfunction(e) { return function() { //remove instances of css (var = 0; < totalcount; i++) { $("#div" + i).removeclass('newcolor'); } document.getelementbyid(this.id).classlist.add('newcolor'); } } }); div { background-color: #ff0; padding: 2px; font-size: 12

web applications - No webapp folder in output jar -

i'm building simple web application using vaadin , spring boot. when build using mvn package , run via java -jar <path_to_jar> seems work. but 1 thing puzzles me. when i'm inside project folder , run java -jar target/app.jar seems working properly. if go outside , run java -jar <full_path_to_jar> works, theme gone. checked output of chrome inspector , returns 404 /vaadin/themes/mytheme/styles.css?v=7.5.5 how package theme jar? judging question's title, sounds you've used src/main/webapp . explained in documentation , shouldn't when building jar: do not use src/main/webapp directory if application packaged jar. although directory common standard, work war packaging , silently ignored build tools if generate jar. instead, should put static content beneath src/main/resources/static .

linux - Determine the source port of an IPv4 packet with perl -

i have perl script reads , processes ipv4 packets tuntap interface. stripped down bit, looks this: #!/usr/bin/perl use warnings; use strict; use common; use linux::tuntap; use netpacket::ip; use io::socket; $|++; ###### predecs ##### $tun; %config = loadconfig(); $tun = linux::tuntap->new(name => $config{'localtun_name'}) or die "couldn't connect interface $config{localtun_name}\n"; print "interface up: " . $tun->{interface} . "\n"; while (my $rawdata = $tun->get_raw()) { $rawdata =~ s/^....//; # strip tuntap header $packet = netpacket::ip->decode($rawdata); print "$packet->{id} $packet->{src_ip} -> $packet->{dest_ip} $packet->{proto} $packet->{len}\n"; # processing here } for routing reasons, need know source port of data. have not found way of doing netpacket::ip , there different way of determining this? using netpacket::ip debugging reasons, not set on mo

php - AJAX request from Codeigniter view gives an error -

Image
csrf protection enabled. i have view i trying insert shifts database table via ajax. $('#insert_shift').click(function(e) { e.preventdefault(); var empty_td = $('.td_shift[data-type=""]').size(); if (empty_td == 0) { var date = $('#atdnc_date').val() + '-'; var arr = []; var new_arr = []; $('.td_shift').each(function() { //if($(this).attr('data-day') != 0){ var data_type = $(this).attr('data-type'); var shift_atdnc_id = $(this).attr('data-typeid'); var user_id = $(this).attr('data-user'); var new_date = date + $(this).attr('data-day'); if (data_type == 'shift') { var shift_strt_time = $(this).attr('data-start'); var shift_end_time = $(this).attr('data-end'); // change new_arr old var new_arr = {

java - Pmd. how to configure ruleset? -

Image
i have following pmd configuration in pom.xml <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-pmd-plugin</artifactid> <version>3.3</version> <configuration> <includetests>true</includetests> <printfailingerrors>true</printfailingerrors> <verbose>true</verbose> <rulesets> <ruleset>rulesets/java/basic.xml</ruleset> <ruleset>rulesets/java/braces.xml</ruleset> <!--<ruleset>rulesets/java/junit.xml</ruleset>--> <ruleset>rulesets/java/unusedcode.xml</ruleset> <!--<ruleset>rulesets/java/codesize.xml</ruleset>--> <ruleset>ruleset-naming.xml</ruleset> <ruleset>rulesets/java/imports.xml</ruleset> <ruleset>rulesets/java/empty.xml</ruleset> <ruleset>rulesets/jsp/basic.xml</ruleset> &

c++ - Reference to "class" is ambigous -

i implement hash table example. aim, have created 1 header, 1 hash.cpp , main.cpp files. in hash.cpp , tried run dummy hash function takes key value , turns index value. however, throws error(reference 'hash' ambiguous) whenever try create object according hash class. this main.cpp: #include "hash.h" #include <iostream> #include <cstdlib> #include <string> #include <stdio.h> using namespace std; int main(int argc, const char * argv[]) { hash hash_object; int index; index=hash_object.hash("patrickkluivert"); cout<<"index="<<index<<endl; return 0; } this hash.cpp: #include "hash.h" #include <iostream> #include <cstdlib> #include <string> #include <stdio.h> using namespace std; int hash(string key){ int hash=0; int index; index=key.length(); return index; } this hash.h #include <stdio.h> #include <iostream> #in

Django get POST data posted via cURL -

i'm sending data using curl this:- curl -x post --header "content-type: application/json" --header "accept: application/json" -d "{ \"social_id\": \"string\", \"social_source\": \"fb/gmail\", \"access_token\": \"string\" }" but i'm not able data in views:- here view:- class usercreate(view): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super(usercreate, self).dispatch(request, *args, **kwargs) def post(self, request): print request.post['social_id'] i've tried request.data well. wrong doing? if posting json blob server not have post parameters available - populated when submit data in application/x-www-form-urlencoded format (e.g., using html form). you can access json data follows (from inside view function): import json data = json.loads(request.body) # data python dict,

linux - How to extract a variable assignment from within a string -

i trying extract variable assignment file defined within larger string in external file /home/user/file.txt: export os_username=xxxxx i want "source" file , pull variable assignment script treats as: os_username=xxxxx i pipe variable command running on script. config -- "$os_username" --test --run can explain me how can pull variable assignment external file? in script #! /bin/bash source /path/to/file.txt # variables set command command ...

php - Different uses of ServiceLocatorInterface in ZF2 Application -

i have 2 factories. the first controller factory: <?php namespace blog\factory; use blog\controller\listcontroller; use zend\servicemanager\factoryinterface; use zend\servicemanager\servicelocatorinterface; class listcontrollerfactory implements factoryinterface { public function createservice(servicelocatorinterface $servicelocator) { $realservicelocator = $servicelocator->getservicelocator(); $postservice = $realservicelocator->get('blog\service\postserviceinterface'); return new listcontroller($postservice); } } the second post servicefactory: <?php namespace blog\factory; use blog\service\postservice; use zend\servicemanager\factoryinterface; use zend\servicemanager\servicelocatorinterface; class postservicefactory implements factoryinterface { /** * create service * * @param servic

java - Spring Authentication object is null -

i'm trying access authentication object in order user's name, authentication object null. authentication authentication = securitycontextholder.getcontext().getauthentication(); if (authentication == null) { log.warn("authentication null during current user name!"); return anonymous_user; } return authentication.getname(); however can call (from same method): httpservletrequest req = (httpservletrequest)inrequest; string user = req.getremoteuser(); and discover user set correctly. edit: found stated problem may due not having gone through security filter chain. so added in filter chain, no success. here web.xml: <filter> <filter-name>springsecurityfilterchainproxy</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchainproxy</filter-name> <url-patt