Posts

Showing posts from July, 2010

python 2.7 - How to stop recursive function before index out of range? -

def isincreasing(ls): if not ls: print "list empty or short" return return (false if ls[0] > ls[1] else isincreasing(ls[1:])) i have made check if list sorted. how can make function stop when there no more check? im getting error "list index out of range". just add: checking if 2 elements in list checking if 1 element or no element in list code: def isincreasing(ls): if len(ls) < 2: print "list empty or short" return if len(ls) == 2: return ls[0] < ls[1] return (false if ls[0] > ls[1] else isincreasing(ls[1:])) print "{}", isincreasing({}) print "[]", isincreasing([]) print [1,2,3], isincreasing([1,2,3]) print [4,6,8], isincreasing([4,6,8]) print [2,1,2,3], isincreasing([2,1,2,3]) print [1,2,3,2], isincreasing([1,2,3,2]) print [3,2,1], isincreasing([3,2,1]) output: {} list empty or short none [] list empty or short none [1, 2, 3] true [4, 6, 8] ...

jquery - Selectbox OnChange copy this text to div -

how can change div text selectbox option selected text... i have selectbox more 100 values scenario: select option selectbox, same option value(text) has replaced relevant div text has ccy class <div class="ccy">blablabla</div> class... eg: have selectbox eur, usd, jpy, inr etc... if select eur selectbox, relevant divs has class ccy <div class='ccy'>currency 1</div><div class='ccy'>currency 2</div> should changed <div class='ccy'>eur</div><div class='ccy'>eur</div> , on... fiddle html <select id="currencty-selectbox"> <option value="1">eur</option> <option value="2">usd</option> <option value="3">jpy</option> <option value="4">cad</option> <option value="5">mxn</option> <option value="6">czk<...

PHP: how to get variables from a JSON(sent from a Swift iOS app) and respond with a JSON -

i developing ios app swift should fetch data mysql database according user's location. don't know php , couldn't find resource explains how receive data app. i have php code: <?php // create connection $con=mysqli_connect("localhost","*******","*******","*******"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } // sql statement selects table 'locations' $sql = "select * *******"; // check if there results if ($result = mysqli_query($con, $sql)) { // if so, create results array , temporary 1 // hold data $resultarray = array(); $temparray = array(); // loop through each row in result set while($row = $result->fetch_object()) { // add each row our results array $temparray = $row; array_push($resultarray, $temparray); } // finally, encode array json , output results ...

node.js - Passport.js / Express.js Creating New Session on Every Network Request -

