Posts

Showing posts from January, 2014

java - Same Form based authentication for two applications Using Spring Security -

we have existing legacy web application(servlet+jsp+spring+hibernate) , going develop new features of application using new stack (angularjs+spring mvc). suggested approach register new servlet , develop new features in same codebase, authenticated users have access new functionality develop in system. there better way of doing 2 different web applications (without sso) ? can 2 web applications secured under same form based authentication settings ? i think architecture , security usability important before dive something. if both apps use same login, assume newer application more service oriented application. ex: restful authorization may issue. ex: legacy app used user set a, new 1 used both user set , b. otherwise can use shared database example mongodb store login info i.e token. when log in, return token , use other service via angular client. when log out remove token user session. may need concern token expiration. however have refactor legacy system in som

c# - WPF DataGrid - Modifing Visuals out of scroll view at runtime -

i have multiple datagrids first column has checkbox , header has checkbox. we've seen, want able click header checkbox , have select of check boxes below. <datagrid x:name="dgreporttypes_new" margin="10,140,0,0" height="175" verticalalignment="top" horizontalalignment="left" width="216" autogeneratecolumns="false" selectionmode="single" canuseraddrows="false" mouseup="datagrid_mouseup" keydown="datagrid_keydown"> <datagrid.columns> <datagridcheckboxcolumn isreadonly="true" binding="{binding ischecked, updatesourcetrigger=propertychanged}" clipboardcontentbinding="{x:null}"> <datagridcheckboxcolumn.headertemplate > <datatemplate> <checkbox x:name="chkselectall" isthreestate="true" checked="datagridh

c++ - boost::circular_buffer<unique_ptr<T>>::set_capacity() fails to build -

i'm trying use boost::circular_buffer in code this: class eventregistry { public: eventregistry() { pendingevents_.set_capacity(max_pending_events); } private: boost::circular_buffer<boost::movelib::unique_ptr<eventdata>> pendingevents_; } however, i'm getting build failure (excerpted): ... boost/build/binaries/include/boost/circular_buffer/details.hpp:470:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept_impl<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::eventdata, boost::movelib::default_delete<appd::agent::eventdata> >, std::allocator<boost::movelib::unique_ptr<appd::agent::eventdata, boost::movelib::default_delete<appd::agent::eventdata> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::ag

Android app crashes if I declare more than 3 Drawables -

i'm making simple dice app in android studio right , have 6 drawables each side of die. here code looks like: final drawable die1 = contextcompat.getdrawable(this, r.drawable.die1); final drawable die2 = contextcompat.getdrawable(this, r.drawable.die2); final drawable die3 = contextcompat.getdrawable(this, r.drawable.die3); final drawable die4 = contextcompat.getdrawable(this, r.drawable.die4); final drawable die5 = contextcompat.getdrawable(this, r.drawable.die5); final drawable die6 = contextcompat.getdrawable(this, r.drawable.die6); the app runs fine when 3 of drawables commented out, doesn't run in emulator if more 3 uncommented. tried fixing building apk , running app on phone, doesn't run if 1 of drawables uncommented. if are, app runs, it's blank screen. thanks help as outofmemory error, can use small size png images overcome outofmemory error. if want use existing images, can shrink images using tinypng online tool.

store google form responses in existing sheet of a spreadsheet -

i'm new google forms , spreadsheets. i know can create form, , send responses new sheet of google spreadsheet. wondering if possible store form responses in existing sheet of spreadsheet. this page seems indicate not, seems unnecessary. the form embedded in wordpress website.

python - PIL: Convert Bytearray to Image -

i trying verify bytearray image.open , image.verify() without writing disk first , open im = image.open() . looked @ .readfrombuffer() , .readfromstring() method, there need size of image (which when converting bytestream image). my read-function looks this: def readimage(path): bytes = bytearray() count = os.stat(path).st_size / 2 open(path, "rb") f: print "file opened" bytes = array('h') bytes.fromfile(f, count) return bytes then basic test try convert bytearray image: bytes = readimage(path+extension) im = image.open(stringio(bytes)) im.save(savepath) if knows doing wrong or if there more elegant way convert bytes image that'd me. p.s.: thought need bytearray because manipulations on bytes (glitch them images). did work, wanted without writing disk , opening imagefile disk again check if broken or not. edit: gives me ioerror: cannot identify image file if manipulate bytearrays , have use io.bytesio . can read

