Posts

Showing posts from August, 2011

node.js - Manually call passport for authentication -

i develop restful nodejs api protected oauth2 authentication using passport. var express = require('express'); var passport = require('passport'); var port = process.env.port || 8080; var app = express(); app.use(passport.initialize()); // create our express router var router = express.router(); var creaturecontroller = require('./controllers/creature'); router.route('/creature').get(passport.authenticate('accesstoken', {session: false}), creaturecontroller.getprofile); in case, route protected , requires send valid token in order access route. i want find way authenticate "users" manually, calling function, take username , password of user want authenticate. passport exposes req.login() function can used login user manually. app.post('/login', function (req, res, next) { var user = user.findorcreate(req.body); // … authentication or whatever req.login(user, ...

php - Segmentation fault (11) when save Laravel 4.2 Eloquent model -

i have problem when try duplicate laravel eloquent model. model has 121 columns , work firebird database, apache 2.2.22, php 5.4.35 , debian. when save method execute new model stored in database, redirect method not execute , browser display "the connection server reset while page loads." in apache logs error "segmentation fault (11)". i try run code artisan command still same error. on windows not work - cli has stopped working. php code: $asort = asort::on($connname)->find($asortid); // new asort_id $newasortid = db::connection($connname) ->table('rdb$database') ->select(db::raw('gen_id(seq_asort, 1) id')) ->lists('id'); $newasort = new asort; $newasort = $asort->replicate(); //$newasort->setrawattributes($asort->getattributes()); $newasort->setconnection($connname); $newasort->asort_id = $newasortid[0]; $newasort->asort_kod = iconv(...

c# - Select and updating data from datatable -

i select data datatable, using following code,but throws exception not familiar with. "index outside bounds of array." tblrooms.select(idroom = 4) value of idroom in thetblroom don't know why causes error. foreach (datarow dr in tblroomcart.rows) { datarow drroom = tblrooms.select("idroom =" + dr["idroom"])[0];//here error in line } as exception says,index out of bounds,you reading first element (with index 0) there no elements in collection. same this: int[] array = new int[0]; int x = array[0];//you exception here add if statement make sure there @ least 1 element,like: int[] array = new int[0]; if (array.length > 0) { int x = array[0]; }

clojure - returning a data type from a fn literal -

