Posts

Showing posts from January, 2013

java - Problems with rollback and @Transactional -

i have following situation. assume have 2 @services classes, inside each 1 have method annotated @transactinal. the method of first class @transactional , calls method of second class (in second class, method annotated @transactiona(propagation=propagation.required)). public class class1 { @autowired private class2 class2; @transactional public void dosomework(object value){ dao.save(value) object anothervalue = value.getanothervalue(); anotherobject anotherobject = new anotherobject(); anotherobject.setvalue1("lorem ip"); anotherobject.setanothervalue(anothervalue); class2.dosomework(anotherobject) } } @service public class class2{ @transactional(propagation=propagation.required) public void dosomework(){ ... throws new runtimeexception("fail"); } } i have observed value (the object in first method) rollback, but, have database id , in session cache. i'

angularjs - Angular: using ng-options properly -

am using ng-options iterate through objects of {title: '', value: ''} show title in select list , use value in controller full object not vlaue. here view code: <select class="form-control" ng-model="item.action" ng-options="option.title option in options"> </select> controller code: $scope.options = [{ title: 'title one', value: 'value one' }, { title: 'title two', value: 'value two' }]; $scope.item = {}; $scope.item.action= $scope.actio.value; // here getting obect title , value when want pull value this way value <html lang="en" ng-app='myapp'> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>my angularjs app</title> <meta name="description

java - Any way to obtain generated id for new entity instance in HibernateInterceptor? -

for sake of discussion, consider following hibernate annotated object: @entity public class testmodelobject { @id @generatedvalue @column private int id; @column private string name; public int getid() { return id; } public void setid(int id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } } the question is, how can obtain generated id value, new instance, via hibernateinterceptor (persisted via session.save )? outline of methods available, i've tested, , explain why each 1 insufficient: onsave - not work because id null, new instance being inserted. makes sense because hibernate doesn't know id ahead of time in case because it's generated @ insertion time rdbms. postflush - has data i'm after, unusable. contains iterator of many objects being flushed, including 1 you're interested in, the

java - How to insert empty row and get autoincrement id? -

