Posts

Showing posts from April, 2010

cors - CorsFilter losing Representation entity -

my works corsfilter when file upload post i'm losing representation entity @ resource level. please i'm stuck. following source (/collections get), (/fileupload post not working). corsfilter corsfilter = new corsfilter(getcontext(), router); corsfilter.setallowedorigins(new hashset(arrays.aslist("*"))); corsfilter.setallowedcredentials(true); corsfilter.setallowingallrequestedheaders(true); corsfilter.setskippingresourceforcorsoptions(true); corsfilter.setnext(collectionsresource.class); router.attach("/collections", corsfilter); corsfilter.setnext(fileuploadresource.class); router.attach("/fileupload", corsfilter); in representation entity in resource debugger saying entity [false/*] . representation null. i think should this: [multipart/form-data; .....] . the following html & ajax call please take look. missing in that? works fine me not post: <html> <head> <scri

jquery ajax bootsrap about modal pop up -

when click button class .btn-edit modal appears, when submit ajax request after if click button modal modal doesn't show. need refresh page work again. $(".btn-edit").click(function(){ $('#edit-profile').modal('show'); }); $(".update-form").submit(function(s){ s.preventdefault(); var website_name = $('input[name=website_name]').val(); var website_url = $('input[name=website_url]').val(); var type = $('#type option:selected').val(); var category = $('#category option:selected').val(); var sells = $('input[name=sells]').val(); var location = $('input[name=location]').val(); var payment = $('input[name=payment]').val(); var description = $("textarea#message").val(); $('#edit-profile').modal('hide'); $.ajax({ type: "post", url: "advertiser/update", data: {

java - GreenRobot Exception : de.greenrobot.event.EventBusException: Invoking subscriber failed -

time time exception. i use green-robot standard way, between views, fragments, activities, services , app, default instance, , time time stickyevents. i did't find other post related exception. idea, or hint start investigation ? the event bus working nicely (~ 20 events, 10 subscribers), user triggered no big workload in field. the complete stack-trace here : de.greenrobot.event.eventbusexception: invoking subscriber failed 10-27 15:37:00.522 25414-25414/fr.tech.app..u e/androidruntime: @ de.greenrobot.event.eventbus.handlesubscriberexception(eventbus.java:518) 10-27 15:37:00.522 25414-25414/fr.tech.app..u e/androidruntime: @ de.greenrobot.event.eventbus.invokesubscriber(eventbus.java:500) 10-27 15:37:00.522 25414-25414/fr.tech.app..u e/androidruntime: @ de.greenrobot.event.eventbus.posttosubscription(eventbus.java:429) 10-27 15:37:00.522 25414-25414/fr.tech.app..u e/androidruntime: @ de.greenrobot.event.eventbus.postsingleeventforeventtype(eventbus.

MySQL get same parameters with different key -

i have 2 tables: users: id first_name last_name -------------------------------- 1 john smith 2 adam jones user_planner_tasks: id moderator user_id ----------------------------- 1 1 2 2 2 1 i display each task 'user_planner_tasks' table. while @ same time displaying first , last name of moderator , user corresponding id's. i wish have this: id moderator first_name last_name user_id first_name last_name ------------------------------------------------------------------------------------- 1 1 john smith 2 adam jones i know have use join of sort cannot, life of me, figure out. reference great! select t.id, t.moderator, m.first_name, m.last_name, t.user_id, u.first_name, u.last_name user_planner_tasks t left join users u on t.user_id = u.id left join us

mysql - Trying to figure out how to create this procedure -

i can't seem figure out , i've been @ sometime great thank you. i have prepare simple procedure accepting 1 parameter, date value, , using date addition functions in sql (mysql if possible) return parameter value minus 1 day create procedure get_date begin date_add(date,interval expr type) end; / exec get_date this come far. appreciated. that question not select statement (ie, computing minus 1 day); need sql procedure. maybe create function create function simplefunction (s datetime) returns datetime deterministic return date_sub(s, interval 1 day); select simplefunction (anydate);

java - eclipse maven Circular placeholder reference Error using profiles -

when packaged target/war using maven profiles, eclipse refreshed project, , try launch on tomcat, constantly org.springframework.beans.factory.beandefinitionstoreexception: invalid bean definition name 'datasource' defined in class path resource [applicationcontext-resources.xml]: circular placeholder reference 'jdbc.driverclassname' in property definitions mention: use sts 3.7.1, based on eclipse 4.5.1 right click on project -> maven -> select maven profiles... , pickup profile. ...this stupid behavior in eclipse

c# - Returning response message from self hosted web service and is it soap? -

currently have small client: static void main(string[] args) { myservice.calculatorclient ws = new myservice.calculatorclient(); ws.open(); console.readline(); ws.xml("<document></document>"); ws.close(); console.readline(); } which works fine sends string web service , generate xml , store somewhere. i response though, if use wcftestclient.exe see response. <s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:header> <a:action s:mustunderstand="1">http://microsoft.servicemodel.samples/icalculator/xmlresponse</a:action> <a:relatesto>urn:uuid:325d2f97-c1f0-4b66-912a-d9b3a6b097a7</a:relatesto> </s:header> <s:body> <xmlresponse xmlns="http://microsoft.servicemodel.samples"> <xmlresult&g

javascript - WordPress comment validation -

i created validation function validating email address , textrea content in wordpress comment: <script> function validatetext(){ var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; var email = document.getelementbyid('email').value; if (email == '' || !re.test($email)) { alert("please enter correct email address") return false; } else if(document.getelementbyid("comment").value.length == ""){ alert("please add comment") return false; } return true; } </script> the above javascript code not work expected. there grammatical errors in it? i added onclick="return validatetext();" submit button: <input name="submit" type="submit" id="submit" class="submit" value="&quo

c# - What does "No suitable directory found to load unmanaged modules" mean in EMGU? -

i'm emgu/cv noob using using emgu3.0 (emgucv-windows-universal 3.0.0.2157), visual studio 2013, , target platform of "any cpu". i'm trying c# "hello world" app @ http://www.emgu.com/wiki/index.php/hello_world_in_csharp#hello_world_-_version_2 looks this: using emgu.cv; using emgu.cv.cvenum; using emgu.cv.structure; using emgu.cv.ui; using system.drawing; ... //create 3 channel image of 400x200 using (mat img = new mat(200, 400, depthtype.cv8u, 3)) { img.setto(new bgr(255, 0, 0).mcvscalar); // set blue color //draw "hello, world." on image using specific font cvinvoke.puttext( img, "hello, world", new system.drawing.point(10, 80), fontface.hersheycomplex, 1.0, new bgr(0, 255, 0).mcvscalar); //show image using imageviewer emgu.cv.ui imageviewer.show(img, "test window"); } it builds ok. when ran got "the type initializer 'emgu.cv.matinvoke' threw ex

Disable Sublime Text 3 html autocomplete in Markdown -

i writing prose in academic markdown. autocomplete can pretty useful when recommends words document, html tags annoying. how can stop st3 stop suggesting html tags in markdown files. i have tried "auto_complete": false doesn't disable autocomplete. don't know why.

sql - Google BigQuery: Query too large, part 2 -

can gbq team share more why "query large" error might popped? , more workarounds problem experienced: in particular, give more details of doing when popped , of resolutions never sufficed appease query-too-large gods. doing rather long comma join like select fields a_1, a_2, ..., a_15, each had many records: 1 - 41854 2 - 32287 3 - 16876 4 - 1799 5 - 3112 6 - 6412 7 - 6424 8 - 7286 9 - 14832 10 - 17167 11 - 51149 12 - 3895 13 - 8139 14 - 38395 15 - 22858 a_4 - a_8 1 query , needed broken or original result table result in same error. a_12 - a_15. (i did not optimize partitioning minimal number of a_i's, broke originals according date partitions coming application.) the queries producing a_i's, i=1,...,15, pared down in terms of fields , aggregation. i.e. drawing necessary fields , aggregating as application allows (considering thoughtful, clever reductions). still popped error. the next step aggregate away important information. worked reducing each of a

json - API design for server client application -

i trying implement api serve client content, , bit unsure on how design api this. in particular question is: is better have specific apis serving specific scenarios @ cost of client making multiple requests, or better have do-it-all api serves every possible value in order minimize requests client has make. for example, in application lists pictures descriptions/titles/tags/etc there 2 scenarios: page 1: only show picture in grid. list picutres (or limited amount, 100) click on picture open view , present additional info: description, title, location, tags, text, comments. now design in 2 ways: (1) get /api/v1/pictures returning json containing information, like: [ { "pictureurl": "someurl", "text": "sometext", "description": "somedesc", "tags": "sometags", "location": "somelocation", { ] (2) get /api/v1/pictures returning array of pictures ids: [ { &qu

mongodb - Meteor/Mongo nested arrays update -

i'm new meteor/mongo/js stack , i'm getting lost in json arrays , referencing them. based another answer ( , docs) think close... a document in orders collection, document has nested arrays. order -> orderlines -> lineitems: sample doc: { "_id" : "27tgprtmwyqppfkdn", "orderlines" : [ { "lineid" : 1, "name" : "cheese & pickle", "instructions" : "", "lineitems" : [ { "name" : "cheddar cheese", "quantity" : 1 }, { "name" : "branston pickle", "quantity" : 1 }, { "name" : "focaccia roll", "quantity" : 1 } ] } ] } what i'm trying meteor/mongo shell: add "in

Memory management in ruby C extensions -

i've started working ruby c extensions. i'm having trouble understanding gc picks , not, , if can manually free 'native' ruby objects (like ruby arrays/strings) created in c snippet earlier on. lets @ example illustrating question, first function allocates memory might, or might not free'd. second function manually free's memory , i'm wondering if break things in long run. see below background info on intend use it. static value test_func(value self) { value ary, str1, str2; ary = rb_ary_new(); rb_ary_push(rb_str_new2("test-blabla")); rb_ary_push(rb_str_new2("test2-blabla")); return ary; } now have figured out if run this, gc free on program termination, , therefore knows existance , i'm asuming gc sweep when running on code on daemon (i.e. background process). my problem gc doesn't sweep enough wondering if adding function below hurt (e.g. break gc or something) static value test_func_free(valu

mysql - How can I prevent SQL injection in PHP? -

if user input inserted without modification sql query, application becomes vulnerable sql injection , in following example: $unsafe_variable = $_post['user_input']; mysql_query("insert `table` (`column`) values ('$unsafe_variable')"); that's because user can input value'); drop table table;-- , , query becomes: insert `table` (`column`) values('value'); drop table table;--') what can done prevent happening? use prepared statements , parameterized queries. these sql statements sent , parsed database server separately parameters. way impossible attacker inject malicious sql. you have 2 options achieve this: using pdo (for supported database driver): $stmt = $pdo->prepare('select * employees name = :name'); $stmt->execute(array('name' => $name)); foreach ($stmt $row) { // $row } using mysqli (for mysql): $stmt = $dbconnection->prepare('select * employees name = ?');

python - Installing Ghost.py on windows 8 -

for starters, dislike whoever made website builder called "ghost" cause makes topic annoying search. anyways, trying these instructions , seems i'm good. step 1) pyqt, have anaconda, there. play safe, start typing (in cmd): conda update conda conda update anaconda #we're date , ready go... and finally, conda install pyqt it returns saying: #all requested packages installed. # packages in environment @ c:\users\(my name)\anaconda: step 2) install flask. (i have pearl well...so needs .exe) pip.exe install flask returns: requirement satisfied (use --upgrade upgrade): flask in c:\users\(my name)\anaconda\lib\site-packages i guess means it's there? step 3) install paste pip.exe install paste returns: same thing flask step 4) install ghost.py, tried mentioned instructions, said didn't exist. after digging around, looks using same method, "pip.exe install ghost.py" way go, that, , again, cmd tells me same think flask ,

spring - How to pass data from angulajs form to struts 2 action class -

here developing shopping cart.this angulajs controller.this method use send data action class using $http.post method angular.module("sportsstore") .constant("dataurl", "angularaction") .constant("orderurl", "angularsaveaction") .controller("sportsstorectrl", function ($scope, $http, $location, dataurl, orderurl, cart) { enter code here`$scope.data = { }; $scope.sendorder = function (shippingdetails) { var order = angular.copy(shippingdetails); order.products = cart.getproducts(); console.log(order);--------------(1) $http.post(orderurl, order) .success(function (data) { //$scope.items=data; $scope.data.orderid = data.id; cart.getproducts().length = 0; console.log(data);---------------(2) }) .error(function (error) { $s

jquery - Multiscroll.js inside div -

is possible "wrap" multiscroll.js inside div , use section in 1 page structure (using anchors)? something like: header multiscroll static section footer you don't need that. just use fixed positioned elements outside mutiscroll wrapper. checkout fixedheaders.html demo available in plugin files .

Windows Phone 8.1 Unit Testing -

i have windows 8.1 universal application have run issue unit testing. using mstest. have test needs make sure exception thrown. test pretty simple, if null value if passed in, fails. exception thrown should argumentnullexception . however, having trouble finding correct way pass. tried using expectedexpection attribute unable find reference work windows phone unit test project. did find assert.throwsexception not able find information on how use it. what best way make sure exception being thrown , test pass if thrown? in mstest use expectedexception this: [testmethod] [expectedexception(typeof(argumentnullexception))] public void testmethod1() { dowhateverthrowsanargumentnullexception(); } if don't way can @ project on github: mstestextensions

java - Apache Solr: I have run this command in Cygwin Terminal. ./nutch crawl urls -dir newCrawl -solr http://localhost:8939/solr/ -depth 10 -topN 10 -

solrindexer: starting @ 2015-10-15 10:13:00 adding 90 documents: java.io.ioexception: job failed! solrdeleteduplicates: starting @ 2015-10-15 10:13:11 solrdeleteduplicates: solr url: http://localhost:8939/solr/ exception in thread "main" java.io.ioexception: org.apache.solr.client.solrj.solrserverexception: java.net.connectexception: connection refused: connect @ org.apache.nutch.indexer.solr.solrdeleteduplicates$solrinputformat.getsplits(solrdeleteduplicates.java:200) @ org.apache.hadoop.mapred.jobclient.writeoldsplits(jobclient.java:810) @ org.apache.hadoop.mapred.jobclient.submitjobinternal(jobclient.java:781) @ org.apache.hadoop.mapred.jobclient.submitjob(jobclient.java:730) @ org.apache.hadoop.mapred.jobclient.runjob(jobclient.java:1249) @ org.apache.nutch.indexer.solr.solrdeleteduplicates.dedup(solrdeleteduplicates.java:373) @ org.apache.nutch.indexer.solr.solrdeleteduplicates.dedup(solrdeleteduplicates.java

python - Reorder the Range with specific way -

i'm looking way reorder given range have first, last, middle one, middles of middles , on..., if @ 0-15 range this: neighbor members come @ last iteration. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 15 8 4 12 2 6 10 13 1 3 5 7 9 11 14 any ideas algorithm? here's solution uses queue instead of recursion. 13 , 14 positioned differently example, if consistently consider middle of even-length list element after middle, 14 comes first. import collections def reorder(seq): '''yield items seq reordered http://stackoverflow.com/q/33372753/ seq can sequence, eg. list or python 3 range object. ''' # output first , last element before middles if seq: yield seq[0] if len(seq) > 1: yield seq[-1] # queue of range indices (start, stop) queue = collections.deque([(1, len(seq)-1)]) while queue: start, stop = queue.popleft() if start < stop: middle = (start +

Is it possible to setup Travis-CI for a public GitHub repo I'm only collaborator in? -

i'm collaborator https://github.com/martinh/libconfuse/ , can push , tag stuff. references on interwebs url, convenient able set travis-ci (and more) repo, not own fork. possible? (the original maintainer can no longer spare time.) considering options, maybe simplest way go maintain in own fork? ( https://github.com/troglobit/libconfuse ) you're required have github admin access setting hooks, yes use simple way , fork or see owner gives required access. alternatively might convinced transfer ownership github not redirects repo's (they hosted sites), defeat purpose ( https://help.github.com/articles/transferring-a-repository/ )

javascript - Click an object and show another - simple jQuery snippet -

i have simple click , show snippet needs bit of modifying. behavior striving when click on li element, hide other grey boxes other li objects. also, need hide grey boxes when click on body of document (e.g. > outside of ul container). here sample code: $('.openmodal').on('click', function (e) { $('#servicelist').find('.modal.active').removeclass('active'); e.preventdefault(); $(this).find('.modal').toggleclass('active'); }); here fiddle. i having bit of hassle reaching desired effect. how can achieve this? thanks in advance! please have @ updated fiddle: https://jsfiddle.net/xvopdkf8/4/ you missed giving id ul element <ul id="servicelist"> modified js code follows: $('.openmodal').on('click', function (e) { $('#servicelist').find('.modal.active').removeclass('active'); e.preventdefault(); $(this).find('.modal'

jquery - Getting the src of an img tag on radio select -

i have html code follows: <div id="input-option227"> <div class="radio"> <label> <input type="radio" name="option[227]" value="17" /> <img src="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_1-50x50.jpg" alt="black" class="img-thumbnail" /> black </label> </div> <div class="radio"> <label> <input type="radio" name="option[227]" value="18" /> <img src="http://localhost/upload/image/cache/catalog/demo/apple_logo-50x50.jpg" alt="green" class="img-thumbnail" /> green </label> </div> </div> i want img src when select radio button means when radio value 17 want alert: http://localhost/upload/image/cache/catalog/demo/ca

ios - 'Save for Development Deployment' equivalent in Xcode 6.4 -

Image
i have code sign app using development certificate, there option in xcode 7 allows that. how can same thing xcode 6.4?

vb.net - Hide / show line programatically in report -

i using vb.net , reportviewer generate report. need programmatically hide line depending whether checkbox checked or not. (a simple if statement). how call this? how refer reportviewer's line element? how tell hide/show? thank in advance if checkbox ticked/unticked before loading report, easiest way achieve using reportparameters . reportparameters allow pass values rdlc report. once report loaded, can define report behavior based on parameter values. code before loading report: 'retrieve checkbox value dim ischecked boolean = yourcheckbox.checked 'create new parameter send report dim parameters new list(of reportparameter) parameters.add(new reportparameter("checkboxvalue", ischecked)) 'send parameter report reportviewer.localreport.setparameters(parameters) and after you've added code, need define parameter in .rdlc file well. .rdlc file open in visual studio, go report menu , select report parameters . to consistent code,

neural network - Does Word2Vec has a hidden layer? -

when reading 1 of papers of tomas mikolov: http://arxiv.org/pdf/1301.3781.pdf i have 1 concern on continuous bag-of-words model section: the first proposed architecture similar feedforward nnlm, non-linear hidden layer removed , projection layer shared words (not projection matrix); thus, words projected same position (their vectors averaged). i find people mention there hidden layer in word2vec model, understanding, there 1 projection layer in model. projection layer same work hidden layer? the question how project input data projection layer? "the projection layer shared words (not projection matrix)", mean? from original paper , section 3.1, clear there no hidden layer: "the first proposed architecture similar feedforward nnlm non-linear hidden layer removed , projection layer shared words". with respect second question (what sharing projection layer means), means consider 1 single vector, centroid of vectors of words in conte

java - Trouble with toString method -

Image
why won't variables basica (crank) , basicb (pedal) show in arraylist display along other values? there's class called part can post if needed, seems ignoring variables. main class package main; import java.util.arraylist; import java.util.list; import java.util.scanner; public class testassembledpart { public static void main(string[] args) { // todo auto-generated method stub scanner sc = new scanner(system.in); list<assembledpart> aparts = new arraylist<assembledpart>(); aparts.add(new assembledpart("a200", "crank & pedal", 10, 3.5, "crank", "pedal")); system.out.println("part before stock level change - start"); system.out.println(assembledpart.toassembledstring(aparts)); } } assembledpart class package main; import java.util.*; public class assembledpart extends part { private string basica; private string basicb; public assembledpart(string i

rspec - How to test validations in a Model Concern in Rails 4? -

i have model concern validations: module uservalidations extend activesupport::concern valid_email_regex = /\a([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i included validates :email, :presence => true, :format => valid_email_regex, :uniqueness => { case_sensitive: false } end end this concern used multiple forms. now plan write spec concern not need test same set of validations in different form specs. however, have not found way it... i have tried things failed... require 'spec_helper' class dummyclass include activemodel::validations include activerecord::validations include uservalidations attributes :email, :first_name, :last_name end describe "uservalidations" subject { dummyclass.new } { is_expected.to validate_presence_of :email } end error stack: /home/eyang/.rvm/gems/ruby-2.0.0-p594/gems/term-ansicolor-1.3.2/lib/term/ansicolor.rb:239:in `term_ansicolor_attributes'

android - How to set height dynamically to listview with webview -

Image
i have listview of webviews in scrollview. listview showing 5 rows proper height, till webview content not loaded. once content loaded in webview (through network call), can see 3 rows increased height, not sure weather listview height increased or scrollview height increased or not. here xml code, <scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:fillviewport="true" android:scrollbars="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <relativelayout android:id="@+id/relativelayout1" android:layout_width="match_parent" android:lay

magento - Is it possible to use two different css styles for the same theme in two stores -

we using same theme 2 magento stores. is possible change css styles differently both stores? in same root folder using different domains. for example if change color navigation, change color in both stores. is there explanation how this? thank you in magento, have store specific layout handle. can use same handle in local.xml add different css in same theme. <store_custom1> <reference name="head"> <action method="addcss"><stylesheet>css/store_custom.css</stylesheet></action> </reference> </store_custom1> <store_custom2> <reference name="head"> <action method="addcss"><stylesheet>css/store_custom2.css</stylesheet></action> </reference> </store_custom2> here custom1 , custom2 store view code. you can check appied handles using below code: print_r($this->getlayout()->getupdate()->gethandles()

c# - Entity Framework migrations under the hood -

i've been using entity framework migrations time , started wondering how work under hood. mean following: how ef understand model in application , db scheme different? far know, there's table __migrationhistory in database migrations stored in migrations folder in application (applies code-based migrations). in __migrationhistory table, there's column called model contains kinda hash. hash exactly? snapshot of model? changes ef needs apply previous migration one? if model snapshot, mean ef have figure out how transform current model snapshot each time decided update database. however, if changes, mean ef have apply changes current model in order understand when db model , application model different. the question is, can read how migrations implemented , model column in database. appreciate advices or links. update: i've checked resources provided , i've found out, model column snapshot of model. means, when run update-database command, ef goes db, c

php - Get value from my array -

this question has answer here: how can access array/object? 4 answers i got following array: $resultaat= array('afterpay result' => $afterpay->order_result); and following output: array ( [afterpay result] => stdclass object ( [return] => stdclass object ( [afterpayorderreference] => 928241d9d1dfb45d7513f3bbb8f063 [checksum] => 8452479310a82dc9a8ce574e6ce180f4 [resultid] => 0 [statuscode] => [timestampin] => 1445938695282 [timestampout] => 1445938700423 [transactionid] => 450831 ) ) ) how retrieve value: 'statuscode' , value 'resultid' can save them in database. can please me? with foll

android - BrightcoveExoMediaPlayer custom controls -

i trying add custom controls bright cove exo media player hls streaming. able play hls videos default controls not want use. any suggestions. first of have hide default media controller of brightcove , can achieved below method brightcovevideoview.setmediacontroller((mediacontroller) null); then need design custom controller per needs. sample attaching below public class videocontrollerview extends framelayout { private static final string tag = "videocontrollerview"; private mediaplayercontrol mplayer; private context mcontext; private viewgroup manchor; private view mroot; private progressbar mprogress; private textview mendtime, mcurrenttime,mtextviewlive; private boolean mshowing; private boolean mdragging; private static final int sdefaulttimeout = 3000; private static final int fade_out = 1; private static final int show_progress = 2; private boolean