Posts

Showing posts from September, 2010

javascript - socket.emit not passing messages -

Image
i have following js code `var express = require('express'); var app = express(); var http = require('http').server(app); var path = require("path"); var io = require('socket.io')(http); app.get('*', function (req, res){ res.sendfile(path.join(__dirname, '/public')); }); app.use('/home',express.static(path.join(__dirname,'/public'))); //app.use('/static', express.static(__dirname + 'index.html')); io.on('connection', function (socket) { socket.on('message', function (data) { socket.emit('news', { hello: 'world' }); }); socket.on('another-message', function (data) { socket.emit('not-news', { hello: 'world' }); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); });` i have html code <html> <h1>working</h1> <script src="/socket.io/socket.io.js"&

android - Picasso placeholder image animation -

i trying load image imageview using picasso . code given below: picasso.with(this) .load(imageurl) .placeholder(drawable1) .error(drawable1) .into(imageview) now here while picasso waiting download complete, imageview goes blank. prevent want fade out current image drawable , load image present in url. there way this? i think picass has done you, placehoder drawable used shown when image being loaded, , error drawable shown when image load failed. if want thing can use target following: new target() { @override public void onbitmaploaded(bitmap bitmap, picasso.loadedfrom from) { imageview2.setimagebitmap(bitmap); } @override public void onbitmapfailed(drawable errordrawable) { } @override public void onprepareload(drawable placeholderdrawable) { } }

javascript - How to change the image thumbnail dynamically by using Facebook web SDK -

facebook development newbie. i have added meta tags html file want share facebook. like: <meta property="og:type" content="article"/> <meta property="og:title" content="title"/> <meta property="og:description" content="description"/> <meta property="fb:app_id" content="23232323323232"/> <meta property="og:image" content="https://fajfladjfaljafl.jpg/> i want make image thumbnail in facebook profile different different people. example, people can small test here share result facebook, image thumbnail should test result of person. how can this. now thinking generate new webpage within specific meta property person every time. this's dump! can change <meta property="og:image" content="https://fajfladjfaljafl.jpg/> automatically when people share facebook? or other ideas? thank much!! hi everyone: i doing via feed di

c++14 - Counterpart to std::enable_if_t -

std::enable_if_t gets type if value true. want thing gets type if expression well-formed. if type want void , can decltype((void)(expr)) . should if want other void ? want succinct , elegant solution. you can use this: template<typename t> struct well_formed : std::true_type{}; and combine enable_if_t

c# - Some data is missing in the Export to Excel using DataTable and Linq -

i exporting 3 worked sheet in single xl file, missing user data in second datatable ( education details sheet) , third datatable ( employeement details sheet). the education details sheet users not there, employeement details sheet users showing. user email id's there 3 database tables. datase ds = new dataset(); datatable dt = new datatable("registration details"); datatable dt1 = new datatable("education details"); datatable dt2 = new datatable("employeement details"); dt = bl.get_registrationdetailsbydate(bo); gv_regdetails.datasource = dt; gv_regdetails.databind(); dt1 = bl.get_registrationdetailsbydate1(bo); dt2 = bl.get_registrationdetailsbydate2(bo); datatable filterededucation = dt1.asenumerable() .where(x => dt.asenumerable() .any(z => z.field<string>("email").trim() == x.field<string>("email").trim())) .copytodatatable()

Firebase: Priority set to null on server but not on client when setting grandchild -

to reproduce, check out http://jsfiddle.net/3ar7n/16/ . first click "set child , grandchild," sets child priority , sets grandchild within it. click "show local values" , you'll see child still seems have priority of 123. click many times - priority comes 123. once you're satisfied local priority 123, refresh whole page. you'll dismayed see priority null. i can believe concurrency issue, effects of set happening in different orders. expected behavior setting child clear priority of parent? thanks easy test case! indeed bug. client , server handling case differently, why you're seeing inconsistent behavior. note occurs if "setwithpriority" primitive value, , write deeper in tree (which deletes primitive value). update: has been fixed.

Spring Integration with Oracle AQ -

i'm trying learn spring integration , create application this: from oracle send messages (on oracle queue), message intercepted java application (build spring integration) , application send email based on message received. message contain to: - cc: , text send. to make kind of communication i've decided use jms (i think in oracle made oracle aq). in database i've created queue , i'm trying create simple applicationcontext.xml start handshake. looking on net i've found few articles (spring integration + oracle aq) , i'm getting error. main error this: java.lang.classnotfoundexception: oracle.jms.aqjmsfactory right applicationcontext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:context="http://www.springframework.org/schema/context" xmlns:orcl="ht