the below expression works - ((fn[n][(take n (range))]) 10) while below throws error - (#([(take % (range))]) 10) why cant return data type function literal ? if absolutely want return "data" anonymous function using # reader macro use do . #(do [1 2]) as @mars said have alternative use vector function. #(vector 1 2)

angularjs - $state, $stateParams, getting undefined object -

i getting unexpected results both methods. i have $state configed $stateprovider .state('status', { url: "/status/:payment", controller: 'questctrl', templateurl: "index.html" }); and on controller have: angular.module('quest').controller('questctrl',function($scope,$stateparams,$state){ console.log($stateparams.payment); // undefined console.log($state); // object {params: object, current: object, $current: extend, transition: null} } i used $stateparams in other projects , worked can't figure out going on here.. ['$scope','$stateparams','$state', function($scope, $http, $stateparams, $state) the names of services don't match variables. so $http $stateparams service, $stateparams $state service, , $state undefined. my advice: stop using array notation...

ios - Want to use both silent push notification and remote push notification based on app state -

is possible use silent push notification when app in foreground , remote push notification (with alerts) when app in background or killed? yes possible. need read following official apple documentation on this applepushservice https://developer.apple.com/notifications/

database - Django: migrations for tables that are not linked to models -

i have set of tables (mostly denormilized pre-calculated values storages) not linked model, use raw select queries on them. possible use migration frameworks them (for example, want add column , deploy change environments). thanks. you can use usual migrations system. first, create empty migration (in whatever app appropriate). python manage.py makemigrations --empty yourappname then put in whatever runsql operations need (including sql reverting changes, if want). operations = [ migrations.runsql("create ...", "drop ..."), ... ] the result can run right alongside migrations django models. python manage.py migrate

android - sliding up panel - thin line sliding panel under google mapfragment -

Image
i made slidinguppanel using repository https://github.com/dlukashev/androidslidinguppanel-foursquare-map-demo however, contains 1 bug not covered anywhere. when touch anywhere expand panel (listview) works well, while i'm trying expand holding top of list view (blue line on screen2) panel hide under map (framelayout) (screen3) how it's possible blue line hiding panel under mapfragment , rest of listview expand well? any ideas why? please give me hint how fix it? please @ screen: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent"> <org.sothree.slidinguppanel.slidinguppanellayout android:id="@+id/slidinglayout" android:gravity="bottom" app:sh...

Open my console as default when running the Eclipse plugin -

i working on eclipse plugin , have need of communication console. have developed console using this: public void openconsole() { myconsole = createconsole1(); } private ioconsole createconsole1() { //creating console title welcome soc console. ioconsole ioconsole = new ioconsole("welcome console.",null); //adding created console console list in console view. consoleplugin.getdefault().getconsolemanager().addconsoles(new iconsole[] {ioconsole}); consoleplugin.getdefault().getconsolemanager().showconsoleview(ioconsole); ioconsoleoutputstream opstream = ioconsole.newoutputstream(); try { opstream.write("myconsole>"); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } but after deploying none of console visible in plugin , message shows this: no console display @ time. now need open console when open plugin instead of this. me if know this. least may me lot please help. ...

unity3d - How to get device token of device in Unity 5? -

i tring device token , dont want use update function. right using following function: if (!tokensent) { token =unityengine.ios.notificationservices.devicetoken; if (token != null) { // send token provider print ("my device token"); hextoken= "%" + system.bitconverter.tostring(token).replace('-', '%'); tokensent = true; } }

c++ - cocos2d-x: can not create callback from onContactBegin -

i have problem collisions. use vs 2013 community edition , create oncontactbegin function this: bool gamescene::oncontactbegin(cocos2d::physicscontact &contact) { physicsbody* bodya = contact.getshapea()->getbody(); physicsbody* bodyb = contact.getshapeb()->getbody(); return true; } but when try create contact listener: auto contactlistener = eventlistenerphysicscontact::create(); contactlistener->oncontactbegin = cc_callback_1(gamescene::oncontactbegin, this); _eventdispatcher->addeventlistenerwithscenegraphpriority(contactlistener, this); my precompiler starts cry on cc_callback_1 function: no instance of overloaded function std::bind matches argument list any help?

dataframe - Load dataset from "R" package using data(), assign it directly to a variable? -

how load dataset r package using data() function, , assign directly variable without creating duplicate copy in environment? put simply, can without creating 2 identical dfs in environment: > data("faithful") # old faithful geyser data datasets package > x <- faithful > ls() # have 2 identical dfs - x , faithful - in environment [1] "faithful" "x" > remove(faithful) # i've removed 1 of redundant dfs try 1: my first approach assign data("faithful") x . data() returns string. have df faithful , character vector x in environment. > x <- data("faithful") > x [1] "faithful" # string, not df "faithful" datasets package > ls() [1] "faithful" "x" try 2: tried little more sophisticated in second attempt. > x <- get(data("faithful")) # works far assignment goes > ls() # still duplicate copy [1] "faithful" "x...

php - Display text once within for loop on the first loop -

i have sql query inside loop , want echo of success of these query once. here part of code <?php for($i=0;$i<sizeof($assigned_project_id);$i++){ $sql2="select * assign_task inner join branch on assign_task.branch_id=branch.branch_id project_id=".$assigned_project_id[$i]." , user_id=1"; $query2=mysqli_query($con,$sql2); if(mysqli_num_rows($query2)>0){ echo" have assigned following reports"; } while($row2=mysqli_fetch_assoc($query2)){ echo $row2['branch_id']."&nbsp;".$row2['branch_name']."<br/>"; } } ?> i want display "you have assigned following reports" once. please me. use below <?php $test =0 ; for($i=0;$i<sizeof($assigned_project_id);$i++){ $sql2="select * assign_...

c++ - Does opencv have Savitzky Golay or Polynomial fit? -

i can't find similar savitzky golay polynomial fit on opencv. standard smoothing operation though, seems should have. know of have? using c++ worth. thanks! -tim it not clear need do: fit or smooth, mentioned both. if need smooth using opencv can try kalman filter (fit in way , smooth), smooth-2d (using 1d-data) or your own convolution smooth kernel 1d+1d using 1d-data kernelx convolution (the fastest way smooth). opencv near real time image , video processing library, , contains common task solvers this, no polynomial fitting among them yet. if need fitting (not smoothing) can use polynomial fitting matrix equation , calculate answer in simple way mat objects in opencv has inv() (inverse) , t() (transpose) functions.

javascript - Using call to pass context -

i'm trying use call pass context of utilities object can access members (alldata array, etc) within mytest function. i'm getting error: referenceerror: alldata not defined this tells me context lost , guess i'm not binding context correctly. how do this? var utilities = { alldata : [], storage : [], apirequest : function () { this.alldata = ["a","b","c"]; var mytest = this.alldata.map.call(this, function (i, el) { var url = 'testphp.php/translate_tts?ie=utf-8&tl=zh-cn&q=' + i; return $.get(url, function (returned_data) { this.storage.push(returned_data); }); }); $.when.apply($, mytest).done(function () { log('done!'); log(this.storage[i]); }); great answer above. 1 thing emphasize @ point: whenever bind object @ initialization bound , cannot call/apply'd using c...

php - Run Magento 1.9.1.0 Dataflow Import Profile Programmatically -

Image
i've tried working, can't seem find solution. i'm looking run existing dataflow profile has id = 3, , has import file name configured. all research i've done, leads variation of following code: public function importproducts($profile_id = 3) { require_once('../app/mage.php'); mage::app()->setcurrentstore(mage_core_model_app::admin_store_id); // instantiate session "root" user. $usermodel = mage::getmodel('admin/user'); $usermodel->setuserid(0); mage::getsingleton('admin/session')->setuser($usermodel); // load dataflow profile. $profile = mage::getmodel('dataflow/profile'); $profile->load($profile_id); if (!$profile->getid()) { exit("profile id #{$profile_id} not exist."); } $profile->run(); $batchmodel = mage::getsingleton('dataflow/batch'); // reporting. $direction = ucwords($profile->getdirection()); ...

c# - IEntity where Key/ID type unknown -

i've been exploring use of data repositories in c# i'm working on first "big" application in quite time (and first c#). particularly used information http://web.archive.org/web/20150404154203/https://www.remondo.net/repository-pattern-example-csharp/ msdn , stackoverflow. i seem have gotten stuck @ think may quite simple, i've tried googling, etc. , either it's more complex thought, or i'm using wrong terminology. basically, when defining ientity interface this: namespace test.database { public interface ientity { int keyvalue { get; set; } } } that works great things, project using existing, nasty database (hence why i'm trying abstract business logic , other dev's future business logic far possible db) not keys integer. there keys character, integers, doubles, etc. there way can make interface's key property, type-agnostic? or looking @ whole thing wrong way? you use generics make typed based on situ...

python - Pygame borderless opening with some offset -

when try open borderless mode window start in top right corner of screen. looks this: http://puu.sh/ivb4y/304018da5e.jpg code looks this if __name__ == "__main__": import source.game, pygame pygame.mixer.pre_init(22050, 16, 2, 256) pygame.font.init() pygame.init() screen = pygame.display.set_mode((1920, 1080), pygame.noframe) source.game.game().main(screen) it might worth noting i'm running 2 monitors, i've tried running 1 , problem still happens, , if take resolution down below native still won't start in top right of screen. is there way fix such problem? edit: i went answers looking on in future. import os os.environ['sdl_video_window_pos'] = "0,0" screen = pygame.display.set_mode((1920, 1080), pygame.noframe) along other .init() statements , whatnot. looks want fullscreen: screen = pygame.display.set_mode((1920, 1080), pygame.fullscreen) you might want turn on hardware acceleration adn d...

Post form does not submit data entered by client-Thanks for your assistance -

here coding have visitors post informations; when visitor clicks on "submit", visitor sees thank page.(works fine) our problem data entered visitor not recorded on "requests.php" page created. thank solve , allow collect data on requests.php form , have form saved each time. <div class="content"> <form action="requests.php" method="post"> header('location: thank_you.php') <strong>&iquest;qu&eacute; limusina usted queria comprar?</strong><br> <textarea name="comments" rows="10" cols="50"></textarea> <br> <br> <p><strong>su informaci&oacute;nes (importante): click sobre &quot;submit&quot; al fin cuando usted ha terminado:</strong></p> <br> <strong>su nombre</strong><br> <input name="name" v...

php - Youtube Data API v3 pageToken for arbitrary page -

another question on revealed pagetokens identical different searches, provided page number , maxresults settings same. version 2 of api let go arbitrary page setting start position, v3 provides next , previous tokens. there's no jumping page 1 page 5, if know there 5 pages of results. so how work around this? a youtube pagetoken 6 characters long. here's i've been able determine format: char 1: 'c' i've seen. char 2-3: encoded start position char 4-5: 'qa' i've seen. char 6: 'a' means list items in position greater or equal start position. 'q' means list items before start position. due nature of character 6, there 2 different ways represent same page. given maxresults=1, page 2 can reached setting page token either "caeqaa" or "caiqaq". first 1 means start @ result number 2 (represented characters 2-3 "ae") , list 1 item. second means return 1 item before result number 3 (represented...

saving rotate images in R - avoiding background and maintaining size -

Image
i have below code based upon earlier question . when save image savethisplot.png, creates unwanted background , image size changes (it reduces). how can save image such rotated part of same size earlier (77 rows , 101 columns) , there no background? library(raster) r1 <- brick(system.file("external/rlogo.grd", package="raster")) r1 x <- crop(r1, extent(0,ncol(r1),0,nrow(r1))) plotrgb(x) x1 <- 0:ncol(x) y1 <- 0:nrow(x) z <- matrix(1, nrow=length(x1), ncol=length(y1)) col.mat <- t(apply(matrix(rgb(getvalues(x)/255), nrow=nrow(x), byrow=true), 2, rev)) # rotate 45 degrees persp(x1, y1, z, zlim=c(0,2), theta = 20, phi = 90, col = col.mat, scale=false, border=na, box=false) png("savethisplot.png") persp(x1, y1, z, zlim=c(0,2), theta = 20, phi = 90, col = col.mat, scale=false, border=na, box=false) dev.off() you can use transparent background, rotating plot require re-sizing. when save plot can set png(...

html - Slide up, and hide a div using jquery on click -

i want hide div when user clicks on element animation. want div slide up, , hide ( display: none ) onclick . possible? if so, how? thanks help! you can use .slideup() method. jsfiddle css #container { border: 3px double blue; height: 300px; } html <div id="container">this must slide up</div> <button>click me</button> js $(function() { $("button").on("click", function() { $("#container").slideup(); }); });

c++ - Synchronizing access to data using a "got there first" flag, instead of a lock/mutex -

suppose have function accesses globally shared data - , suppose function called multiple concurrent threads. naturally, need somehow synchronize access data. possible via mechanism have atomic flag, , whichever thread manages set flag can proceed access shared data? whereas losing threads not block on lock, return function. something following: given globally shared data along synchronization flag: namespace global { int x; int y; std::atomic_flag sync_flag = atomic_flag_init; } and our function accessed concurrent threads: void race() { // see if won race // if (!global::sync_flag.test_and_set()) { // won // global::x = 10; global::y = 11; } else { // lost... return; } } does above code guarantee global::x , global::y safely accessed single thread, , no race conditions occur? or not guaranteed due memory ordering problems? note never locked mutex or anything, no thread ends blocking. idea he...

Excel data validation by combining multiple conditions -

can excel validation formulas multiple conditions? have 1 column want 1) unique values 2) values have 10 characters(leading zeroes allowed) 3) have numbers i can unique values below formula: =countif($g:$g,g2)=1 how add other 2 conditions? if set type number, leading zeroes not displayed. formula =and(countif(g:g,g2)=1,len(g2)=10,isnumber(value(g2))) countif(g:g,g2)=1 checks unique condition. len(g2)=10 checks length, including leading zeros i.e., number stored in text format. isnumber(value(g2)) checks value of cell. and condition ensures above met.

python - Spark java.lang.VerifyError -

i following error when try call use python client spark. lines = sc.textfile(hdfs://...) lines.take(10) i suspect spark , hadoop versions might not compatible. here result of hadoop version: hadoop 2.5.2 subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r cc72e9b000545b86b75a61f4835eb86d57bfafc0 compiled jenkins on 2014-11-14t23:45z compiled protoc 2.5.0 source checksum df7537a4faa4658983d397abf4514320 command run using /etc/hadoop-2.5.2/share/hadoop/common/hadoop-common-2.5.2.jar i have spark 1.3.1. file "/etc/spark/python/pyspark/rdd.py", line 1194, in take totalparts = self._jrdd.partitions().size() file "/etc/spark/python/lib/py4j-0.8.2.1-src.zip/py4j/java_gateway.py", line 538, in __call__ file "/etc/spark/python/lib/py4j-0.8.2.1-src.zip/py4j/protocol.py", line 300, in get_return_value py4j.protocol.py4jjavaerror: error occurred while calling o21.partitions. : java.lang.verifyerror: class...

PHP math calculation really slow -

so wrote script can enter number , program find highest prime number in range. problem in php, calculation slow larger numbers, compared javascript version, exact same thing faster. //here php code: <form> <input type="text" name="input"> </form> <?php $input = $_get['input']; function prime($num) { if($num < 2) return false; ($i = 2; $i < $num; $i++) { if($num % $i == 0) return false; } return true; } for($i = $input; $i > 0; $i--) { if(prime($i)) echo $i; if(prime($i)) exit(); } } here javascript variant: <html> <script> var input = prompt("enter number"); function prime(num) { (var = 2; < num; i++) { if(num % == 0) { return false; } } ...

Accessing a stored image resource using Bootstrap in XPages -

when call image image resource library: <xp:image url="/usergroup.png" id="image1"></xp:image> on page works fine, trying use bootstrap img code throws error , not load. in xpages how access image resource bootstrap img <img src="/usergroup.png" > it looks stored in nsf. xp:image looks in root of nsf, whereas img tag looking @ root of server. try removing leading / .

pointers - C++/CLI how do I tell if a handle isn't pointing to any object -

in normal c++ there pointers indicated null if not pointing object. class* object1 = null; //null special value indicates //that pointer not pointing object. if(object1 == null) { cout << "the pointer not pointing object" << endl; } else { cout << "the pointer pointing object" << endl; } how c++/cli handles? have found on internet. can tell me if im right this? class^ object2 = nullptr; if(object2 == nullptr){ cout << "the pointer not pointing object" << endl; } else { cout << "the pointer pointing object" << endl; } you should not use null in c++. opt nullptr . consider this: void some_function(some_class* test); void some_function(int test); int main() { some_function(null); } since humans interpret null pointer "type," programmer might expect first overload called. null defined integer 0 -- , compiler select s...

php - Count two rows with scopes and relationships (Laravel) -

so have 2 tables, 1 called members , 1 called memberships my goal count number of members have membership. i've set foreign keys , relationships working fine, point need counts. my scope (in member model) public function scopeactive($query) { return $query->where('membership_ended_at', null); } my relationship (in member model) public function membership() { return $this->belongsto('app\membership'); } this query works fine, , see how many members active() has membership_id of 6. $members_student = membership::find(6)->members()->active()->count(); i don't know if that's supposed work, does. now, issue have have regular student membership, , student abroad membership id of 14. i assumed maybe work, realized wrong $members_student = membership::find([6,14])->members()->active()->count(); i know can call 2 queries , add 2 together, i'm looking more elegant solution. required 1 query, , half que...

node.js - stubbing a Mongoose model -

i'm trying unit test function: exports.createtoken = function( user ){ var tokenexpirationdate = moment().add( config.tokenexpiration, 'minutes' ).valueof(), payload = { sub: user.id, exp: tokenexpirationdate }, token = jwt.sign( payload, config.tokensecret ), userinfo = user.tojson(); delete userinfo._id; delete userinfo.__v; delete userinfo.password; return { user: userinfo, token: token, expires: tokenexpirationdate }; }; since idea not have dependencies, have stub mongoose model function receives. since have little no experience in unit testing first thought in mocha: describe( '#createtoken', function() { it( 'should return jwt token', function( done ) { var fakeusermodel = { id: '558480eeffa8528c15492361', _id: '558480eeffa8528c15492361', __v: '0', tojson: function(){ return { email: 'foo@bar....

optimization - linq query crossjoin groupby optimize -

i have following database-model: http://i.stack.imgur.com/grtmd.png many many relations kunde_geraet/kunde_anwendung in explicit mapping-table additional information. i want optimize following linq-query: var qkga = (from es in db.eintrag_systeme.where(es => es.eintrag_id == id) kg in db.kunde_geraet.where(kg => es.geraet_id == kg.geraet_id) select new { kunde = kg.kunde, geraet = es.geraet, anwendung = es.anwendung }) .union( es in db.eintrag_systeme.where(es => es.eintrag_id == id) ka in db.kunde_anwendung.where(ka => es.anwendung_id == ka.anwendung_id) select new { kunde = ka.kunde, geraet = es.geraet, anwendung = es.anwendung }) .groupby(kga => kga.kunde, kga => new {geraet = kga.geraet, anwendung = kga.anwendung}); it better, when result ienumerable(kunde, ienumerable(geraet), ienumerable(anwendung)) without null-values uni...

box api - Does Box throw an "Upload" Webhook notification for files uploaded via email? -

i have application setup, created "uploaded" webhook notification. works fine when upload via drag-and-drop or via box sync, or other api enabled process, webhooks not working when files uploaded folder via email. expected behavior? this issue api box in process of fixing. should webhook notification when files uploaded via email.

can the size of the same image in MATLAB be shown differently? -

i entered image in matlab command a=('address of image') , created variable c c=imread('address of image') used same image in both cases. when used size command show different sizes both. how possible size(a) gave different size size(c). although used same image in both cases, both variables , c. i assume did wrote in question. code following: a = ('onion.png'); c = imread('onion.png'); this means variable a string represented chars , variable c image represented uint8-array. applying size -function on them gives different results because not same object @ all. can verified using class -function. sizeofa = size(a) >> [1 9] sizeofc = size(c) >> [135 198 3] classofa = class(a) >> char classofc = class(c) >> uint8 edit: can take string a load same image. because assigning filename variable, image not automatically read. prove creates same result, can this: d = imread(a); isequal(c,d) which ret...

html - How to target accordion li when hovering and targeting the first child? -

i want target strictly menu when hovering. menu change color , size without affecting li menu. how that? note suppose accordion menu. nav (sub) expands when hovering on menu. have spent great deal of time cannot target menu without messing sub. <nav id="menu_box"> <ul class="menu"> <li> <a href="#">menu</a> <ul> <li><a href="#">sub</a></li> <li><a href="#">sub</a></li> <li><a href="#">sub</a></li> </ul> </li> <li> <a href="#">menu</a> <ul> <li><a href="#">sub</a></li> <li><a href="#">sub</a></li> <li><a href="#">sub</a></li> </ul> </li> <li> <a href=...

Android Studio: How to build command-line Android activity with no view (NOT how to build *with* command line) -

i need build command-line tool can run in android shell. this question not how build using command-line tools, pretty find when search so/google question. what can do: write simple java jar runs app_process what want: tool uses android libraries (such packagemanager) runs command line (such 'adb shell') , exits - not app, doesn't have view , isn't following android life-cycle. so presumably either need figure out how build such tool either ide (such android studio) or else command-line using android libraries. someone gave (mostly) reasonably suggestion @ how 'pm' compiled, though can't figure out how without downloading entire android source , doing full build (and don't have time or hd space that). so suppose solution if telling me how compile 'pm' since repurpose needs.

android - Do something after startActivity finished -

this question has answer here: android- going previous activity different intent value 2 answers i need update adapter after activity has finished. idea how it? --edit -- i have activity have update data set after other activity finishes first 1 starts. have pass started activity? try overriding either onstop() or onpause() method , add code work. use onpause() if want update adapter when user minimizes app. use onstop() if want update adapter when user exits activity , destroyed.

android - How to create .aar file with library source code? -

i have library source files inside of it. need compile library .aar file, can't seem import module or project. there no .idea folder within library. how can create .aar file out of this? if library in project source, compiled each time run. under <your_lib> -> build -> outputs -> aar . there have .aar each build type have. i.e. debug , release

php - ZF2 domain specific object -

i have fetch entity object, based on given domain of application. based on entity, other services handle requests. is there way store static object or that? or should inject other services, should store way? thanks help -- edit -- now have following service factory return wantend entity. have problem, in case of default domain, no entity exists , application crashes because can't return null value in factory. how can solve that? namespace client\factory; use zend\servicemanager\factoryinterface; use zend\servicemanager\servicelocatorinterface; class clientfactory implements factoryinterface { /** * @param \zend\servicemanager\servicelocatorinterface $servicelocator * @return \client\entity\client */ public function createservice(servicelocatorinterface $servicelocator) { /* @var $clientservice \client\service\clientserviceinterface */ $clientservice = $servicelocator->get('client\service\client'); $baseurl ...

java - In a MapReduce , how to send arraylist as value from mapper to reducer -

this question has answer here: output list hadoop map reduce job using custom writable 1 answer how can pass arraylist value mapper reducer. my code has rules work , create new values(string) based on rules.i maintaining outputs(generated after rule execution) in list , need send output(mapper value) reducer , not have way so. can 1 please point me direction adding code package develop; import java.io.bufferedreader; import java.io.filereader; import java.io.ioexception; import java.net.uri; import java.net.urisyntaxexception; import java.util.arraylist; import java.util.linkedhashmap; import java.util.list; import java.util.map; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.path; import org.apache.hadoop.io.text; import org.apache.hadoop.mapreduce.job; import org.apache.hadoop.mapreduce.mapper; import org.apache.hadoop.mapreduce....

angularjs - How can I validate an ng-repeated dropdown category selector? -

i created nested category model. in order select category product, see dropdown main categories. when select one, new dropdown added right child categories 1 selected. repeats until reach last level. when happens $scope.product.category_id set. want invalidate whole set of fields when $scope.product.category_id null . i've been using angular-bootstrap-show-errors validation , tried mix ui-utils achieve one, using custom function: validate_category() . here's html used: <span ng-repeat="parent_id in category_dropdown_parents" show-errors="{ skipformgroupcheck: true }"> <select class="form-control" name="category_id" ng-init="selected_category[$index] = init_select($index);" ng-model="selected_category[$index]" ng-options="category.name category in (categories | filter : { parent_id: parent_id } : true ) track category.id " ng-change="select_catego...

github - Can git filter out certain lines before commit? -

Image
i have repo on github working out of , have comments on .py files starts " # todo: " keep personal note of things done. # todo: <code> i not want go in commit. i want github search files when commit them , not include lines start # todo: does git this? know version control perforce have feature. any thoughts? i want github search files when commit them , not include lines start # todo: github (server side) won't that. but can, in local repo, register content filter driver on git commit ( like sed '/^# todo:/ d' ). (image shown in " customizing git - git attributes ", " pro git book ") a ' clean ' filter can filter out lines (i won't discuss if should leave them or not), , filter apply automatically on git commit. remove all todo including ones left others, handle care: technically possible, have determine if needed/useful in case. update february 2016: git 2.8, if had defined gi...

ruby on rails - Rspec, can you stub a method that doesn't exist on an object (or mock an object that can take any method)? -

this might sound terribly basic question... let me explain context. i'm retrieving event stripe, purposes of this, works other things i've considered. the data need in stripe object way buried, i'd have event.data.object.date.lines.first.id . i'm not sure how mock/stub this... the way can think create fake model simulates stripe event object (in example me, keep in mind stripe events can't user created). , can mock fake model. way it? there way can use rspec stub whole shebang , event.data.object.date.lines.first.id wherever appears should retun 1 ? oh , also... if not, , turns out have create fake model... tips appreciated, because right i'm thinking "fake" model needs many layers of children, , totally not worth time investment. rspec provides no special mechanisms access elements under test, yes, need somehow stub id method , have return whatever wish (e.g. 1 ). to that, must have way access event object in test can stub it...

php - regex item count -

i have 2 distinct styles of item count text extract total number of items from. from style 1 need number 3, style 2 need 56 style 1: 3 item(s) style 2: items 1 45 of 56 total i trying match /(?<page>\d+,?\d+) total| item\(s\)/ it matches 56 in style 2 not 3 in style 1. this used preg_match in php ( can't change feeding values via webform ) i have other regex's i've tried, post if required. you need put total , item inside capturing or non-capturing group, first pattern become common 1 both total , item . (?<page>\d+(?:,\d+)*)(?: total| item\(s\)) demo

gem - why does rails generate scaffold fail? message is add pg to gemfile -

rails generate scaffold user name:string email:string fails message gem::loaderror the error message indicates gemfile not have gem pg does. says ensure version of pg @ minimum required activerecord. not sure minimum version of pg be. so created new app start. database=postgresql option. rails new app --database=postgresql and answered yes new things created. set gemfile corectly. , rails generate scaffold success .

printing - Truetype font not displaying on one client workstation with Citrix Xenapp -

i have truetype barcode font prints in ssrs report third party application runs through citrix xen app. on every single other client machine (8 different machines) prints properly, on single client computer running windows xp (not windows xp machine) font not display, instead defaults numbers. have verified font installed on client machine. preview on client not checked, emf viewer comes when attempt print.

jsf - How to call bean method when drag-drop the element using <p:pickList>? -

i using primefaces 3.3 library jsf based application. i using <p:picklist> handle drag , drop element source target , vide versa. i want call jsf bean method when element transferring(by drag-drop ) source target , vice versa , handle logical things there. i follow link primefaces showcase picklist implement functionality. version 5.2.7. in primefaces 5.2.7 can done <p:ajax event="transfer" /> , how can achieve using primafaces 3.3 . i try valuechangelistener attribute not working. there 1 attribute called ontransfer , clientside callback. this can achieve putting submit button. want achieve on drag , drop. how can ? thanks in advance. first, should consider update of primefaces version. updates not provided new features bug fixes, improvements (performance, stability) etc. currently cannot find documentation 3.3, try using p:remotecommand (its in 3.5 documentation, maybe available): use ontransfer="submittobean()...