i have working login function authenticates , saves. however, express never remembers old session, creates new 1 every network request. evidently, passport exceedingly sensitive order express middleware initialized. (example: https://www.airpair.com/express/posts/expressjs-and-passportjs-sessions-deep-dive ). checked config against number of examples , rearranged if help, hasn't moved bug. either isn't issue or haven't found config holy grail yet. here's current config: express config app.engine('html', require('ejs').renderfile); app.set('view engine', 'html'); app.use(express.static(path.join(config.root, '/views'))); app.set('views', config.root + '/views'); var sessionopts = { saveuninitialized: true, resave: false, store: new redisstore({ host: 'localhost', port: 6379 }), secret: 'keyboard', cookie: { httponly: true, maxage: 1000...

ruby on rails - Changing position of options via the admin panel -

i have below method rearranging position of radio , checkbox images app. def change_position if !self.position.blank? existing_model=part.where("ancestry = #{self.ancestry} , position = #{self.position}") if !existing_model[0].blank? if !self.changes['position'].blank? existing_model[0].update_columns(position: self.changes['position'][0]) end end end end but when trying change position of parent option, getting below error in rails admin panel. sqlite3::sqlexception: near "and": syntax error: select "parts".* "parts" (ancestry = , position = 2) order created_at asc why not able save position parent options position here? any here?

javascript - How to stop iteration on error | Node.js and MongoDB -

got little problem here that's taking me long solve. might idiot because feel simple problem cant wrap head around it. here's code: get_online = function (err, result) { if (err) { return next(err); } streamers_size = result.length; result.map( function (entry) { curl.get .to('https://api.twitch.tv/kraken/streams/' + entry.uname) .then(update_streamers); } ); }, update_streamers = function (err, result) { var clean; if (err) { return next(err); } if (result.stream) { db.collection('streamers').update({ _id: result.stream.channel._id }, { $set: { stream_preview: result.stream.preview.large, viewers: result.stream.viewers } }, send_response); } ...

Java: Reading part of a text file -

i'm trying print out sections of text file. right text file consists of jack <id 123.456> doug <id 231.345> this have far in terms of code: bufferedreader reader = new bufferedreader(new filereader("file.txt")); string readbuff = reader.readline(); string tempstring = ""; while (readbuff != null) { if (tempstring.equals("<id ") && !readbuff.equals(">")) { tempstring = readbuff; system.out.println(tempstring); } readbuff = reader.readline(); } reader.close(); i hoping print out id section (i.e. "123.456" , "231.345") of each line right doesn't print anything. appreciated. try code: fileinputstream fis = new fileinputstream(new file("file.txt")); bufferedreader br = new bufferedreader(new inputstreamreader(fis)); string line = null; while ((line = br.readline()) != null) { str...

Editing a master template in domino -

we developing application consumes domino data service. hence, changes being made several views enable data service. application inheriting master template, properties changed reverting original values periodically. is making application master template valid option? can edit master template inheriting? you have 2 options: remove "inherit design master template" , make changes on db. modify master template. first option way of working transforme changed db new master template see . if select second option have "application/refresh design" after each modification made in template in order test them in db.

javascript - How to set Autoclick on all the buttons of a page? -

i using jquery , ajax performing action, need after loading complete page, code click on every button automatically. i used following javascript code click buttons in end of page. not working. <script type='text/javascript'> document.getelementbyclassname('sub').click(); </script> structure of page code [jquery] [php] [html] [javascript] i set buttons type "button", when set type="submit" the autoclick code work on first button, "button" type not working of them. if click manually on buttons working properly. please give suggestion. thank you. youre using wrong function. elements plural in method. document.getelementsbyclassname('sub'); additionally, calling click on nodelist not work. need loop through , call event on each index. also, you're using jquery. ensure call happens after dom ready, wrap js $().ready(). last, use tools you've provided yourself, in case jqu...

c# program to remove duplicate elements from a given integer using linq? -

it should using linq only.for example if integer 123444 taken,then should print 1234. unable single integer.i can list of integers. you can converting int string , getting digits in array. applying distinct remove duplicates array. once have array of unique digit can make string using join. parsing string int give number duplicate digits in it. int j = int.parse(string.join("",i.tostring().toarray().distinct()));

javascript - Protractor: Return Repeater Count from Prototype -

i have behavior can't understand: cart.prototype.getcouponscount = function() { // loop through rows of coupons available in cart ele.cartcouponslist.count().then(function(count) { console.log("amount of items in cart:", count); return count; }); }; when called this: var cart = require("../../../../lib/cartlib"); var cart = new cart(); expect(cart.getcouponscount()).tobe(2); returns undefined , in console can see correct coupon amount being printed. it's not returning count back. similarly have working gettext() method, therefore why can't understand why count() method behave differently. working method: cart.prototype.getevent = function(row) { var carthistory = new cart(); var parent = carthistory.getcartcoupon(row); var child = parent.element(by.binding("selection.event.name")) .gettext().then(function(e) { console.log(e); return e; }); ...

Svn hook script email body html formatting -

i have below script sends email whenever developer commits svn repository. mail body includes name of file plus changes developer has added , removed. i want additions blue , removals red, color formatting not working. folks can please advise has been long time , stuck solution #!/usr/bin/ruby -w # subversion post-commit hook. edit configurable stuff below, , # copy repository's hooks/ directory "post-commit". don't # forget "chmod a+x post-commit". # ------------------------------------------------------------------------ # *will* need change these. address="foo@some_domain.com" sendmail="/usr/sbin/sendmail" svnlook="/usr/bin/svnlook" # ------------------------------------------------------------------------ require 'cgi' # subversion's commit-email.pl suggests svnlook might create files. dir.chdir("/tmp") # revision in repository? repo = argv.shift() rev = argv.shift() # overview infor...

windows - C# IMEI detection of any device connected via USB -

i working on c# desktop application detect imei of device connected via usb. got working samsung device after installing driver , running @ commands. there generic way devices. any device supports @ command access using c# serial port class . once hold of device through serial port can send @ commands , response of commands. how can send @ command imei number , number response of @ command through uniform interface type of devices support @ commands , access through com port. i have found following example on codeproject imei number , made little modification. private string getimeinumber(string portname) //serial { string key = ""; serialport serialport = new serialport(); serialport.portname = portname; serialport.baudrate = 9600; try { if (!(serialport.isopen)) serialport.open(); serialport.write("at\r\n"); thread.sleep(3000); key = serialport.readexisting(); serialport....

Running a URL in Advanced Rest Client from a java program -

i have url of api working fine if run in advanced rest client of chrome directly. want url trigger own rest api code should run in advanced rest client , stores result in variable. how can this? use apache httpclient library https://hc.apache.org/ or other third party open source libraries easy coding. if using apache httpclient lib, please google sample code. tiny example here. httpclient client = new defaulthttpclient(); httpget request = new httpget('http://site/myresturl'); httpresponse response = client.execute(request); bufferedreader rd = new bufferedreader (new inputstreamreader(response.getentity().getcontent())); string line = ''; while ((line = rd.readline()) != null) { system.out.println(line); } return (rd); if there restriction use third party jars, can in plain java too. httpurlconnection conn = null; try { url url = new url("http://site/myresturl"); httpurlconnection conn = (httpurlconnectio...

nullpointerexception - Application crash during language integration android -

hello friends i'm integrating language integration in application below code main.java public class activitysetting extends activity { locale mylocale; radiobutton mradiobuttonmile; radiobutton mradiobuttonkilomile; spinner mspinnerlanguage; string selecteditem=""; bathroomadapter mlanadapter; string mstringgetcurrency; string ll; string[] mstringsarraylanguage = new string[] { "english", "german", "russian", "spanish" }; public static final string my_pref = "mypreferences"; adview madview; linearlayout layout; boolean firstadreceived = true; @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.settings); actionbar actionbar = getactionbar(); actionbar.set...

python - PyQt5 button to run function and update LCD -

i getting started creating gui's in pyqt5 python 3. @ click of button want run "randomint" function , display returned integer qlcdnumber named "lcd". here's code: import sys pyqt5.qtwidgets import qapplication, qwidget, qvboxlayout, qpushbutton, qlcdnumber random import randint class window(qwidget): def __init__(self): super().__init__() self.initui() def initui(self): lcd = qlcdnumber(self) button = qpushbutton('generate', self) button.resize(button.sizehint()) layout = qvboxlayout() layout.addwidget(lcd) layout.addwidget(button) self.setlayout(layout) button.clicked.connect(lcd.display(self.randomint())) self.setgeometry(300, 500, 250, 150) self.setwindowtitle('rand integer') self.show() def randomint(self): random = randint(2, 99) return random if __name__ == '__main__': app = q...

asp.net mvc - Kestrel on AspNet vNext doesnt serve index page under / -

i need able serve 'index.html', under default url / , using kestrel web server. right i'm able access static files full path i.e /index.html again works on visualstudio, context osx kestrel this startup.cs public void configureservices(di.iservicecollection services) { services.addmvc(); } public void configure(iapplicationbuilder app) { app.usestaticfiles(); app.usemvc(); } the solution have far, redirect inside homecontroller. plain ugly, i'm trying serve static html file, don't want handled application, if possible served directly kestrel. you need enable defaultfilesmiddleware using usedefaultfiles() , place before call usestaticfiles() : app.usedefaultfiles(); app.usestaticfiles(); if don't specify otherwise, middleware uses defaultfilesoptions default, means list of default file names used: default.htm default.html index.htm index.html see msdn

xcode - Check IBOutlet from UIView debugging IOS -

Image
i using uiview debugging see why layout position wrong or why have set text wrongly. when uiview debug, saw this. saw uilabel , don't know what iboutlet set to. may know if possible kind of outlet set? or identify that uilabel , find inside code? in interface builder right-click on uilabel , dialogue box pop displaying label's properties, there 1 it's outlet (it'll under referencing outlets). can @ respective header/implementation file , identify property outlet hooked to, in example it's "backgroundview".

php - Searching Multi-Dimension Array With Multiple Results -

let's have array , want search value should return multiple results: array(2) { [0] => array(2) { ["id"] => string(2) "1" ["custom"] => string(1) "2" } [1] => array(2) { ["id"] => string(2) "2" ["custom"] => string(1) "5" } [2] => array(2) { ["id"] => string(2) "3" ["custom"] => string(1) "2" } } i want search key custom value = 2 , following result: array(2) { [0] => array(2) { ["id"] => string(2) "1" ["custom"] => string(1) "2" } [1] => array(2) { ["id"] => string(2) "3" ["custom"] => string(1) "2" } } is possible without looping through array? there such class or built in function this? the array_filter function want. $array = [ [ ...

javascript - Fullscreen mode on click? Fullscreen API closes after navigation -

i'm making offline website project , i'd whole thing displayed in full screen when opened (or after clicking prompt.) @ moment use fullscreen api works great exits out of fullscreen after user navigates page. i've seen other people have had this issue , using fullscreen api purpose may not possible because of dom tree being destroyed. are there other work arounds or options use working? still new @ stuff vague answers can find "ajax loaders" has me lost. ideally cross browser compatible – i'm handing on files on usb , have no control on browser opened on. from offical whatwg spec (in section dealing naviagtion): ...if specified browsing context's active document not same document document of specified entry, run these substeps: fully exit fullscreen... i may misreading this, think it's spec if dom changes (eg page navigation), fullscreen dismissed. you may need chromium. edit: as ajax loaders, it...

python - Object pandas has no attribute name Series -

import pandas pd numbers = {1,2,3,4,5} ser = pd.series(numbers) print ser i write code in python pandas series. it's giving this "attributeerror: 'module' object has no attribute 'series'" please me the error in problem file name. i save file pandas.py that's why got error.

build - Combine many ruby source files into a single file -

i'm working on project in ruby, , have many source files each declaring few classes , methods in module. i've been looking around , may missing something, can't seem find way merge of source files single file. want single file because end product here meant command line tool, , users won't want install 20 files in order run single command. is there way take many ruby source files , process of require statements ahead of time create single file can run stand-alone program? a few things may useful (or harmful?): the file code not within function main file. therefore, main file have code run after file parsed. i require needed files @ start of each file (after initial comment), require statements @ top of file, , dependancies listed @ start of each file i call require on files required each file, regardless of weather or not may have been included already. example (a few files project): <filename> --> <include1> <inclu...

c# - WebAPI2 Json.Net Required property not adding ModelState Error properly -

[datacontract(namespace="")] public class value { [datamember(isrequired=true)] public string id { get; set; } [datamember(isrequired=true)] public int num { get; set; } [datamember] public string name { get; set; } } public value post(value value) { if(!modelstate.isvalid) { //bad request } return value; } i trying enforce values specified in post request web api. in value model above, when num property omitted: {"id": "abc", "name":"john"} it adds error model state indicating absence. however, when id property omitted: {"num" : 3, "name" : "john"} unexpectedly, no model state error added, , model considered valid. when manually deserialize model jsonconvert.deserialize throws serialization exception in both cases indicating property missing. why appear add model state errors when value type (int) not present correctly, not when ...

ruby - Using Mongoid: Can you use embed_in in multiple documents at the same time? -

i'm getting use using mongoid, ran problem situation i'm trying use mongoid. i have game, game has teams, teams have players, , game has same players. class game include mongoid::document embeds_many :players embeds_many :teams end class team include mongoid::document embedded_in :game embeds_many :players end class player include mongoid::document embedded_in :game embedded_in :team end now when run code using game = game.new( :id => "1" ) game.save player = player.new() game.players << player team = team.new() game.teams << team team.players << player i expect have game, has team, team has player, , player in game. then run newgame = game.find("1") newteam = newgame.teams.first newplayer = newgame.players.first newplayer2 = newteam.players.first newplayer exists, newplayer2 doesn't exist. so what's that? am allowed embedded document in 1 object, there way around it? tried maki...

angularjs - ng-change function gets run on page load before data loads? -

one of controller functions gets run before data loads. the html: <div ng-show="item.name"> <input ng-change="dochange()" ng-model="item.name"> </div> my controller: $scope.item = { name: 'bob' }; $scope.other = {}; $scope.dochange = function() { $scope.item = $scope.other['test'].name } // load data now! myservice.getdata().success(function(newdata) { $scope.item = newdata.item; $scope.other = newdata.other; }); my service: app.factory("myservice", function($http) { return { getdata: function() { return $http.get("/data"); } } }); this results in typeerror: cannot read property 'name' of undefined because dochange() gets executed before service has loaded data. i'm not sure why happens. shouldn't dochange run when input has changed, yet it's getting run on page load. change $scope.dochange() { ...

javascript - Number assigned to a variable using Case Switch returning 0 instead of correct result -

i beginner in javascript , simulate exercise using html , javascript. basically, have 2 inputs take 1: name of product , 2) quantity of item. when user click on button, function calculates total amount item executed. on function, use switch statement in order calculate right $amount according product. function should print itemtotal result of itemq (quantity of item) * fix value item (3.5 eggs). itemtotal appear 0 zero. seems switch statement not recognize it. if make local value inside switch, cannot used outside of switch statement. can do? ideas? function caltotitema() { var item = document.getelementbyid("itemname").value; var itemq = document.getelementbyid("itemquantity").value; var itemtotal = 0; switch (item) { case "eggs": this.itemtotal = 3.5 * itemq; break; case "milk": this.itemtotal = 4.5 * itemq; break; } document.getelementbyid("itemtotaldisplay").innerhtml...

ember.js - Getting length of hasMany association -

i have following models defined in ember project (project created ember-cli 0.2.3) import ds 'ember-data'; var game = ds.model.extend({ title: ds.attr('string'), description: ds.attr('string'), geekrating: ds.attr('number') }); game.reopenclass({ fixtures: [ { id: "1", title: "catan", description: "catan game", geekrating: "5.65"} ] }); export default game; import ds 'ember-data'; var ownedgame = ds.model.extend({ rating: ds.attr('number'), plays: ds.hasmany('gameplay'), game: ds.belongsto('game', {async: true}), playcount: function() { return this.get('plays.length') }.property('plays') }); ownedgame.reopenclass({ fixtures: [ { id: "1", rating: "8.25", game: "1"} ] }); export default ownedgame; import ds 'ember-data'; var gameplay = ds.model.ex...

c# - string Array initialization -

this question has answer here: all possible c# array initialization syntaxes 11 answers i have new array initialised below: string[] somenames = new string[] { "john", "bryan", "annete", "mathiew", "joseph", "donald", "tom" }; string[] somenames = { "john", "bryan", "annete", "mathiew", "joseph", "donald", "tom" }; what difference? both gives same result. thought second 1 throw error. why both works , 1 preferred or more correct? in first case, supply type of array element explicitly. however, c# compiler can figure out type of array element analyzing data supply. second example shows feature. there absolutely no difference between 2 initializers. pick 1 style , use throughout code base consistency.

Android Studio: Error:Execution failed for task ':app:dexDebug' when build project -

i'm using android studio first time , got following error after importing project (previously eclipse project had issues too.) here information given: error:execution failed task ':xink:dexdebug'. com.android.ide.common.internal.loggederrorexception: failed run command: c:\users\user\appdata\local\android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output e:\xink app\xink\xink\build\intermediates\dex\debug --input-list=e:\xink app\xink\xink\build\intermediates\tmp\dex\debug\inputlist.txt error code: 2 output: unexpected top-level exception: com.android.dex.dexindexoverflowexception: method id not in [0, 0xffff]: 65536 @ com.android.dx.merge.dexmerger$6.updateindex(dexmerger.java:502) @ com.android.dx.merge.dexmerger$idmerger.mergesorted(dexmerger.java:277) @ com.android.dx.merge.dexmerger.mergemethodids(dexmerger.java:491) @ com.android.dx.merge.dexmerger.mergedexes(dexmerger.java:16...

swing - Java repaint() not working on call -

i wonder why repiant() method not working intended more ... ex : public class main extends jpanel implements actionlistener, mouselistener,mousemotionlistener{ private arraylist<node> nodes; private arraylist<edge> edges; private boolean addnode; private int no_of_nodes; private int width = 30, height = 30; public static void main(string[] args){ main m = new main(); m.start(); } public void start() { nodes = new arraylist<node>(); edges = new arraylist<edge>(); jframe f = new jframe("sfg"); jpanel main_panel = new jpanel(new borderlayout()); jpanel buttons = new jpanel();//buttons containser jpanel draw = new jpanel(); arraylist<jbutton> bs = new arraylist<jbutton>(); jbutton b1 = new jbutton("add node"); b1.addactionlistener(new add_node()); jbutton b2 = new jbutton("add edge"); b2.addactionlistener(new add_edge()); jbutton b3 = new jbutton("add arc...

java - JPA Hibernate Spring MySql Tomcat - Connect to 2 databases -

i've been searching, reading, trying code 2 days , have not been successful. i need able connect 2 different databases, not simultaneously, using technologies listed in header. i'm using tomcat7, not j2ee container. below have application context. works fine 1 database. need configure two? how tell daos connection use? in advance. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/sc...

r - Variable matrix index and row/column as indices in a single function argument -

how handle variable matrix index , row/column indices in single function argument? m <- matrix(1:9, 3) fn <- function(m, subsetarg) { stopifnot(m[subsetarg] == 6) } i'd able use both situations: a <- matrix(false, 3, 3) a[2,3] <- true # yielding # f f f # f f t # f f f fn(m, subsetargument = a) # works and fn(m, subsetargument = tuple(2,3)) # <- not work logically note after using range, example tuple(2, 1:3) i understand done explicitly testing either 1 or 2 variables given, feel there might easier way. just slurp arguments , pass them call [ : fn <- function(...) { stopifnot(do.call(`[`, list(...)) == 6) } everything in r function, including subsetting :-)

php - Problems with volley passing parameters -

(check variablepost) well, want pass params volley android current code code volley map<string, string> params = new hashmap<string, string>(); params.put("variablepost", "androidvolley");//**** jsonobjectrequest jsonobjreq = new jsonobjectrequest(request.method.post, url, new jsonobject(params), new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { log.d(tag, response.tostring()); pdialog.hide(); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { volleylog.d(tag, "error: " + error.getmessage()); pdialog.hide(); } }) { @override protected map<string, string> getparams() throws authfailureerror { map<string, string> para...

registrykey - C++ Why does my code put a registry key at the wrong directory? -

so, want put registry key @ directory hkcu\software\microsoft\windows\currentversion\run, , want called test, , have contain "testtext", instead code puts new key @ hkcu\test , program writes random chinese characters in registry key. help? #include "stdafx.h" #include <iostream> #include <windows.h> #include <string> #include <time.h> using namespace std; int main() { hkey keyexample; if (regopenkey(hkey_current_user, text("software\\microsoft\\windows\\currentversion\\run\\"), &keyexample) != error_success) { regclosekey(keyexample); return 69; } if (regsetkeyvalue(hkey_current_user, text("test"), 0, reg_sz, (lpbyte)"testtext", strlen("testtext")*sizeof(char)) != error_success) { regclosekey(keyexample); cout << "unable set registry value value_name"; } regclosekey(keyexample); return 0; } ...

node.js - sails generate <something>: where are the docs on 'generate'? -

sails generate controller <name> , model , api , others. what others? options? commandline options? insert here obligatory "i've websearched high , low" thing can come github entries individual generators in various states of ignorement. so, abstractly, where's documentation on generate command? the default generators shipped sails documented here , in command line interface section of reference section of sails documentation. options accepted believe section of documentation references them, sails new having option usage options. at time of writing include new , api , model , controller , adapter , , generator . more community created generators can added, modifying .sailsrc file include npm package. here's example sails-auth docs . { "generators": { "modules": { "auth-api": "sails-auth" } } } if want know more making own generators , goes you'd want check out sai...

javascript - Detecting pinching in desktop browsers -

so scrolling events can detect panning gestures in desktop browsers , modify content accordingly. there way detect pinching (zooming) gestures? instead of browser zooming whole site (or not doing anything) modify dom element accordingly. there laptops such trackpads (like magic trackpad , force touch trackpad). gestures can captured, how can use them in desktop web apps? imagine pinch , zoom in our out in google map in desktop browser. , pan left , right hand gesture. i suggest using specialized library hammer.js . have @ this example of hammer.js documentation, utilize pinch gesture recognition. according example detecting pinch gesture simple as: var myelement = document.getelementbyid('myelement'), mc = new hammer.manager(myelement), pinch = new hammer.pinch(); mc.add(pinch); mc.on("pinch", function(ev) { console.log('you sir did pinch!'); }); however, if wanted react changing viewport within layout, might better off usi...

javascript - Regex Not Suppose To Run In Link Tag - JS -

currently, writing regular expressions parse textarea bbcode, , replace html. the problem @ moment regex use replace urls, replacing urls in [link] tag second time , messing them up. i replacing [link=___]test[/link] tags so: .replace(/(\[code\][\s\s]*?\[\/code\])|\[(link=)((http|https):\/\/[\s]{0,2000}\.[a-za-z]{2,5}(\/[^\[\]\<\>]*)?)\]([\s\s]*?)\[\/link\]/gi, function (m, g1, g2, g3, g4, g5, g6) { return g1 ? g1 : '<a href="' + g3 + '">' + g6 + '</a>'; }) and replacing urls in <a> tag so: .replace(/(\[(code|link=(.*))\][\s\s]*?\[\/(code|link)\])|((http|https):\/\/[\s]{0,2000}\.[a-za-z]{2,5}(\/[^\[\]\<\>]*)?)/gi, function (m, g1, g2, g3, g4, g5) { return g1 ? g1 : '<a href="' + g5 + '">' + g5 + '</a>'; }) i not know how not make second regex parse urls , not change them if inside of <link> tag. ideas on how make work correctly? i suggest ad...

c# - .NET runtime error while excuting .Net application -

i have compiled code supportproject.dll using .net framework 4 . i'm using dll in project target. while executing project target i'm getting below error unhandled exception: system.badimageformatexception: not load file or asse mbly 'supportproject, version=1.3.8325.1453, culture=neutral, publickeytoken=null' or 1 of dependencies. assembly built runtime newer cur rently loaded runtime , cannot loaded. file name: 'supportproject, version=1.3.8325.1453, culture=neutral, publickeytoken=nu ll' machine on i'm executing target project has .net version 4.0 tia.

iOS: Modify a font height, width, and spacing independently when creating PDF -

in ios app need use specific font each character needs taller, thinner, , spacing closed fit correctly. possible stretch/squish font programmatically? when you're adding text pdf file there multiple ways influence how text going appear. generic way (and way might sufficient you) scale text matrix: void cgcontextsettextmatrix ( cgcontextref c, cgaffinetransform t ); as mentioned in comment @mkl, can provide matrix scale in y direction while scaling down in x direction. effect letters stretched out vertically , squished horizontally. normally expect don't have touch spacing in case, spacing "squished" other characters. just in case isn't sufficient, pdf provide way change spacing between characters too: void cgcontextsetcharacterspacing ( cgcontextref context, cgfloat spacing ); while apple's description talks "additional space" add between characters, pdf specification , suspect apple's implementation result allows spacing...