i want add empty row table , autoincrement id in java. im not sure why im still getting userid=0. java class: public class userprofiledao { private dbconnectionmanager connectionmanager; private static final string insert_user = "insert user_profile values(default)"; private int userid; public userprofiledao(dbconnectionmanager connectionmanager) { this.connectionmanager = connectionmanager; try (connection connection = connectionmanager.getconnection()) { try (preparedstatement preparedstatement = connection.preparestatement(insert_user)) { try (resultset generatedkey = preparedstatement.getgeneratedkeys()) { if (generatedkey.next()) { userid = generatedkey.getint(1); } } } } catch (sqlexception e) { throw new runtimeexception(e); } } public int getuserid() { return userid;

javascript - Proxyquire can't find module -

i'm trying use proxyquire mock dependency testing. keep getting error cannot find module i tried full path , it's still complaining. i have src file in assets/js/src/lib , test in js-tests/specs here's code. var proxyquire = require('proxyquireify')(require); var stubs = { 'mandrill': { mandrill: function () { return { messages : jasmine.createspy('send') }; } } }; var jquery = require('jquery'), mandrill = proxyquire('../../assets/js/src/lib/mandrill', stubs), globalmandrill = require('mandrill'); which i'm getting error. error: cannot find module '../../assets/js/src/lib/mandrill' at i'm using grunt , phantomjs run tests here's browserify in gruntfile.js browserify : { options: { prebundlecb: function(b) { b.plugin(remapify, [ // module config ]);

java - The constructor Object(Context, int, List<DrawerItem>) is undefined -

please me resolve issue. i'm making drawer app , i'm receiving these errors adt: the constructor object(context, int, list) undefined the method getview(int, view, viewgroup) of type customdraweradapter must override or implement supertype method this code customdraweradapter class: package com.example.ico; import java.util.list; import android.app.activity; import android.content.context; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.textview; public class customdraweradapter { context context; list<draweritem> draweritemlist; int layoutresid; public customdraweradapter(context context, int layoutresourceid, list<draweritem> listitems) { super(context, layoutresourceid, listitems); this.context = context; this.draweritemlist = listitems; this.layoutre

html - CSS "inherit" not working as expected with focus state -

apparently need education on how inherit value works in css. i'm trying use element using :focus selector make sure that, on focus, border color doesn't change. i'm doing because want override bootstrap's default behavior creates blue "glow" around focused input elements on forms. but oddly, when set border-color:inherit under input:focus , border goes black on focus. here 's jsfiddle demonstrating this. first input has explicit color under focus , works fine. second input uses inherit goes black on focus. it's working expected, you're missunderstanding inherit keyword does. it takes computed value of property of parent element, input isn't parent of input:focus . if put input in div , , specify border-color div , inherit mean color of input's border 1 of div 's border . exemple: https://jsfiddle.net/e4mzfo3v/1/

python - Creating Pandas Dataframe between two Numpy arrays, then draw scatter plot -

i'm relatively new numpy , pandas (i'm experimental physicist i've been using root years...). common plot in root 2d scatter plot where, given list of x- , y- values, makes "heatmap" type scatter plot of 1 variable versus other. how best accomplished numpy , pandas? i'm trying use dataframe.plot() function, i'm struggling create dataframe. import numpy np import pandas pd x = np.random.randn(1,5) y = np.sin(x) df = pd.dataframe(d) first off, dataframe has shape (1,2), have shape (5,2). if can dataframe right shape, i'm sure can figure out dataframe.plot() function draw want. there number of ways create dataframes. given 1-dimensional column vectors, can create dataframe passing dict keys column names , values 1-dimensional column vectors: import numpy np import pandas pd x = np.random.randn(5) y = np.sin(x) df = pd.dataframe({'x':x, 'y':y}) df.plot('x', 'y', kind='scatter')

php - Excel timetable from MySQL database to Bootstrap table -

i'm trying make timetable website job, , can't figure out, boss makes excel table showing date , times people work. e.g. date ---- john ---- marcus 01.04 --- 08-12 --- 12-18 and on... and i'm trying do, excel file in mysql, , print out website, thing is, whenever try, kind of works, prints text sideways. e.g. date ---- john ---- marcus 01.04 --- 02.04 --- 03.04 and put date sideways , not downwards, show dates of month sideways.. this have. <table class= "table table-striped table-bordered table-hover"> <thead> <tr> <th colspan="1" rowspan="1" style="width: 180px;" tabindex="0">date</th> <th colspan="1" rowspan="1" style="width: 220px;" tabindex="0">john</th> <th colspan="1" rowspan="1" style="width: 288px;" tabindex="0">marcus</th> </

eclipse - How to undo / redo selective parts of code? -

i using eclipse. it happens lot when develop code (assume developed sequentially, top bottom): part 1 (*) part 2 part 3 part 4 (*) part 5 but figured out parts 1 , 4 (marked (*)) wrong , others fine. question how can undo 2 parts (1 , 4) without undoing rest? if undo selectively, great. note reverting code version 1 loses parts 2, 3 , 5 correct parts , should remain in code. note these parts mixed in 1 or 2 code blocks (not in separate blocks). example: part 1: add method f1(x, y) , move code main() f1() --> incorrect (should reverted) part 2: add method f2(a, b, c, d) --> correct (should remain) part 3: change part of main() implementation --> correct (should remain) part 4: change f2 signature f2(s, n) --> incorrect (should reverted) part 5: change body of f2 --> correct (should remain) the current approach use is: keeping copy of latest version somewhere (e.g., in temporary text file), undo before part 1, , add correct parts

asp.net mvc 4 - Simulating signalR connection failure -

i have website hosted in iis 8.5. use signalr send , receive messages , browser. periodically (3 seconds) browser calls server method called ping() , receive response in browser in client method. my server method this: public void ping() { clients.caller.sendack("ok"); } all working fine. testing purposes i'm simulating connection failure stopping website (not iis or application pool). strange website stopped, client method in browser called normally, when website runnig. , state of connection "connected" instead of disconnected. in debbuging process tried change website port in iss. using port 80 , changed port 83. now, when stop website, server method isn't called , new state disconnected, expected. so why port 80 has different behavior others? there issue/limitation known this? more details: the signalr connection use websockets; iis , browser renning in same machine; when stop application pool instead, connection lost expected;

jquery - Unobtrusive validation - added rule only works when an existing field is in place -

i trying add required rule dynamically radio button list. the example below works though when 'name' row removed validation longer fires. it appears there needs field data-val attributes on page validation plugin start watching form. how can add dynamic rules page no existing unobstrusive fields? <!doctype html> <html> <head> <title></title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> </head> <body> <div class="container body-content"> <form action="" method="post"> <!-- when below row commented out validation no longer fires --> <div class="row"> <div class="col-md-4"> <p>name</p> </div> <div class="col-md-4"> <input class="in

c# - SSIS Script Task, SqlException Handling Issue -

what trying create framework in ssis generate tab delimited utf8 text files dynamically. data source sql server, , queries output stored in physical database table, sql query plus few other parameters (e.g. file output location) passed ssis script task via variables. query executed , results streamed specified location. this part works fine – started having few issues when attempted introduce exception handling. if there error in source sql, exception thrown , sql server error message inserted source table. again, got work, using sqlexception class. however, depending on sql error, blank 0 byte text file may or may not generated. example, syntax error in source sql thrown straight catch block, divide 0 error creates blank 0 byte text file. in both cases, source table updated error. how can avoid this? whatever error is, don’t want file generated. this have cobbled together… noob c# , first ever stab @ c# coding if there glaringly obvious schoolboy errors in here, or i

java - Jsoup select excluding Elements with :not, not getting expected text -

i'm trying text isn't in span or in class _21ok _50f5 , in case want no text @ all, keep getting text. i tried combinations of select(._42ef:not(._21ok._50f5)) , , select(._42ef).not(._21ok._50f5) , more , still text. <div class="_42ef"> <div class="_6a _5u5j"> <div class="_6a _6b" style="height:36px"></div> <div class="_6a _5u5j _6b"> <div class=""> <span class="_21ok _50f5">add current city</span> <span class="img _55ym _55yn _55yo _5tqs _3-9a" aria-label="loading..." aria-busy="1"></span> </div> </div> </div> </div> anyone knows problem or how fix it? i think there several reasons why not performing had hoped. here example of javascript/jquery works. hope helps: //look in elements of root , specify each filter criteria separately $('._42ef')

java - Android; How to return a method for value from an activity inside a fragment? -

i realy new in android make lot of mistakes. basicly following tutorials. problem in question let me explain anyways. basicly have class use store user details shared preferences. , trying user details show in profile layout fragment. , before writing user details profile fragment chechk if user logged in. but while checking if user logged, app crashes, think because not calling method in right way. here code problematic section shown ; public class userprofile extends android.support.v4.app.fragment implements view.onclicklistener{ view rootview; button logoutbutton; edittext regusername, regpassword, regemail, regphonenumber, regbloodtype, regbirthday, regaddress; userlocalstore userlocalstore; context context; @nullable @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { rootview = inflater.inflate(r.layout.userprofile_layout,container,false); regusername = (edi

c++ - Why does my Palindrome function keep returning false? -

i have text file consists of: 1457887541 madam able ere saw elba straw? no, stupid fad. put soot on warts. class cancelled today and when run program, strings returning false , can't figure out why is. #include <iostream> #include <fstream> #include <string> #include <cstring> #include <cctype> using namespace std; bool ispalindrome(string); int main() { string input; fstream namefile; namefile.open("xample.txt", ios::in); if (namefile) { cout << "now reading file: " << endl; // read item file. getline(namefile, input); // while last read operation // successful, continue. while (namefile) { cout << input << endl; //palindrome function call if(ispalindrome(input)){ cout << "it palindrome :)/> " << endl; } else { cout << "it not palindrome :'( " << endl; } // read next string. getlin

coldfusion - Remove duplicates from a list in CF10 -

i have following string before use string, want remove duplicates it: http://website.com/abc.asp?type=298&action=submit&product=&contribution=&rateterm=&surryr=&mva=&rop=&sortby=1&sortorder=2&pagenum=3&company=&product=&state=&contribution=&rateterm=&surryr=&mva=&rop= i tried using cflib function listremoveduplicates , not seem solve issue. it should like: http://website.com/abc.asp?type=298&action=submit&product=&contribution=&rateterm=&surryr=&mva=&rop=&sortby=1&sortorder=2&pagenum=3 i using cf10. the cfoutput expecting should have company=&state= well. distinct too. taking in account can give try: <cfset url = "http://website.com/abc.asp?type=298&action=submit&product=&contribution=&rateterm=&surryr=&mva=&rop=&sortby=1&sortorder=2&pagenum=3&company=&product=&state=&contribution=&

gruntjs - Grunt for Brackets Extension Not Working For me -

when use plugin, grunt brackets, doesn't seem work me. i've looked , looked , looked through files of extension, , when "grunt," devtools spit out log. [node-log 10:01:49 am] { '0': { [error: spawn enoent] code: 'enoent', errno: 'enoent', syscall: 'spawn' } } i'm not sure means... here link extension. author has not updated in months, , there open issue ticket, there hasn't been responses. if me decipher log, appreciate it. do have grunt installed on computer already? if so, installed in standard location? (e.g. did intsall using npm -g grunt ?) enoent means "file not found," , since error message says spawn i'm guessing problem it's unable find grunt binary execute. update: looks bug in how current version of extension packaged. should able fix way: help > show extensions folder in brackets , find brackets-grunt extension in 'user' subfolder open command prompt @

html - CSS ellipsis inside flex item -

i have layout based on flexbox. 2 columns, 1 fixed size , second need take rest space. in grow column have string want clipped. in chrome works fine. doesn't work in firefox , ie. tried fix giving grow (flex item) inner element width using relative , absolute positions, got corrupt layout. corruption related element's height doesn't take in account child elements. note: inner element inside flex grow item built several div tags. here jsfiddle . .cols { display: flex; } .flex--0 { flex: 0 0 auto; } .flex--1 { flex: 1 1 auto; } .absolute { position: absolute; } .relative { position: relative; } .width--100 { width: 100%; } .ellipsis { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } .border { border: 1px solid gray; } <h1>ellipsis inside flex item</h1> <h2>working fine in chrome not working in ff , ie</h2> <div class="cols border"> <div class="flex--0 border pad

MySQL Full Text Search on columns with special characters -

i have mysql column contains character 's (eg. lee's). when performing full text search "lee" on column not return results. search including "'s" (e.g. "lee's") takes long time return huge number of results. how mysql full text search handle character "'s" , what's best way make search on type's column work? thanks. full text search depends on definition of collation used, whether particular character considered considered punctuation character or letter character. myisam, apostrophe should considered character in word, not punctuation. there's bug report innodb full text search regarding apostrophe; it's not clear whether using myisam or innodb. https://dev.mysql.com/doc/refman/5.6/en/full-text-adding-collation.html and again, depends on collation used, how apostrophe handled. reference: https://dev.mysql.com/doc/refman/5.6/en/full-text-adding-collation.html

Using Python's CSV library to print an array as a csv file -

i have python list such: [['a','b','c'],['d','e','f'],['g','h','i']] i trying csv format can load excel: a,b,c d,e,f g,h,i using this, trying write arary csv file: with open('tables.csv','w') f: f.write(each_table) however, prints out this: [ [ ' ' , ... ... so tried putting array (again) , printing it. each_table_array=[each_table] open('tables.csv','w') f: f.write(each_table_array) now when open csv file, bunch of unknown characters, , when load excel, character every cell. not sure if it's me using csv library wrong, or array portion. i figured out table pulling data has table within 1 of cells, expands out , messes whole formatting you need use csv library job: import csv each_table = [['a','b','c'],['d','e','f'],['g','h','i']] open('tables.c

AngularJS UI Router not executing unspecified resolve dependencies in order -

i'm running in problem how ui router handles order loads resolves. end goal of i'm trying accomplish having services load data , store it, , have data loaded (requested) once , accessible through service. the current way i've gone implementing follows pattern: in higher level state resolve, tell service load data. result of resolve not dependency of sub services, because data accessed injecting service in controller. sub state resolves may depend on service has been "primed" in previous state works great when you're clicking through application (i.e, state -> state a.b -> state a.b.c) however, breaks down when go directly nested state (state a.b or state a.b.c). problem occurs because ui router not ensure order resolves executed in if child state not specify resolve of parent state dependency. see example below: app.config(function($stateprovider) { $stateprovider .state('a', { url: "/a", resolve: { data: fu

linux - Printing more than one line after a match -

$ cat /etc/sudoers inavg7ey evl0000332,evl0000333,evl0000234,evl0000999,evs99234456,\\ evl3300987,evl3344567,evlser999,eul000123,evs3300123,evs3300124,\\ (root,jboss,superss) nopasswd:all inavgmcn evl0000332,evl0000333,evl0000234,evl0000999=(all,wasadmin,\\ jboss,superss) nopasswd:all i want print inavg7ey user details second line (if more lines there want them also).. me this? i've tried this: awk '/inavg7ey/' /etc/sudoers but it's displaying one: inavg7ey evl0000332,evl0000333,evl0000234,evl0000999,evs99234456,\ you may use: awk '/inavg7ey/{c=n}c&&c--' /etc/sudoers n - here number of line after match including match and 1 solution: awk '/navg7ey/,/^$/' /etc/sudoers awk -may grep between 2 patterns, in file, navg7ey - it's first pattern grep from; ^$ - it's second pattern grep ( ^$ - means empty line)

writing aborted; java.io.NotSerializableException -

this question has answer here: java.io.writeabortedexception: writing aborted; java.io.notserializableexception 2 answers i trying read objects file. below snippet of method use fetch list of object file. public list displayparties() { objectinputstream ois = null; list<registerparty> results = new arraylist(); try { fileinputstream fis = new fileinputstream("/media/user/disk2/myapp/assignment/party.ser"); ois = new objectinputstream(fis); while (true) { system.out.println(" inside while true"); results.add((registerparty) ois.readobject()); system.out.println(results); } } catch (ioexception ex) { ex.printstacktrace(); } catch (exception ex){ ex.printstacktrace();

filesystems - Registering a File System in Apache Drill -

i'm trying register file system in apache drill doesn't work. i tried these steps: navigate http://localhost:8047 , , select storage tab. in new storage plugin window, enter unique name , click create. in configuration window, provide following configuration information type of file system configuring data source.a. i entered: { "type": "file", "enabled": true, "connection": "file:///", "workspaces": { "root": { "location": "/root/data/json", "writable": false, "storageformat": null } }, "formats" : { "json" : { "type" : "json" } } } update. every time when press button code deleted, result: null there instance created without content. any i

d3.js - Can I use index.html and ui.r for my r shiny interface? -

in reference this on how build shiny app in html, i'm wondering if there way use approach in conjunction using traditional ui.r approach. reason: this approach of using d3 r shiny seems require putting d3 code index.html file. want interactivity (selectinputs, daterangeinputs, multiple tabs, etc.). advice? you can use tags add custom html ui.r . for more complicated outputs, can build custom shiny outputs while using app ui.r , server.r . this page has info on how code. here's example using javascript code d3 example posted. app generates plot, added selectinput can select data plots show how thing integrate. of javascript code mbostock. (can found here ). i added shiny binding parts , changed few lines adapt app, commented above changes can track them. ui.r library(shiny) shinyui( fluidpage(singleton(tags$head( #adds d3 library needed draw plot tags$script(src="http://d3js.org/d3.v3.min.js"), #the js script holding code

node.js - NodeJS Mongoose collection.remove not working -

trying drop docs in collections before unit tests run... var collections = mongoose.connection.collections; async.eachseries(_.keys(collections), function(key, cb){ collections[key].remove(function(){ //never gets here, doesn't drop collection , doesn't error. cb(); }); } but callback in remove() never gets fired. i've logged out collections[key] , resolve collection. no errors, times out never runs callback. ive tried looping models , calling remove same issue. what doing wrong here?? logs at? you try using drop method: var async = require("async"), _ = require("underscore"), collections = _.keys(mongoose.connection.collections); async.foreach(collections, function(key, done) { var collection = mongoose.connection.collections[key] collection.drop(function(err) { if (err && err.message != "ns not found") { done(err); } else { done(null);

php - Please check whether this SQL query is correct -

i trying update data in row of table specific user id. receiving syntax error. tell me what's wrong in syntax or miss ? result of echo statement ---> update activitymeter set totaltimes = 4, tna_wd = 1, tnm_wd = 10, tna_we = 10, tnm_we = 10, mvpa_wd = 2, mvpa_we = 5, week_diff = -3, tailor_advice= weekday activity level below recommended levels looks though improved on weekend. user_id = 2227904 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'weekday activity level below recommended levels looks though th' @ line 10 from above printed sql query, type of tailor_advice field may text or varchar, value must put inside double quotes or single quotes.

python - Pandas error with pivot_table and categorical data -

i'm having no fun on pandas. have data.frame: category1 category2 numeric 0 grey complete 1 1 grey complete 2 2 nan incomplete 3 3 blue complete 4 and want pivot table. p.pivot_table(df, index = 'category1', columns = 'category2', values = 'numeric', aggfunc = 'count') that's ok need add categories in category1, do: df['category1_'] = p.categorical(df['category1'], categories = ['grey','blue','red']) and get: p.pivot_table(df, index = 'category1_', columns = 'category2', values = 'numeric', aggfunc = 'count') valueerror: cannot convert na integer i think there problem nan values in categorical series droping nan: df2 = df.dropna() p.pivot_table(df2, index = 'category1_', columns = 'category2', values = 'numeric', aggfunc = 'count') c:\users\diego_000\anaconda3\lib\site-packages\pandas\

javascript - Stubbing jQuery.ajax in node environment (jQuery 2.x) -

i trying run tests require stubbing jquery.ajax . i'm using sinonjs , used work fine older version of jquery (1.x) var $ = require('jquery'); var sinon = require("sinon"); sinon.stub($, "ajax"); // worked because $.ajax defined however, after upgrading jquery 2.x, have had include window environment when require jquery module run. using jsdom accomplish this: var document = require('jsdom').jsdom(), window = document.parentwindow, $ = require('jquery')(window); problem $.ajax undefined. suspect because returns jquery object bound specific element not entirely sure. know why , how around this? edit buddy of mine isn't on has pointed out if attach window global, can plain jquery object instead of factory global.window = require('jsdom').jsdom().parentwindow; var $ = require('jquery'); // works $.ajax defined i'm not fan of attaching window global affect of plugins type ch

ios - Toggle UITextView scrollEnabled -

i initialized uitextview scrollenabled = true . once set scrollenabled = false , text view not scroll after i've set scrollenabled = true is there way toggle textview's scrolling? have userinteractionenabled set true . in override func viewdidload() { view.addsubview(scrollview) scrollview.delegate = self scrollview.addsubview(textview) } in func scrollviewdidscroll(scrollview: uiscrollview) { if scrollview.contentoffset.y >= 180 { textview.scrollenabled = true // not work! } else { textview.scrollenabled = false // works! } } i don't you,what trying. it's working me.just try below code. - (ibaction)test:(id)sender { uibutton *btn = sender; switch (btn.tag) { case 0://enabled [customtextview setscrollenabled:yes]; break; case 1://disable [customtextview setscrollenabled:no]; break; default: break; } }

Susy columns overflowing grid -

Image
i'm trying susy first time, having bit of difficulty. html <div class="wrap"> <div class="col"></div> <div class="col"></div> <div class="col"></div> <div class="col last"></div> </div> scss @import "susy"; $susy: ( container: 1140px, columns: 12, gutters: 0.5, global-box-sizing: border-box, debug: (image: show-columns) ); @include border-box-sizing; .wrap { @include container; } .col{ @include span(3); height:40px; background:#f00; box-sizing: border-box; } i think have right, columns coming out outside of grid: you can see code running here: http://codepen.io/eightarmshq/pen/ejjxwv how columns inside grid? your columns correct, , background gradient wrong. it's browser bug. see documentation .

javascript - how to include HTML form method=DELETE for the same "action" in the REST service call -

i want include delete method in same html form, calling same action(calling rest service) . how do ? . current html form looks :, delete functionality not work , post does. have included rest resource service well. suggestions appreciated. <!doctype html> <html> <head> <title>form create new resource</title> <style> tab { padding-left: 4em; } </style> </head> <body> <form id= "myform" action="../com.dcr.jersey.first/rest/todos" > <label for="id">id</label> <input name="id" /> <br/> <label for="summary">summary</label> <input name="summary" /> <br/> description: <textarea name="description" cols=40 rows=6></textarea> <br/> <button type="submit" value="submit">submit</button> <tab> <button type="submit&q

python - How do you extract unique queryset from queryset of objects with ManyToManyField -

i have channel model object follows: def channel(models.model): users = models.manytomanyfield(user, blank=true, null=true, related_name='channels') manager = models.foreignkey(user, related_name='manager_channels') i want list of users channels managed current user, so: managed_channels = channel.objects.filter(manager=user) # users of managed_channels queryset is there efficient way list without iterating on managed_channels queryset , extracting users , compiling unique list? try reverse relation: #add .distinct() if duplicate users. users = user.objects.filter(channels__manager=request.user)

angularjs - How to copy a list before POST/GET block execution? -

i trying copy list present in post body before execution of post block. below code snippet: app.controller('oneclickcontroller',function($scope,$http){ $scope.oneclick.submitoneclickdetails.listinvestoptions ={}; $scope.oneclick.submitoneclickdetails.contactdtlswrapper.contactdtls = {}; $scope.invest = {}; $scope.submitoneclick = function(investdtls) { //$scope.oneclick.submitoneclickdetails.contactdtlswrapper.contactdtls.emailaddr = angular.copy('mbc@gmail.com'); //$scope.invest = angular.copy(investdtls); $scope.oneclick.submitoneclickdetails.listinvestoptions = angular.copy(investdtls); $http({ method : 'post', url : '/investor/api/v1/oneclick', data : $scope.oneclick }).success(function(response) { $scope.out= response; alert("success " + $scope.oneclick.submitoneclickdetails.listinvestoptions[0].investname); });

c++ - Cassandra cpp-driver throwing error but able to connect with the cluster -

i'm trying connect cassandra cpp-driver 2 node cassandra cluster. throwing error, able retrieve keyspace names. 1430309809.995 [error] (src/connection.cpp:413:static void cass::connection::on_connect(cass::connector*)): connect error 'connection refused' on host 192.168.1.5 1430309809.995 [error] (src/connection.cpp:651:void cass::connection::notify_error(const string&)): host 192.168.1.5 had following error on startup: 'unable connect' keyspace_name: 'mytest' keyspace_name: 'system_traces' keyspace_name: 'system' it looks host 192.168.1.5 not configured accept external connections driver able connect second node in cluster.

Android drag and drop issue with sending DragEvents -

i integrated drag , drop framework in project. in layout have own custom grid of cells want able drag swipe order of them or put 2 in folder. to achieve did build custom relativelayout , override ondragevent() callback. basically working fine, have issues when in dragging process put 2 cells big folder . this folder in layout start of process gone visibility ,and change visibility visible copy of cells. problem relativelayout folder have issues stream of drag events. stream stop , continue if stop movement time. i think of moving dragging logic parent 1 view event prefer find solution , stay logic because taking advantage framework data view below dragging view. after lot of tries , research found out drag , drop framework stops send of dragevents when alpha prperty of view different 1.

wordpress - How to add rel=canonical tag in Blogger -

i have blog: http://blog.companyname.com blogger.com. have few articles there. i have blog on website http://www.companyname.com/blog on wordpress. have same articles (that have on blogger) here. this means have duplicate content , avoid penalized google understood need add rel=canonical tag. however, keep both blogs (blogger , wordpress), , since push views of website set preferred url http:// www.companyname.com/blog. so add following tags blogger: < link rel="canonical" href="http://www.companyname.com/blog/article1" /> etc. i have difficulties add tag blogger, can me? well, have add canonical-tag site header section. hosted blog-systems wordpress.com or blogger not allow edit theme files (and therefore output mentioned tag). if editing theme output or changing functions.php not possible, not able set tag, think. sorry.

sql - Nhibernate queryover filter based on count of child collection -

ultimately want filter parent objects have less 2 children. i'm building search screen grid dashboard, uses following logic example of how build query. var query = session.queryover<parent>(() => parentalias); if (!string.isnullorwhitespace(searchcriteria.openedby)) query.where(restrictions.eq(projections.property<parent>(x => x.openedby), searchcriteria.openedby)); if (searchcriteria.openeddatestart != null) query.where(restrictions.ge(projections.property<parent>(x => x.openedat), searchcriteria.openeddatestart)); this working wonderfully right until point: if (!string.isnullorempty(searchcriteria.childrenaffected) && searchcriteria.childrenaffected == "multi") query.where(() => parentalias.children.count > 2); it makes sense .count does't work, isn't linq. .count() throws error. honestly, feel i've tried every combination of restritions, joinalias, etc can think of, i've gone off path

java - 415 Unsupported Media Error in PUT method using REST -

firstly new development , have started working directly rest. may stupid ask silly questions. please accept apologies in advance! regarding problem - trying learn how rest api webservices can developed started mavan project using archetype - " jersey-quickstart-webapp " , using chrome postman rest client. successful in writing methods getting struck while writing put. every time 2 things - a) runtime exception 404 error or b) 415 error media unsupported. i have tried different combinations @consumes annotation , method parameters @formparam , @queryparam no luck. neither successful in reading value sent via put application postman nor able send simple response postman. please suggest , drive me path can overcome these small hurdles. my code - package tcs.suraj.learnwebservices; import java.util.arraylist; import javax.ws.rs.*; import javax.ws.rs.core.mediatype; import javax.ws.rs.core.response; import tcs.suraj.learnwebservices.domain.moviebean; @path("

c# - Windows phone 8.1 BackButton Navigation issue -

i developing windows phone 8.1 silver light application. in application there many screens. pages navigating perfectly. my issue when press on button(windows phone button) pages going previous pages. want stop button navigation in application. followed below link not succeeded. https://social.msdn.microsoft.com/forums/windowsapps/en-us/131a99ce-53a4-4389-81e9-7801af57b78b/used-hardwarebuttonsbackpressed-handler could 1 advise me. try button on xaml.cs page : protected override void onbackkeypress(system.componentmodel.canceleventargs e) { base.onbackkeypress(e); if (navigationservice.cangoback) { while (navigationservice.removebackentry() != null) { navigationservice.removebackentry(); } } }

java - ExecutorService that scales threads then queues tasks -

there executorservice implementation behaves thread pool following characteristics? there @ least x active threads. if task submitted , active threads busy, new thread started, y threads. if task submitted , y threads busy, task queued. if no new tasks submitted, pool scales down x active threads. pretty standard thread pooling behavior. you'd think threadpoolexecutor handle this, but executorservice = new threadpoolexecutor( 2, 10, // min/max threads 60, timeunit.seconds, // time of inactivity before scaling new synchronousqueue<runnable>()); // task queue will throw exception if more 10 tasks submitted. switching linkedblockingqueue never scale past 2 minimum threads, unless limit size new linkedblockingqueue<runnable>(20) , in case there 2 threads handling 1-20 tasks, 2-10 threads handling 21-30 tasks, , exception more 30 tasks. not pretty. fixed thread pool, meanwhile, never scale down inactive threads. so, i'm after, can use d