javascript - Creating a categorical bar chart from csv file in c3.js -

Image
i have code simple bar chart using c3.js: <!doctype html> <html lang="en"> <head> <title>c3</title> <meta charset="utf-8" /> <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js"></script> </head> <body> <div id="chart"></div> <script> var chart = c3.generate({ data: { url: 'data/output.csv' type: 'bar' } }); </script> </body> </html> the file output.csv looks this: a,b,c,d 25,50,75,100 and graph ends looking this: which of data in 1 group. what i'd want producing followin

mysql - concat fields that have a duplicate key in common and remove those dupes leaving one -

this bugging me last week now, , basic knowledge can't to solution brings need be. i've searched on updateing, group_concat, concat, joins, cant result need. the problem follows: we have 2 columns work 1 result need: the db we're working on: +------------------------------------+-------------+ | id | value | +------------------------------------+-------------+ | d44172cb5c086c19a4c0286270916bc52 | | | d44172cb5c086c19a4c0286270916bc52 | c | | d44172cb5c086c19a4c0286270916bc52 | b | | d87d93570cbc9a3edc18601e0aff6e261 | d | | d87d93570cbc9a3edc18601e0aff6e261 | | | d87d93570cbc9a3edc18601e0aff6e261 | f | +------------------------------------+-------------+ what expect get: +-------------------------------------+-------------+ | id | value | +-------------------------------------+-------------+

android - Save and restore instance state of an Activity manually -