pdo - how to set charset for php PDOException itself -

i know how set charset database connection. but...how configure charset pdo . ex. when php running on windows(chinese) , if new pdo(...) failed, return message encoded gbk. if want error message encoded utf-8 ,how ? thanks. i got exception messages encoded in utf8 changing postgresql.conf directive follows (example french language) : lc_messages = 'french_france.utf-8'

php and mysql error for registration form -

when press register on php form im getting error: warning: mysql_num_rows() expects parameter 1 resource, boolean given in /home/changj/public_html/register.php on line 26 no database selected below register.php script line 26 unsure how fix error if(mysql_num_rows($sql)> 0 ) { any ideas thanks. i guess $sql string. try this, $result = mysql_query($sql); if(mysql_num_rows($result)> 0 ) { .... } but mysql_query() deprecated of php 5.5.0. alternative use, mysqli_query() or pdo::query()

plsql - I need to create a trigger to automatically increment the no_of_books in member table and book table -

upon issue, value of no_of_books must decremented in book table , incremented in member table create or replace trigger trans_s_t3 after insert on trans_s select member_s m1, book_s b1 each row begin update book_s , member_s set no_of_books=:old.no_of_books - :new.no_of_books; book_s=:new.book_no; end; do create or replace trigger trans_s_t3 after insert on trans_s select member_s m1, book_s b1 each row begin update book_s set no_of_books=:old.no_of_books - :new.no_of_books; book_s=:new.book_no; update member_s set no_of_books=:old.no_of_books - :new.no_of_books; book_s=:new.book_no; end;

xpath - How can I use several xml filter for one xml message -

i have parse xml document (received rabbitmq message) want more info according filters. here xml part of logstash if ([message] =~ /^</) { xml { ... xpath => [ "/apios_mom_event/ident/no_emiarte/text()", "no_emiarte", "name(/apios_mom_event/data/apios_export/*[not(self::metadata)])","message_type", "name(/apios_mom_event/data/*)","recommendations", "/apios_mom_event/data/apios_export/metadata/code_offre_web/text()","offre_web" ] target => "xml" } alter { condrewrite => [ "message_type","","edito" ] condrewriteother => [ "recommendations","recommendations","message_type","recommendations" ] condrewriteother => [ "recommendations","schedule","message_type","schedule" ]

jquery - static variable in Javascript -

i want create static variable in java script. requirement "i created global variable var = 'abc'. changing variable value when doing interaction dom. if refresh page want latest value shown. possible?" here code. <!doctype html> <html> <head> <title>static variable</title> </head> <body> <button onclick = "staticdemo();">click me</button> <script> var = "abc"; alert(a); function staticdemo(){ = "def"; } </script> </body> </html> you can use local storage retrieve data, after refresh. check out http://www.w3schools.com/html/html5_webstorage.asp

Weird PHP magic getter on an array -

i have weird issues magic getter/isset. have myobject defines magic getter/isset: private $_data = array(); public function __get($name) { if (array_key_exists($name, $this->_data)) return $this->_data[$name]; throw new exception($name.': property doesn\'t exist.'); } public function __isset($name) { return isset($this->_data[$name]); } if call: isset($myobject->notexisting); empty($myobject->notexisting); i have correct behaviour (__isset() called), while if call: isset($myobject->notexisting['ok'])); empty($myobject->notexisting['ok'])); __isset() not called while __get() is. this seems weird me php should first check $myobject->notexisting existence before trying it, shouldn't ? according docs : __isset() triggered calling isset() or empty() on inaccessible properties. in isset($myobject->notexisting); isset applies notexisting property of $myobject . in isset($myobject-&g

java - How to Use HikariCP with MySql JDBC -

i'm trying use hikaricp jdbc connection pool in java application. i'm not using frameworks spring or hibernate in application. i'm able connect mysql db using simple jdbc driver when try using hiraki code not working. can't understand i'm going wrong after initializing data source . initial jdbc working code.. public class connect extends errorcat{ protected connection connection = null; //database user name , password private string name = "root"; private string pass = ""; //database url , jdbc driver private string url = "jdbc:mysql://127.0.0.1:3306/fls"; private string driver = "com.mysql.jdbc.driver"; protected /*static connection*/void getconnection(){ if (connection == null){ system.out.println("registering driver...."); try { //driver registration class.forname(driver).newinstance(); sy

c++ - Memory leak when using std::list -

how remove memory leak std::list ? this example code : #define _crtdbg_map_alloc #include <stdlib.h> #include <crtdbg.h> #include <iostream> #include <list> using namespace std; void main() { list<int> a; a.clear(); _crtdumpmemoryleaks(); } when try run it, shows memory leak. so, how remove it? there no memory leak. report telling memory has not yet been deallocated, true. deallocated @ end of current scope - after _crtdumpmemoryleaks() has run. alter code follows; provide more accurate answer: void main() { { list<int> a; a.clear(); } _crtdumpmemoryleaks(); } note movement of a container own scope.

scope - Surprised that global variable has undefined value in JavaScript -

today, got surprised when saw global variable has undefined value in case. example: var value = 10; function test() { //a console.log(value); var value = 20; //b console.log(value); } test(); gives output as undefined 20 here, why javascript engine considering global value undefined . know javascript interpreted language. how able consider variables in function? is pitfall javascript engine? this phenomenon known as: javascript variable hoisting . at no point accessing global variable in function; you're ever accessing local value variable. your code equivalent following: var value = 10; function test() { var value; console.log(value); value = 20; console.log(value); } test(); still surprised you're getting undefined ? explanation: this every javascript programmer bumps sooner or later. put, whatever variables declare hoisted top of local closure. so, though declared variable after first console.

sockets - Python, wait until network interface is up? -

i have python script opens port , listens on raspberry. added /etc/rc.local , working properly. problem socket not created when process being executed. s = socket.socket() s.bind((host_ip,port)) #e.g. host_ip='192.168.1.32' , port=12345 s.listen(5) while true: c,addr = s.accept() c.send('ack') c.close() the above code not executed because there no 'eth0' connection available. should do? should loop scan socket status until connection being available? there other more sophisticated solution? like this: import urllib2,thread time import sleep import netifaces class _check: def __init__(self): self.uri="http://www.google.com" self.period = 5 self.status = false self.ifaces() def check(self): try: answ = urllib2.urlopen(self.uri) if answ: self.status = true #now can run awesome code ! print "o

python - Connecting to SFTP server via Windows' Command Prompt -

this question has answer here: secure ftp using windows batch script 3 answers i'm wondering if there's way connect sftp server windows' command prompt, executing batch file. need install additional software? software? the purpose pretty basic file operations (upload, delete, rename) on remote sftp server executing batch file. and way, have heard python 's fabric library, , wonder whether it's better solution batch script mentioned basic file operations? thanks lot! the built in ftp command doesn't have facility security. can use winscp, open source free sftp client , ftp client windows.

parse.com - Connecting android app with Mailchimp -

i have android app want connect mailchimp. when new user signs in app want user email import automatic app list in mailchimp. anny suggestens? thank you! if helps have parse account connected android app yes possible. donwload code https://github.com/mailchimp/chimpbot , update url current mailchimp url.

c# - UWP windows 10 app memory increasing on scroll listview and add item at the bottom of listview -

i have uwp windows 10 app , noticed memory using app increase when new items add @ end of listview , memory increase around 4mb each item . i found increasing memory because of item template set them. used usercontrol item template contain button , textblock , 1 image. how can remove item not on screen visible memory ? the user control similar : <usercontrol x:class="xamlpulltorefresh.myusercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:xamlpulltorefresh" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" d:designheight="300" d:designwidth="400"> <grid> <grid.rowdefinitions> <rowdefinition />

python - Is there a way to handle only year in a datetime object? -

coming question here , i'm wondering if there's way in python handle year in datetime object , know year important , else has ignored? here's example of need do: a = date(2014, 1, 1) a.ignore_days = true a.ignore_months = true b = date(2014, 12, 1) if a.ignore_days , a.ignore_months , (a.year==b.year): print("ok") and later on: a = date(2014, 12, 1) a.ignore_days = true b = date(2014, 12, 8) if a.ignore_days , a.ignore_months , (a.year==b.year): print("ok") else: print("different") if a.ignore_days , (a.year==b.year) , (a.months=b.months): print("ok") else: print("different") if str(a)==str(b): print("ok") else: print("different") should output: ok ok different i guess want compare years. in case can extract year form datetime object , compare them. x = date1.year y = date2.year if x == y: do_my_stuff()

unit testing - Mock Beans from Spring Context -

i want create tests working spring context, mocked repository beans. i'm using spring boot 1.3.2.build-snapshot + junit + mockito. here test config class: @componentscan(basepackages = "myapp", excludefilters = @componentscan.filter(type = filtertype.assignable_type, value = { offerrepository.class } ) ) @configuration public class testedge2edgeconfiguration { @bean public offerrepository offerrepository() { return mock(offerrepository.class); } } purpose of configuration exclude offerrepository spring context , mock it, thank i'll able write tests using spring context mocked database repository. here test class: @runwith(springjunit4classrunner.class) @springapplicationconfiguration(classes = {testedge2edgeconfiguration.class}) @webappconfiguration public class offeractionscontrollertest { @autowired private offerrepository offerrepository; @autowired private offeractionscontroller o

php - swiftmailer and Yii2 not working 1 out of 10 time -

i have background process sending email me when specific event occur. it's working of time (9 out of 10), sometime following error message : php warning 'yii\base\errorexception' message 'fwrite(): ssl: established connection aborted software in host machine.' in e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\streambuffer.php:232 stack trace: #0 [internal function]: yii\base\errorhandler->handleerror(2, 'fwrite(): ssl: ...', 'e:\programdata\...', 232, array) #1 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\streambuffer.php(232): fwrite(resource id #481, 'mail from:<mte@...') #2 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\bytestream\abstractfilterableinputstream.php(171): swift_transport_streambuffer->_commit('mail from:<mte@...') #3 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib

javascript - How to fix position of div tags? -

Image
i creating interactive periodic table project. this looks , good, change resolution, right side elements scatter on page , becomes mess. here snippet:- function lanthanoids() { var elements1 = document.getelementsbyclassname('lanthanoids'); var i, marginleft = -70; (i = 0; < elements1.length; i++) { marginleft += parseint(window.getcomputedstyle(elements1[i]).marginleft, 10) + 70; elements1[i].style.marginleft = marginleft + 'px'; } } function actinoids() { var elements2 = document.getelementsbyclassname('actinoids'); var i, marginleft = -70; (i = 0; < elements2.length; i++) { marginleft += parseint(window.getcomputedstyle(elements2[i]).marginleft, 10) + 70; elements2[i].style.marginleft = marginleft + 'px'; } } function typeshover() { $('.info').hover( function() { getid = this.id; originalcolor = document.getelementbyid(getid).style.backgroundcolor;

Restart dead accumulo tablet server -

i use single-instance accumulo database. worked fine until tried ingest multiple data (following this tutorial), tablet sever died. i tried restart (using bin/start-all or bin/start-here ) did not work. restarted whole server , seams, bin/start-all starts tablet server first: warn : using zookeeper /root/installs/zookeeper-3.4.6/zookeeper-3.4.6. use version 3.3.0 or greater avoid zookeeper deadlock bug. starting monitor on localhost warn : max open files on localhost 1024, recommend 32768 starting tablet servers .... done starting tablet server on 46.101.229.80 warn : max open files on 46.101.229.80 1024, recommend 32768 openjdk client vm warning: have loaded library /root/installs/hadoop-2.6.0/lib/native/libhadoop.so.1.0.0 might have disabled stack guard. vm try fix stack guard now. it's highly recommended fix library 'execstack -c <libfile>', or link '-z noexecstack'. 2016-01-27 04:44:18,778 [util.nativecodeloader] warn : unable load native-hadoo

c - Count how many integer values separated by spaces are in a given string -

i want make function that, given character string containing (unsigned) integer values separated spaces, gives me number of values in string: int conta_coords(char *args) { char *pal; int k=0; pal = strtok (args," "); while (pal != null) { k++; pal =strtok (null," "); } return k; } this function won't give me right number. can me? in way won't give correct number? here's code embedded sscce ( short, self-contained, correct example ). #include <string.h> #include <stdio.h> extern int conta_coords(char *str); int conta_coords(char *args) { char *pal; int k=0; pal = strtok (args," "); while (pal != null) { k++; pal =strtok (null," "); } return k; } int main(void) { char data[] = "1 23 456 7890 12345"; printf("data: %s\n", data); printf("number: %d\n", conta_coords(data)); printf("data split: %s\n", da

uiwebview - How to display HTML string with MonoTouch Dialog? -

i need way display string html tags within monotouch.dialog element. if understand right build in htmlelement load external data display. so asked google , found thread here display-uiwebview-in-custom-monotouch-dialog-element seems solution found other search results found ... maybe knows if solution still available or if not know library convert html tags string nice in standard elements ...? thanks andre you can create uiwebview , add text there, , use uiviewelement show that. but little on heavy side. perhaps should consider using nsattributedstring if want add styling project.

xml - Create a list using a for in XQuery 1.0 -

i create list of element using in example: for $ingr in distinct-values(//ingredient/name) let $res := ( $res2 in //restaurant return if( $ingr2 in $res2/dish/ingredient/name satisfies $ingr2 eq $ingr ) then( $res2 ) else() ) return $ingr, $res what want obtain is: for each ingredient return list of restaurants use it . don't understand problem? here can see example: http://www.xpathtester.com/xquery/0c8f9699df404020afd07ff9f9517a46 it keep saying: error - variable $res has not been declared your expression read (for ... let ... return $ingr), ($res) . means $res @ end considered different expression separate previous flwor expression, hence undeclared variable error. you can use parentheses alter unwanted grouping : for $ingr in distinct-values(//ingredient/name) let $res := ( $res2 in //restaurant return if( $ingr2 in $res2/dish/ingredient/name satisfies $ingr2 eq $ingr ) then( $res2 ) else() ) return ($ingr, $res) xpathtest

internet explorer 10 - JavaScript browser detection in IE10 -

i'm updating website design because doesn't work in ie10. i using combination of conditional comments , javascript handle ie version detection, since ie10 has dropped former , haven't found reason ignoring latter, i'm seeking here. i've been reading thread: detect ie version (prior v9) in javascript but knowledge of javascript isn't far off zilch, i'm not sure whether should looking modify code or scrap , adopt , change code mentioned in url (and if so, how should that). the code i'm using: <link rel="stylesheet" type="text/css" href="barebones.css"> <!--[if lte ie 8]> <link rel="stylesheet" type="text/css" href="ie.css"> <![endif]--> <!--[if gt ie 8]> <link rel="stylesheet" type="text/css" href="default.css"> <![endif]--> <script type="text/javascript"> //<![cdata[

loop through simple json object -

how loop through json object each item value? know easy need undestand why there 2 brackets ([]) in first , end of json object. [// i'm talking [ { "id": 2, "title": "xxxxxxxxx", "author": "mike123", "postdate": "march 12, 2013 @ 6:46 pm", "postdatecreation": "2013-03-12", "posteditdate": null, "postcontent": "eeeeee", "userid": 34 } ] ]// , if remove them json still remain valid. you can loop through json object using $.each loop. here fiddle: http://jsfiddle.net/ay2ub/ here results array of array of object. i've passed object accessing index results[0] give array results[0][0] give object code below: var results=[ [ { "id": 2, "title": "xxxxx

c# - Not to show keyboard when focusing a searchbox -

i developing app (in xamarin.forms) used external barcode scanner, i don't need show tactile keyboard each time put focus in entry/searchbox/etc. how can this? thanks guys. assuming never want keyboard never show whatsoever on entry , can set keyboard property null in entry's constructor. var scannerentry = new entry { keyboard = null, placeholder = "scan item" }; because xamarin.forms api not expose keyboard property on searchbar class, can write custom renderer . ios implementation can use resignfirstresponder in onelementchanged override prevent keyboard ever showing: [assembly: exportrenderer(typeof(scannersearchbar), typeof(scannersearchbardrenderer))] namespace hidekeyboard.ios { public class scannersearchbarrenderer : searchbarrenderer { protected override void onelementchanged(elementchangedeventargs<xamarin.forms.searchbar> e) { base.onelementchanged(e); if (control !=

Facebook page's posts rss feed? -

does know how fetch facebook page's rss-feed nowadays (27 january 2016)? i know answer: facebook page's posts feed doesn't work anymore solution. i know fbrss.com works it's not realtime, it's been 3 hours 1 of facebook page , follow has posted , on fbrss.com rss feed link doesn't appear yet. any tool/online webservice or whatever can use (apart implementing myself webservice on webserver)? you implement self hosted version of rss bridge ! use wallflux use profesionnal version of inoreader wich alows follow 60 facebook pages in real time

batch file - Escape an asterisk in DOS -

i rename file in dos. result, dot , asterisk should appended file name. example: rename text.log text.log.* however returns: text.log.. i have tried escape * follows: rename text.log text.log.\* but no way! guys know how can rename file appending .* string text.log using cmd shell? thanks! you can't - * reserved character , cannot used in filename. https://en.wikipedia.org/wiki/filename#reserved_characters_and_words

php - How to include Composer dependencies in a Git repo -

Image
when creating sites using framework silverstripe want use helper modules gridfieldextensions , lumberjack . i therefore use composer require add dependencies. however when follow regular development work flow , use git add -a add module repo rather code being added repo reference it. this causes problems when try clone site elsewhere (using jenkins or developer). git clone or git pull leaves empty directory. i solve deleting .git dir of module , adding files. is there better way this? using git submodule option? somewhere found .gitignor e file ignores , have tell include custom modules project. it's like: # ignore everything... /* # ...but !/.htaccess !/.gitignore !/composer.json !/composer.lock !/capfile !/gemfile !/favicon.ico !/touch-icon-* !/mysite !/some-module #...other modules # theme stuff !/themes/ **/.sass-cache **/node_modules !**/node_modules/_manifest_exclude #no assets in general, /assets/.htaccess !/assets /assets/* !assets

Regex in a bash scipt -

i've got following text file contains: 12.3-456, test test test test if line contains xx.x-xxx, want print line out. (x's numbers) i think have correct regex , have tested here: http://regexr.com/3clu3 i have used in bash script line containing text not printed out. have messed up? #!/bin/bash while ifs='' read -r line || [[ -n "$line" ]]; if [[ $line =~ /\d\d.\d-\d\d\d,/g ]]; echo $line fi done < input.txt you need use [0-9] instead of \d in bash regex. no regex delimiters necessary, , global flag not necessary either. also, can contract bit using limiting quantifiers (like {3} match 3 occurrences of pattern next it). besides, dot matches character in regex, need escape if want match literal dot symbol. use regex="[0-9]{2}\.[0-9]-[0-9]{3}," if [[ $line =~ $regex ]] ...

c# - Rows are coming undefined when calling function in postgreysql -

i wrote functon when calling function select * fngettalukbydistrict(); iam getting rows field defined undefined. function create or replace function sde.fngettalukbydistrict(in districtname text) returns table(districtname text) $body$ select distinct talukname village districtname=$1 order talukname $body$ language sql volatile cost 100 rows 1000; alter function sde.fngettalukbydistrict(text) owner postgres; public datatable getalltaluksbydistrict(string districtname) { return helper.executeselectcommand("select * fngettalukbydistrict('" + districtname + "');", commandtype.text); public datatable getalltaluksbydistrict(string districtname) { return agriculturedetailsdal.getalltaluksbydistrict(districtname); }

Scala Unit Testing - Mocking an implicitly wrapped function -

i have question concerning unit tests i'm trying achieve using mockito in scala. i've looked scalamock sounds feature not provided well. suppose maybe i'm looking narrow way solution , there might different perspective or approach im doing opinions welcomed. basically, want mock function available object using implicit conversion , , don't have control change how done. since i'm user library. concrete example similar following scenario rdd: rdd[t] = //existing rdd sqlcontext: sqlcontext = //existing sqlcontext import sqlcontext.implicits._ rdd.todf() /*todf() doesn't exist @ rdd implicitly added when importing sqlcontext.implicits._*/ now in testing, i'm mocking rdd , sqlcontext , want mock todf() function. can't mock function todf() since doesn't exist on rdd level. if simple trick, importing mocked sqlcontext.implicit._ error function not publicaly available object can't mocked. tried mock code implicitly executed until todf(

python - GitPython: check if git is available -

gitpython depends on having command line version of git installed (otherwise, issue in question: oserror: [errno 2] no such file or directory on gitpython ). is there way gitpython api check if executable found, or, need wrap gitpython calls in exception handling account possibility? i don't particularly recommend this, did @ least once: try 1 git command while catching oserror case see if can run git (and running it, capture git version number well, in case). if git fails run, complain , disable further invocations of git (or exit or whatever). if not, assume further invocations continue work.

jquery validation with addMethod fails when it shouldn't -

i have idea may stupid, i've been stuck on hours. i have simple form, jquery validation using ajax determine whether email address in database. works great. when email address found, reports duplicate, , when not, silent. but when enter email know new, , fill out rest of form, , press submit, prevents form submission , sets focus on email field. here's jquery: $(document).ready(function(){ var email; var name; var passwd; var passwd_repeat; //form validation rules $("#regform1").validate({ rules: { name: { required: true, minlength: 3, }, passwd: { required: true, minlength: 8, }, passwd_repeat: { required: true, equalto: passwd, minlength: 8 } }, messages: { name: "please enter name.", passw