i have download activity in app, users can download content. activity called main activity, , retrieves list of available files download on network. to avoid fetching whole list again when download activity recreated e.g. because of rotation, override onsaveinstancestate() store list in bundle , evaluate bundle passed oncreate() method. works rotation. however, able implement same behavior if user hits , later returns download activity. android in case not call onsaveinstancestate() , hence nothing gets saved. my idea override onbackpressed() , include call onsaveinstancestate() . will work @ all? can onsaveinstancestate(new bundle()) , or have initialize new bundle somehow? will android store bundle , pass oncreate() next instance of activity creates, or have take care myself of storing bundle , passing new instance (if so, how)? update: simply adding @override public void onbackpressed() { onsaveinstancestate(new bundle()); super.onbackpressed();

google apps script - How can I kick a user out of a cell before using the cell contents? -

i working on google sheet script copy cells , paste them somewhere else. 1 of issues i'm running if user actively editing cell when script run, script see cell blank. i've tried make different cell "active" or "selected" doesn't seem effect user editing cell. or if tell if user editing it, , make them press "enter" work guess... thanks!

javascript - Why does bob instanceof Person return false? -

i need explain me why bob instanceof person returns false code: var person = function(firstandlast) { var names = firstandlast.split(' '); return { getfirstname: function() { return names[0]; }, getlastname: function() { return names[1]; }, getfullname: function() { return names[0] + " " + names[1]; }, setfirstname: function(first) { names[0] = first; }, setlastname: function(last) { names[1] = last; }, setfullname: function(firstandlast) { names = firstandlast.split(' '); } }; }; var bob = new person('bob ross'); i've tried looking answer couldn't find anything. far understand bob instanceof person should return true doesn't. the problem you're returning object constructor. object not object initialized new , it's not instance of pers

java - When to use a String with filename or File as argument to constructor? -

when should use file , when should use string filename constructor? constructed method should contain contents of file. can choose: public graphmodel(file file) throws ioexception { this(); readfromfile(file); } versus public graphmodel(string filename) throws ioexception { this(); readfromfile(new file(filename)); } is 1 preferred on other? some people think matter of taste / personal preference ... or doesn't matter. argue matter. lets assume api's implementation require file internally. then, there 3 alternative approaches: // #1 public graphmodel(file file) throws ioexception {...} // #2 public graphmodel(string file) throws ioexception {...} // #3 public graphmodel(file file) throws ioexception {...} public graphmodel(string file) throws ioexception { this(new file(file)); } now compare these apis in various contexts: if adopt approach #1, , caller has filename string must construct file . potenti

encryption - Error occurred while decoding OAEP Padding C# -

below code , error in title. encrypted using private key decrypt using same private key ran error mentioned in title, not sure underlying cause of error. in regard highly appreciated. class program { static void main(string[] args) { string thumbprint = "somevalue"; encryptusername("steve", thumbprint, true, true); } public static void encryptusername(string texttoencript, string certificatethumbprint, bool searchlocalmachine, bool searchuser) { x509certificate2 cert = findcertificate(certificatethumbprint, searchlocalmachine, searchuser); rsacryptoserviceprovider rsaencryptor = (rsacryptoserviceprovider)cert.publickey.key; byte[] cipherdata = rsaencryptor.encrypt(encoding.utf8.getbytes(texttoencript), true); var encryptedstring = convert.tobase64string(cipherdata); console.writeline(encryptedstring); } public static byte[] decrypt(byte[] encrypteddata, bool foaep, x509certifica

How does bash parse quotes in this example? -

i running example , trying figure out how arguments parsed. colour1="red" colour2="light blue" colour3="dark green" x in "$colour1" $colour2" $colour3" echo $x done note weird missing quotes not typo. it's test example blog. the output red light blue dark green the output expected red light blue dark green since colour2 won't protected quotes colour1 , colour3 should be. interpreter doing? because $colour2 , "$ colour3" adjacent, form single word before parameter expansion occurs. here's how expansion progresses: you start $colour2" $colour3" parameter expansion turns light blue" dark green" word-splitting applied result of expansion on unquoted whitespace. there 1 unquoted space, 2 resulting words light , blue" dark green" . finally quote removal performed, yielding light , blue dark green .

javascript - unable to get object3D in scene -

i unable object3d scene. although mesh objects shown in scene. scene.children array not show that. please have @ screenshot (link). screenshot code: function init(){ loadjson(function(response) { // parse json string object var jsondata = json.parse(response); materialtype = ['meshbasicmaterial','meslambertmaterial','meshphongmaterial', 'meshstandardmaterial']; (var =0; i< jsondata.materials.length; i++){ var matname = jsondata.materials[i].name; materialarray[matname] = new three.meshlambertmaterial(); materialarray[matname].name = matname; } var loader = new three.objloader(); for(var = 0; < jsondata.models.length;i++){ parentgroup = new three.object3d(); parentgroup.name = jsondata.models[i].name; for(var j = 0; j < jsondata.models[i].children.length;j++){ childname = jsondata.models[i].children[j].name; mattype = jsondata.models[i]

asp.net mvc - MVC 6 post method not found after publish -

after publish destitution server form unable post data method inside controller(everything works on local , developement machine). its returns 404 error. this view cshtml : @using (html.beginform("index", "account", formmethod.post, new { @class = "login-form", @role = "form", @id = "loginform" })) { <div class="row"> <div class="large-12 columns"> <input type="text" name="username" /> </div> </div> <div class="form-group row"> <div class="large-12 columns"> <input type="password" name="password"/> </div> </div> <div class="form-group row"> <div class="large-12 large-centered columns"> <input type="submit" class="button expand" /&g

sql - SELECT columns OVER (PARTITION BY column) -

Image
suppose want retrieve swimmer , time @ 75th percentile each day. this trying do: select tablea.date, tablea.swimmer, tablea.time on (partition tablea.date) tablea rank = ceil(0.75 * num_of_swimmers); but errors @ on statement. what's best way data need? thanks! your error on clause of windowing function requires order clause. but assuming num_swimmers , why not return select date, swimmer, time tablea rank = ceil(0.75 * num_of_swimmers) ? the clause ensure rows returned 75th percentile given day

database - EntityFramework5 Code-First Migration -

i running entityframework5 code-first , enabled migration package manager console . after enabled migration configuration.cs file added migrations folder, not initialcreate.cs . i change class from public class product { public product() { this.creationdate = datetime.now; } [key, databasegenerated(databasegeneratedoption.identity)] public guid productid { get; set; } public datetime creationdate { get; set; } public string image { get; set; } public string imagethubmnail { get; set; } [foreignkey("category")] public guid categoryid { get; set; } public virtual category category { get; set; } [foreignkey("company")] public guid companyid { get; set; } public virtual company company { get; set; } } to public class product { public product() { this.creationdate = datetime.now; } [key, databasegenerated(databasegeneratedoption.identity)] public guid pro

android - Removing event listener as activity pauses or stops -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i facing problem in removing event listener. using initialising listener inside onstart() in activity after collecting user data, app shows toast user data has been uploaded , call onbackpressed() method. but notice listener still running after activity paused or stopped, because creating toast called under oncancelled() event. so tried overriding onpause , onstop methods. @override public void onpause() { super.onpause(); // remove post value event listener if (mlistener != null) { mreadreference.removeeventlistener(mlistener); } } but causing error : java.lang.runtimeexception: unable pause activity {deventree.com.thetimothyinitiative/deventree.com.thetimothyinitiative.attendance}: java.lang.nullpointerexception: listener must not null i wan

android - How to implement Firebase Cloud messaging with Foreground application? -

how receive message in activity application in foreground , display message toast? receive notification when app in background. something messages in real time. please me !! on oncreate method of activity display toast.write. registerreceiver(new myreceiver(),new intentfilter("myreceiver")); then create myreceiver broadcastreceiver inner class in activity. as. public class myreceiver extends broadcastreceiver{ public void onreceive(context context, intent intent){ toast.maketext(context,intent.getstringextra("from")+" "+intent.getstringextra("message"),toast.length_short).show(); } } ///finally have write following codes on onmessagereceived intent intents=new intent(); intents.setaction("myreceiver"); intents.putextra("message",message.getdata().get("message")); intents.putextra("from",message.getdata().get("from")); get

java - How to increment a number for 3 different paths while using recursion? -

i have program prints reachable paths of graph. contains 2 classes graphpath1 , search . program given below: class graphpath1: import java.util.arraylist; import java.util.hashmap; import java.util.linkedhashset; import java.util.linkedlist; import java.util.list; import java.util.map; public class graphpath1 { list<string> src=new arraylist<string>(); // source node list<string> dest=new arraylist<string>(); // destination node private map<string, linkedhashset<string>> map = new hashmap(); public void addedge(string node1, string node2){ linkedhashset<string> adjacent = map.get(node1); if(adjacent==null) { adjacent = new linkedhashset(); map.put(node1, adjacent); src.add(node1); } adjacent.add(node2); dest.add(node2); } public linkedlist<string> adjacentnodes(string last) { linkedhashset<string> adjacent = map.get(last); if(adjacent==null) { re

php - Pass a shared preference value using StringRequest so I can filter my SQL query -

i'm working on listview inside fragment. it's working fine, need filter data on listview using user's username. how able pass "username" using request? help, advice, , tip appreciated. in advance :) here's code: public class pendingfragment extends fragment { public static final string json_url = "my_url"; private listview listview; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { final view rootview = inflater.inflate(r.layout.pending_layout,null); //fetching username shared preferences sharedpreferences sharedpreferences = getactivity().getsharedpreferences(config.shared_pref_name, context.mode_private); string username = sharedpreferences.getstring(config.username_shared_pref,"not available"); sendrequest(); listview = (listview) rootview.findviewbyid(r.id.listview); return rootview; } pr

Firebase Storage and Access-Control-Allow-Origin -

i'm trying download files firebase storage through xmlhttprequest, access-control-allow-origin not set on resource, it's not possible. there way set header on storage server? (let [xhr (js/xmlhttprequest.)] (.open xhr "get" url) (aset xhr "responsetype" "arraybuffer") (aset xhr "onload" #(js/console.log "bin" (.-response xhr))) (.send xhr))) chrome error message: xmlhttprequest cannot load https://firebasestorage.googleapis.com/[edited] no 'access-control-allow-origin' header present on requested resource. origin ' http://localhost:3449 ' therefore not allowed access. from post on firebase-talk group/list : the easiest way configure data cors gsutil command line tool. installation instructions gsutil available @ https://cloud.google.com/storage/docs/gsutil_install . once you've installed gsutil , authenticated it, can use configure cors. for

c# - Unity Reusing Ui element in list -

Image
i have ran sort of problem in project, creating scroll listview show elements present in list in screen. using button in panel show list. when call showlist() shows elements in list. but if add objects list , again call showlist() make clone of previous object instantiated objects present. to solve deleting clones using destroy() when list contain many item (300~400) deleting them cause lag in game . how can create object pool ui button or deactivate them. public class 2 : monobehaviour { public gameobject button_template; private list<gamename> gm = new list<gamename>(); public void exit() { var og = gameobject.findgameobjectswithtag("clone"); (int = 0; < og.length; i++) { destroy(og[i]); } } void start() { gm.add(new gamename("1")); gm.add(new gamename("2")); gm.add(new gamen

email - Gmail / Inbox : have our website icon show instead of the circled letter -

Image
i don't understand how websites (linkedin, youtube, houzz, ...) have favicon show in google inbox. awesome! how come mine not show? first thought had put favicon.ico in public root folder... found out have. so, allow me have favicon display instead of colored circled letter in gmail / inbox (or other apps) ? thank all! if haven't figured out now, here's late answer :) there's couple of different kind of "favicons" can specify , assume gmail uses 1 of other kinds of favicons. article has explanation https://css-tricks.com/favicon-quiz/ , recommends use service http://realfavicongenerator.net/ generate code adding these other kind of favicions site.

gcc - Invalid operands for binary AND (&) -

i have "assembly" file (containing directives ) // declare protected region somewhere within stack .equiv prot_start, $stack_top & 0xffffff00 - 0x1400 .equiv prot_end, $stack_top & 0xffffff00 - 0x0c00 combined linker script: sections { "$stack_top" = 0x10000; } assembling produces output file.s: assembler messages: file.s: error: invalid operands (*und* , *abs* sections) `&' when setting `prot_start' file.s: error: invalid operands (*und* , *abs* sections) `&' when setting `prot_end' how can make work? why not possible? you have linked gas docs, rationale inability? answer: gas must communicate operations linker through elf object file, , things can conveyed + , - ( - + negative value). fundamental limition of elf format, , not lazyness gas devs. when gas compiles object file, link step follow, , relocation determine final value of symbol. question: why can + conveyed, not & ? answer:

jquery - Get the data-url correctly using javascript function -

i creating delete comment function , pieces of html delete comment functionality. <div id="comment-area"> <div class="list-border"> <small class="mdl-button delete-comment js-delete-comment pull-right" data-url="http://myproject.com/comment_controller/delete_comment/12/6"> x </small> </div> <div class="list-border"> <small class="mdl-button delete-comment js-delete-comment pull-right" data-url="http://myproject.com/comment_controller/delete_comment/13/6"> x </small> </div> </div> and function delete comment, automatically loaded when document ready, function delete_comment () { $('.delete-comment').click( function (e) { var url = $('.delete-comment').attr('data-url'); $.ajax({ url: url, type: 'get', datatype: 'json', success: function (dat

php - What kind of algorithm should I use to find similarities in a db? -

let's have 1000 users app. ask them 100 questions answers yes/no , record answers in seperate table. now, want see people has given same answers @ least 20 questions. what kind of algorithm should follow in order this? relevant keywords googling? p.s. work in wamp environment. join answers table itself, selecting answers share same question_id , answer have different user_id . group rows both user_id s , use having clause exclude less 20 matching answers. example looking users similar user user_id "1": select distinct a2.user_id answers inner join answers a2 on a.question_id = a2.question_id , a.answer = a2.answer , a.user_id != a2.user_id a.user_id = 1 group a.user_id, a2.user_id having count(*) >= 20; technically don't need group a.user_id in case i've left there in case want modify where clause return results more 1 a.user_id .

ios - How to change UISplitVIew's TableView Width -

i have ipad app in portrait mode due shorter width of detailview hiding content in according width wise. want shorter width of table view. idea? simple , easy feature of ios 8. in .h file: @property(nonatomic, assign) cgfloat maximumprimarycolumnwidth ns_available_ios(8_0); in .m file: self.maximumprimarycolumnwidth = 100; self.splitviewcontroller.maximumprimarycolumnwidth = self.maximumprimarycolumnwidth;

Javascript onload and script callback functions, which takes the precedence? -

i'm loading external script uses callback function, returns specific data. if data not received error should displayed. here code i've made: <script> //setting initial state function work once var visitors_loaded=false; var my_callback = function( data ) { if (visitors_loaded) return 0; if (data) { //success: callback function called , has proper data visitors_loaded=true; alert(json.stringify(data)); } else alert ('error'); //something went wrong }; </script> <script onload="my_callback(null)" onerror="my_callback(null)" src="https://api.clicky.com/api/stats/4?site_id=32020&sitekey=9a19b1a4d1171193&type=visitors&date=this-month&output=json&json_callback=my_callback"></script> as can see... many things can go wrong script, naturally added onerror event. on error event fires if change host name or domain of script non-existent. however, if make change

android - Add Item from EditText to RecyclerView -

i making project college. has notice page can post notice. notice page has recyclerview notices posted can viewed users using app, if text stuck permanent page. notice gets saved in database successfully, dont want show notice database, project purpose. ever time on clicking post button app force closes. wrong in code. please help. below files. activity_notice.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <relativelayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:layout_width="250dp" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge"