Posts

Showing posts from April, 2010

How to find the intersections of two functions in MATLAB? -

lets say, have function 'x' , function '2sin(x)' how output intersects, i.e. roots in matlab? can plot 2 functions , find them way surely there must exist absolute way of doing this. if have 2 analytical (by mean symbolic) functions, can define difference , use fzero find zero, i.e. root: f = @(x) x; %defines function f(x) g = @(x) 2*sin(x); %defines function g(x) %solve f==g xroot = fzero(@(x)f(x)-g(x),0.5); %starts search x==0.5 for tricky functions might have set starting point, , find 1 solution if there multiple ones. the constructs seen above @(x) something-with-x called anonymous functions, , can extended multivariate cases well, @(x,y) 3*x.*y+c assuming c variable has been assigned value earlier.

Perl: oo with use parent - checking if class has a parent -

i have perl objects built time ago not moose, bless, inheritance implemented using 'parent' pragma. now know whether there way check whether class has used 'parent' or not. e.g. if have 2 classes package animal; sub new { $class = shift; return bless {}, $class; } 1; and package cat; use parent 'animal'; sub new { $class = shift; return bless {}, $class; } 1; would there check make determine 'cat' class has parent ( not care which, not ), , animal not, given $foo either of them? i can't picture why you'd ever want know this, it's possible using following: use mro; $inherits = @{ mro::get_linear_isa($class) } > 1; or my $isa = { no strict 'refs'; \@{ $class . '::isa' } }; $inherits = @$isa; notes: all classes inherit universal, that's ignored unless class explicitly declares inherits it. these methods don't care how inheritance declared ( use parent or other means

How to Get the content of html tag in c# -

i want content in "p" tag html document <div id=123> <div class="abc"> <div class="xyz"> <p> contents </p> i use dynamic document = webcontrol1.executejavascriptwithresult("document"); var p = document.getelementsbytagname("p"); but doesn't work try following: var p = document.getelementsbytagname("p")[0].innerhtml;

Is type casting possible between wrapper classes in Java? -

is type casting possible between wrapper classes in java? the code here tried: public class test { public static void main(string[] args) { double d = 100.04; long l = (long) d.doublevalue(); //explicit type casting required int = (int) l; //explicit type casting required system.out.println("double value " + d); system.out.println("long value " + l); system.out.println("int value " + i); } } why isn't long casted int in program? long l = (long)d.doublevalue(); //explicit type casting required int = (int)l; //not valid, because here casting wrapper long in above line, casting of l not possible int because wrapper classes autoboxing , unboxing. refer: https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html . wrapper class casted corresponding primitive type. long l = (long)d.doublevalue(); //explicit type casting required int = (int)l;

python - VerificationError: CompileError: command 'cc' failed with exit status 1 -

i trying install: couchbase-python-cffi part of pypi package. keep on getting following error when trying install couchbase-python-cffi: verificationerror: compileerror: command 'cc' failed exit status 1 this error occurs on travis build: https://travis-ci.org/ardydedase/pycouchbase/jobs/75819605#l541 here's content of travis file: # config file automatic testing @ travis-ci.org language: python python: - "3.4" - "3.3" - "2.7" - "2.6" - "pypy" before_install: - sudo rm -rf /etc/apt/sources.list.d/* - wget -o- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add - - echo deb http://packages.couchbase.com/ubuntu precise precise/main | sudo tee /etc/apt/sources.list.d/couchbase.list - sudo apt-get update - sudo apt-cache search libcouchbase - sudo apt-get install libxml2-dev libxslt-dev python-dev libffi6 libffi-dev - sudo apt-get install build-essential libssl-dev insta

sorting - Python order a dict by key value -

i've been trying order dict has keys format: "0:0:0:0:0:x" x variable incremented while filling dict. since dictionaries doesn't insert in order, , need key-value values showed ordered, tried use collections.ordereddict(sorted(observation_values.items()) where observation_values dict, values ordered caring first number, this: "0:0:0:0:0:0": [0.0], "0:0:0:0:0:1": [0.0], "0:0:0:0:0:10": [279.5], "0:0:0:0:0:100": [1137.8], "0:0:0:0:0:101": [1159.4], "0:0:0:0:0:102": [1180.3], "0:0:0:0:0:103": [1193.6]... till "0:0:0:0:0:109" "0:0:0:0:0:11" , again "0:0:0:0:0:110" , ..:111 , ..:112 . how can avoid using significant numbers order? you sorting strings, sorted lexicographically, not numerically. give sorted() custom sort key: sortkey = lambda i: [int(e) e in i[0].split(':')] collections.ordereddict(sorted(observation_values.items(), key

python - django-phonenumber-field: get phone number field validation pattern -

i using django-phonenumber-field in model. parsley.js validate model form on client side. however, cannot find regular expression used validate phonenumberfield field on server side. i use exact same expression if possible. here model , form: from phonenumber_field.modelfields import phonenumberfield @python_2_unicode_compatible class cvapplication(application): mobile_phone_number = phonenumberfield() [...] @parsleyfy class cvapplicationform(forms.modelform): class meta: model = cvapplication fields = ( 'mobile_phone_number', [...] ) def __init__(self, *args, **kwargs): super(cvapplicationform, self).__init__(*args, **kwargs) self.fields['mobile_phone_number'].widget.attrs.update( {'data-parsley-pattern': '??????????'} ) [...] thank help! django-phonenumber-field relies on python-phoneumbers validate phone number. you

How to display xml content with html tags and view it as html using Jquery load -

i want display xml content html tags , view in html format via browser using jquery load. issue: html tags displayed actual html tags (i.e. <p> or <br> ) in browser , need convert html format. i have xml: <?xml version="1.0" encoding="utf-8" ?> <catalog> <title>catalog 1</title> <text_area><p>this test catalog1</p><br>this second line<br>last line. <b>end</b></text_area> </catalog> i have html, js code <!doctype html> <html> <head><script src="https://code.jquery.com/jquery-1.10.2.js"></script></head> <body> <b>catalog</b><br> title:<div id="title"></div><br> content:<div id="text_area"></div><br> <script> var getvar = "catalog.xml"; $( "#title" ).load("catalog.xml title"); $( "#text_are

c++ - How do I print out vectors in different order every time -

i'm trying make 2 vectors. vector1 (total1) containing strings , vector2(total2) containing random unique numbers(that between 0 , total1.size() - 1) i want make program print out total1s strings, in different order every turn. don't want use iterators or because want improve problem solving capacity. here specific function crash program. (unsigned = 0; < total1.size();) { v1 = rand() % total1.size(); (unsigned s = 0; s < total1.size(); ++s) { if (v1 == total2[s]) ; else { total2.push_back(v1); ++i; } } } i'm grateful can get! can suggest change of algorithm?. because, if current 1 correctly implemented ("s", in code, must go 0 total 2 .size not total1.size , if element found, break , generate new random), has following drawback: assume vectors of 1.000.000 elements , trying last random number. have 1 probability in 1.000.000 of find random number not

sum of all integer between m and n in a loop Python 3 -

i having problems acquiring sum of integers between m , n . in code must input 2 integers m , n , calculate , display sum of integers m n . the sum should calculated using loop repeatedly add numbers total , cannot use formula calculate result. code produced far displayed below: m = int(input("enter number: ")) n = int(input("enter second number: ")) sum = 0 in range (m,n): m+n sum += print(i) you should use range(m, n+1) in order include n in range. for in range (m,n+1): sum += print(i) print(sum) for example range(4,6) give [4,5] range(4,5) give [4] .

javascript - Web Audio Api - Download edited MP3 -

i'm editing mp3 file multiple effects so var mainverse = document.getelementbyid('audio1'); var s = source; source.disconnect(audioctx.destination); (var in filters1) { s.connect(filters1[i]); s = filters1[i]; } s.connect(audioctx.destination); the mp3 plays accordingly on web filters on it. possible create , download new mp3 file these new effects, using web audio api or writing mp3 container javascript library ? if not whats best solve on web ? update - using offlineaudiocontext using sample code https://developer.mozilla.org/en-us/docs/web/api/offlineaudiocontext/oncomplete i've tried using offline node so; var audioctx = new audiocontext(); var offlinectx = new offlineaudiocontext(2,44100*40,44100); osource = offlinectx.createbuffersource(); function getdata() { request = new xmlhttprequest(); request.open('get', 'song1.mp3', true); request.responsetype = 'arraybuffer'; request.onload = function(

java - How to make a JFrame one colour? -

i'm trying add polish small game made and, every time round finishes, i'd whole jframe flash white , lose opacity until can see game again. how this? note: i'm thinking hiding components , adding jpanel on top loses opacity doesn't seem right (and i'd able see components behind white flash goes opaque transparent). you use jlayer class. take @ section swing tutorial on how decorate components jlayer class . the tutorial has examples that: paint translucent layers do animation put examples , should have solution.

ios - swift will I be forced to remake my app's code when swift 2.0 is released -

i have made app using swift 1.2. will forced rebuild entire using swift 2 when released? or can still make updates app using swift 1.2 code? it's understanding xcode 7 uses swift 2, , xcode 6.x uses swift 1.2. apple continue support xcode 6.x time after xcode 7 goes gm. during time should able support swift 1.2 code. however, it's not idea depend on old developer tools. should think migrating swift 2 once xcode 7 released.

crashlytics - Git thinks a directory is deleted when it is not -

Image
this happened after upgraded crashlytics fabric following fabric update wizard. here folder structure looks like: why git think crashlytics.framework/headers folder deleted when it's not , in fact there new files being added within headers folder? it possible git confused because had delete old "crashlytics.framework" replaced new version of framework same folder name different content? how make git know crashlytics.framework/headers folder not deleted? currently i'm hesitant commit , push this. git doesn't track directories . does, however, track symbolic links , , representing link small text file link file-type (as on this answer ). the directory identical you, , traverse cd same way, on file system appear different. don't know sure whether finder represents symlinked directories different, might not. my hunch directory symbolic link other directory, git acknowledged file named "headers", , upgrade replaced symboli

node.js - "style" field in package.json -

i noticed bootstrap , normalize.css both have "style" field in package.json. why have this? if had guess, it's allow users import defined stylesheet doing require('bootstrap') , doesn't seem case. from techwraith's pull request added bootstrap: many modules in npm starting expose css entry files in package.json files. allows tools npm-css , rework-npm , , npm-less import bootstrap node_modules directory. [...] it's not written anywhere in code these modules right now. we're hoping standardized @ point, we've reached convention separately, i'm inclined go it. [...] if want read style of css development, wrote thing: http://techwraith.com/your-css-needs-a-dependency-graph-too/ there's support in other tools, such browserify plugin parcelify : add css npm modules consumed browserify. just add style key package.json specify package's css file(s). [...] par

mysql - global variable not working in php class -

class database { public $connect = ""; public function connect() { $connect = new mysqli("localhost", "root", "1521", "phone"); ini_set('default_charset', "utf-8"); mysqli_set_charset($connect, "utf8"); header('content-type: text/html; charset=utf-8'); if ($connect->connect_error) { die('not connect' . mysqli_connect_error()); } } public function insert() { $sql = "select id personal order id desc limit 1"; //global $connect; $result = $connect->query($sql);//// here !!!!!!!! $row = $result->fetch_assoc(); $tempint = (int)$row['id']; $tempint += 1; } } why $connect in insert function not working ? added global befor $connect still not working. simple class mysql. you syntax incorrect. change this, $connect = new mysqli(

c++ - Template equivalent of #var in macro -

in c++ macros can use #var literal string of argument passed: #define print_size(type) \ (std::cout << sizeof(type) << " " << #type << std::endl) using macro, can write simple program give me lengths of specific types on machine: print_size(bool); print_size(char); … this work use c++ templates instead. obtaining size easy following template function: template <typename t> void print_size() { std::cout << sizeof(t) << std::endl; } i can call function type , output size: print_size<bool>(); print_size<char>(); … is there way literal "bool" anywhere such output nice 1 macros? it can sortof done using rtti (runtime type inference) using typeid: #include <iostream> #include <typeinfo> template <typename t> void print_size() { t a; std::cout << typeid(a).name() << ": "

ios - Using SPUserResizableView in Swift -

i'm trying use spuserresizableview created spoletto in github ( https://github.com/spoletto/spuserresizableview ). i imported .h , .m files, created bridge , added delegates controller. i think problem problem library old , that's why many errors in .h , .m files can't use library. errors - http://postimg.org/gallery/3bq2ldo0m/ can me setup library in swift? i got same error, add these 2 in spuserresizableview.h #import <uikit/uikit.h> #import <foundation/foundation.h> your problem resolved.

ocaml - Type-safe template variable substitution -

i had idea of type-safe templating language use polymorphic variants source of type-safe variables can substituted text, example: type 'a t = var of 'a | text of string | join of 'a t * 'a t let rec render ~vars = function | text source -> source | var label -> vars label | join (left, right) -> render left ~vars ^ render right ~vars let result = render (join (var `foo, text "bar")) ~vars:(function `foo -> "foo");; let () = assert (result = "foobar") this fine: compiler enforce don't forget substitution variable, or don't have typo in variable name—thanks polymorphic variants. however, find 2 problems: you can accidentally supply unused variable. if template contains no variables, still forced supply ~vars function, , 1 work fun _ -> "" or fun _ -> assert false , compromizes type-safety in case template ever changes. i'm looking advice on problems above, appreciate appl

Why my AngularJS module isn't defined -

here code: var app = angular.module('todoapp', ['ui.router', 'ngresource', 'ui.bootstrap']); app.config(['$stateprovider', '$urlrouterprovider', function($stateprovider, $urlrouterprovider) { $urlrouterprovider.otherwise("/"); $stateprovider .state('home', { url: "/", templateurl: '/templates/index.html', }) .state('signup', { url: "/signup", templateurl: '', }) } ]); module.exports = app; when i'm running in in browser, show me error: referenceerror: module not defined what i'm doing wrong ? how define module ? the console error message few lines below module not defined gives hint problem is: module 'ui.router' not available! either misspelled module name or forgot load it. check if have included file containing ui.router page

web scraping - python webscraping with selenium: trouble locating modal element -

i want go http://ted.com/talks , click "see topics" in "topics" dropdown, , click random letter heading, "c" or "d-e". however, don't know how find element in modal popup specific letter heading. this letter heading elements when click "inspect element": <li class="topic-select__range"> <a class = "topic-select__range__link" href="#" data-index="0">a-b</a> </li> <li class="topic-select__range"> <a class = "topic-select__range__link" href="#" data-index="1">c</a> </li> <li class="topic-select__range"> <a class = "topic-select__range__link" href="#" data-index="2">d-e</a> </li> ... etc. my program can way see topics fine gets cannot locate element error when try click on letter headers. code snippet looks far: # each header ass

node.js - How do I make the Sass Importer combine files into one stylesheet? -

this question has answer here: import regular css file in scss file? 14 answers i found out feature in node-sass named importer , allows handle encounter @import in sass files. i want take advantage of feature import .css files npm package easily, browserify. here's sass file. (index.scss) @import "normalize.css"; when run file through sass , importer, should output (supposed index.css): /*! normalize.css v3.0.3 | mit license | github.com/necolas/normalize.css */ /** * 1. set default font family sans-serif. * 2. prevent ios , ie text size adjust after device orientation change, * without disabling user zoom. */ html { ... instead, outputs (actual index.css): @import url(/users/me/workspace/project/node_modules/normalize.css/normalize.css); what gives? why importer changes file path instead of taking file , combining origin

go - How to handle HTTP timeout errors and accessing status codes in golang -

i have code (see below) written in go supposed "fan-out" http requests, , collate/aggregate details back. i'm new golang , expect me noob , knowledge limited the output of program like: { "status":"success", "components":[ {"id":"foo","status":200,"body":"..."}, {"id":"bar","status":200,"body":"..."}, {"id":"baz","status":404,"body":"..."}, ... ] } there local server running purposely slow (sleeps 5 seconds , returns response). have other sites listed (see code below) sometime trigger error (if error, that's fine). the problem have @ moment how best handle these errors, , "timeout" related errors; in i'm not sure how recognise if failure timeout or other error? at moment blanket error time: get http://localhost

cocoa - Checkbox NSButton inside NSPopover changes colors when running -

Image
i'm getting strange behavior of checkboxes inside nspopover on os x 10.10.3. colors of checkboxes distorted other elements regular buttons or labels have correct colors. top image: how nspopover renders in running app (black background app). bottom image: nspopover view in interface builder. visual effect views (like used in nspopover) totally messed in os x yosemite. luckily working fine in el capitan. a workaround on yosemite should set appearance property of each checkbox, label, scrollview etc. nsappearancenameaqua

c++ - How to catch com0com IO-CTL commands? -

i have 2 connected virtual com ports (ex. com0 , com1), created com0com driver. old application (app1) writes data com0 , read com1 (in app2) , vice-versa. how can catch io-ctls virtual com port, created com0com driver (com1), baud rate, parity , others? of course, can change nothing in app1 , can in app2.

Python, get base64-encoded MD5 hash of an image object -

i need base64-encoded md5 hash of object, object image stored file, fname. i've tried this: def get_md5(fname): hash = hashlib.md5() open(fname) f: chunk in iter(lambda: f.read(4096), ""): hash.update(chunk) return hash.hexdigest().encode('base64').strip() however, don't think right because returns string many characters. understanding needs 24 characters long. get njjim2rlowmzotyxymm3mdi5y2q1nzdjotq5ywrlytq= i've tried few other similar ways well, example, 1 not chunk loop thing. return same string. (my later actions need base64-encoded md5 hash fail, , i'm thinking why.) i able make work using digest() instead of hexdigest(). last line becomes: return hash.digest().encode('base64').strip() the result 24 characters long, , accepted google cloud storage transfer, required base64-encoded md5 hash.

transformation - OpenGL GL_Position 3D to 2D Screen Space -

i trying understand maths associated converting 3d point 2d screen position. understand process involves moving object space->worldspace->eye space -> clip space -> ndc space -> viewport space (final 2d position on screen) vertexshader: gl_position = projection matrix * view matrix * model matrix * vec(position,1); => clip space. fragmentshader: (pseudo code) //assuming gl_position received vec4 input variable vec2 gl_position_ndc = (gl_position.xy/gl_position.w)/2+ .5; (gl_position_ndc -> gl_fragcolor) after perspective division , converting normalized device coordinate space do these automatic perspective divides , ndc conversion in fragment shader happen automatically gl_position received vertex shader described above in fragment shader? yes, division w automatic after output clip-space vertex in vertex shader. it happens before rasterization, , therefore before fragment shader runs. now, 1 interesting quirk in window-space (

json - Facebook Graph API get page post's attachments -

i trying url of image attachment published facebook page. goal embed image in webpage in order website display last image attachment published page. own both website , fb page. i have yet not grasped details on handling facebook graph api, here did far: 1) in fb developers website, have created application, getting app id , secret; 2) used information access token (just pasted in browser following code: https://graph.facebook.com/oauth/access_token?client_id={my-client-id}&client_secret={my-client-secret}&grant_type=client_credentials 3) in website, have loaded facebook js sdk after body tag; , got facebook page id facebook page administration; 4) real question begins: how can query facebook information need – source url of last published image? the best result have gotten far making getjson call of jquery: var fbfeed = $j.getjson('https://graph.facebook.com/{my-page-id}/feed?access_token={my-token}&fields=attachments&limit=1'); this , stor

Resources release while coding on Haxe (mainly for XML parser disposal)? -

i'm new haxe coming actionscript. looking ways dispose resources when can't reuse them. in particular, there actionscript's "system.disposexml" haxe's fast xml? it depends on target platform, in javascript/as3, have object or graph of objects disposed of, make sure there no references anywhere in program. garbage collector take care of it. what disposexml seems overkill. modern garbage collectors, don't need break references within group, referring member of it.

javascript - Random value generation from options with chance -

i want way pick random element array, probability of element being picked expressed percentage on each element. the array may in json format or php array, though code has written in php. following example in json: { "extreme": { "name": "item 1", "chance": 1.0 }, "rare": { "name": "item 2", "chance": 9.0 }, "ordinary": { "name": "item 3", "chance": 90.0 } } for example above, following true: item 1 ( extreme ) should picked 1 out of 100 times item 2 ( rare ) should picked 9 out of 100 times item 3 ( ordinary ) should picked 90 out of 100 times in simple words: code random picking item array or json string, setting percentage chance each item. @mhall's solution faster. but i'll leave mine here record: <?php $json_string = ' { "extre

c++ - Best way to avoid code duplication defining comparison operators `<, <=, >, >=, ==, !=`, but taking into account NaNs? -

i mathematics, x <= y equivalent !(x > y) . true floating-point arithmetic, in cases , not always. when x or y nan, x <= y not equivalent !(x > y) , because comparing nan returns false . still, x <= y <=> !(x > y) true of time. now, suppose writing class contains floating-point values, , want define comparison operators class. definiteness, suppose writing high-precision floating-point number, uses 1 or more double values internally store high-precision number. mathematically, definition of x < y class defines other operators (if being consistent usual semantics of comparison operators). nan s break mathematical nicety. maybe forced write many of these operators separately, take account nans. there better way? question is: how can avoid code duplication as possible , still respect behavior of nan ? related: http://www.boost.org/doc/libs/1_59_0/libs/utility/operators.htm . how boost/operators resolve issue? note: tagged question c++ because

html - resource with http or not? change site speed? -

use this: <link href="http://www.alessandrapinto.it/css/real-style.css" rel="stylesheet"> or this: <link href="css/real-style.css" rel="stylesheet"> can change speed of website? all 2 example in same domain. look @ server logs. server receives same path in end, purely client-side manipulations. answer no.

java - what is the purpose of assertThat in JDBI? -

i going through codebase found in github. found set of lines in code contains following function: assertthat .any appreciated. myobject = somedao.foo(obj); assertthat(myobject.getupdated,isafter(updated)); this assertion lib called hamcrest used ensure states in program. if fail throw exception output understanding goes wrong. assert or assertequals methods junit . , used in test class can use them in normal program ensure states expect (preconditions, postconditions,class invariants or design contract). so ensures date getupdated > date updated when wrong exception thrown.

c++ - Do most compilers transform % 2 into bit comparison? Is it really faster? -

in programming, 1 needs check if number odd or even. that, use: n % 2 == 0 however, understanding '%' operator performs division , returns remainder; therefore, case above, faster check last bit instead. let's n = 5; 5 = 00000101 in order check if number odd or even, need check last bit. if it's 1 , number odd; otherwise, even. in programming, expressed this: n & 1 == 0 in understanding faster % 2 no division performed. mere bit comparison needed. i have 2 questions then: 1) second way faster first (in cases)? 2) if answer 1 yes, compilers (in languages) smart enough convert % 2 simple bit comparison? or have explicitly use second way if want best performance? yes, bit-test much faster integer division, by factor of 10 20, or 100 128bit / 64bit = 64bit idiv on intel . esp. since x86 @ least has test instruction sets condition flags based on result of bitwise and, don't have divide , then compare; bitwise and is compare.

java - Microsoft Azure Database and Glassfish -

i have j2ee web application deployed on glassfish 4.0.1 want use windows azure database. the application uses jpa , eclipselink. if ping glassfish interface works, properties provide ok. if application uses database after server started, goes (it can retrieve/store data) when application tries use database after being idle while, exception saying connection closed. if flush connection (from glassfish admin) starts work again, until goes idle period of time. so basically, long executes database operations works well, if there no database operations while, next db operation result in exception. i have found solution having hard time implementing it. can me please ? here link of solution http://www.robblackwell.org.uk/2010/12/02/java-jdbc-to-sqlazure-connection-drop-workaround.html or here https://msdn.microsoft.com/en-us/library/hh290696(v=sql.110).aspx per experience, alternative way solve issue can create crontab listener using java schedule framework &q

sql - How to calculate time difference between current and previous row in MySQL -

Image
i have mysql table t1 : what want do calculations between rows , save value in new coloumn called diff ticketid| datenew | diff 16743 12:36:46 0 16744 12:51:25 15. minute 16745 12:57:25 6.5 minute .......... ....... etc i know there similar questions ,but ive tried of solutions posted here no success,so how solve query ??? to time difference in minutes between current , previous row, can use timestampdiff on datenow , previous time, can via subquery: select ticketid, datenew, timestampdiff(minute,datenew,(select datenew mytable t2 t2.ticketid < t1.ticketid order t2.ticketid desc limit 1)) diff mytable t1 update here's way using variable store previous datenew value might faster: select ticketid, datenew, timestampdiff(minute,datenew,prevdatenew) ( select ticketid, datenew, @prevdatenew prevdatenew, @prevdatenew := datenew mytable order ticketid ) t1

ios - Should I consider displayed ads when rating app in itunes connect? -

i have made ios app shows ads multiple ad networks. itunes connect asks me give rating of app based on content, , not sure wether should consider ads content, since come third-party service , have limited (or no) control on them. in case ads considered content, how supposed know kind of ads show , how frequently, since ad networks implemented not offer kind of informations? i looked both on google , stackoverflow not find answer. you're going responsible whatever content own application displays. if vendors can't provide information on content, need different vendors. there should content guideline documentation available reputable vendor. see apple's , project wonderful's , , admob's examples. ad vendors can , should rating or restricting content can control serve. if they're not, shouldn't work them. it's going trouble on you.

angularjs - Irregular repetitions in table using JavaScript and Angular.JS -

i iterate on data this: <table> <tr ng-repeat="(k,val) in items"> <td>{{k}} {{val.style}}</td> <td ng-repeat="(k2, item) in val.items">{{item.title}}</td> <td>{{item.ingredients}}</td> <-- (a) <td>{{item.moreinfo}}</td> <-- (b) </tr> </table> (a) , (b) [and c, d, e...] use object "item in val.items", {{item.ingredients}} not valid expression there, because out of <td> object want use create more columns. example of like: http://jsfiddle.net/yj7xopgy/ is there way that? use ng-repeat-start , ng-repeat-end . <td ng-repeat-start="(k2, item) in val.items">{{item.title}}</td> <td>{{item.ingredients}}</td> <td ng-repeat-end>{{item.moreinfo}}</td> updated fiddle

How to reconfigure rails 4 to use mongodb -

i want configure existing rails application use mongoid instead of sql database. ideally, have used "rails new --skip-active-record name_here." how do after i've made application? haven't done model or database yet there no files created relating database aside made when created rails project. you can start manually removing references activerecord::base in model files , replace them include mongoid::document you might need comment every line starting config.active_record in environment configuration files. you'll find these files in /config/environments/ then can use rails g mongoid:config command generate mongoid.yml configuration file. ps : when using rake you'll have use rake db:mongoid:* commands. edit: also remove require rails/all you'll have require each framework separately, example : require "action_controller/railtie" require "action_mailer/railtie" require "sprockets/railtie" require

c# - Automatically bind event to a Dependency Properties Value -

i trying set custom user control derived togglebutton control. i set 2 new commands, checkedcommand , uncheckedcommand. i have defined commands below, , able bind them. , firing them via internal events. works great. however able have these commands disable button usual command interface canexecute. understand need use canexecutechanged event , set isenabled property in here. when supposed bind event, looked @ using propertychangedcallback event of dependancyproperty how unsubscribe bound command. it ends looking bit convoluted, missing simple or way is. [description("checked command"), category("common properties")] public icommand checkedcommand { { return (icommand)this.getvalue(checkedcommandproperty); } set { this.setvalue(checkedcommandproperty, value); } } public static readonly dependencyproperty checkedcommandproperty = dependencyproperty.register( "checkedcommand

core bluetooth - CoreBluetooth State Preservation and Restoration -

i have following scenario: ios app (peripheral) x osx app (central) i instantiate peripheral manager cbperipheralmanageroptionrestoreidentifierkey. in peripheral's didfinishlaunchingwithoptions send local notification after getting peripheral uiapplicationlaunchoptionsbluetoothperipheralskey (don't it) in peripheral's willrestorestate trigger notification (don't other that) if peripheral app still running in background before gets killed due memory pressure, messages osx central fine. after ios app gets killed, when osx central sends message, both notifications mentioned above come through on ios, message expecting doens't. i've not resintantiated peripheralmanager @ moment, , how should it? have 1 peripheralmanager entire cycle of app. any suggestions welcome. update: if do let options: dictionary = [cbperipheralmanageroptionrestoreidentifierkey: "myid"] peripheralmanager = cbperipheralmanager(delegate: self, queue: nil, option

c# - nancy razorview intellisense -

i using nancy, self-hosting, razorview. using vs 2010. i cannot intellisense working razor view syntax in cshtml files. i've been struggling hours! i'd intellisense razor view syntax i'm new razorview engine. i gave , used vs 2015. worked steps listed on nancyfx site. anyone struggling issue, save time , use 2015. razor intellisense doesn't appear work nancy in visual studio 2010.

ruby on rails - How to best model survey forms -

i want create 2 types surveys, presurvey , postsurvey, users can fill out. each survey type have same questions. what's best way model 2 surveys? having each survey model have different field each question seems bad design because it's hard maintain , extend. i'm trying create survey model has_many questions, , have presurvey , postsurvey inherit it. seems it's right path, can't figure out how force instances of 1 type of survey specificy questions there. time presurvey created, have same set of questions in it. how can force behavior? sorry less specific questions asked here, if point me in right direction appreciate it.

python - Fast method for removing duplicate columns in pandas.Dataframe -

so using df_ab = pd.concat([df_a, df_b], axis=1, join='inner') i dataframe looking this: b b 0 5 5 10 10 1 6 6 19 19 and want remove multiple columns: b 0 5 10 1 6 19 because df_a , df_b subsets of same dataframe know rows have same values if column name same. have working solution: df_ab = df_ab.t.drop_duplicates().t but have number of rows 1 slow. have faster solution? prefer solution explicit knowledge of column names isn't needed. you may use np.unique indices of unique columns, , use .iloc : >>> df b b 0 5 5 10 10 1 6 6 19 19 >>> _, = np.unique(df.columns, return_index=true) >>> df.iloc[:, i] b 0 5 10 1 6 19

javascript - TypeError: undefined is not a function GET request/db call -

i getting typeerror when using node.js execute request. looks same other requests in other modules. error being returned in code executed between 2 created modules, i'm not sure what's going on. error: typeerror: undefined not function @ object.exports.getfollowingwatches (/users/m/desktop/projects/bx-server/modules/feed/feeddb.js:23:11) @ /users/m/desktop/projects/bx-server/modules/feed/index.js:55:5 @ layer.handle [as handle_request] (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/layer.js:95:5) @ next (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/route.js:131:13) @ route.dispatch (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/route.js:112:3) @ layer.handle [as handle_request] (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/layer.js:95:5) @ /users/m/desktop/projects/bx-server/node_modules/express/lib/router/index.js:277:22 @ function.process_params (/users/m/desktop/projects/bx-serv

javascript - AJAX inside if statement -

this onclick function. code without if statement runs perfectly. i'm trying test if sbmt equal 1 , remove row. once add if statement, row cannot removed. wrong code? function taskonclick(row,task) { var url = 'remove_task.asp?task='+task; if (<%=("sbmt")%> === 1){ $(this).row.closest('tr').remove(); $.ajax({url: url, success: function(result){ alert(result); }}); } }; <tr id="taskid"> <% if objrs("reas") <> "" strreason = "<br/><br/><b style=""color: red"">reason: "&objrs("reas")&"</b>" else strreason = "" end if response.write "<td onclick=""taskonclick(this,'"&objrs("task")&"')""><a href="&quo

mysqldump - how to repack logfiles with git efficiently -

i have several files on server grow permanently (logs, db-dumps, ..) , want make full backup history in repository. simple diffs between 2 states pretty small, files too, somehow git repository becomes large, 100 gb now. i found repack command, runs hours , don't see how far got already. can see somehow how percent got processed? also in beginning there repack problems, have found following parameters, not sure if values use case: repack -a -f -d --window-memory=400m --max-pack-size=400m --depth=100 --window=100 is possible configure git to: .. work each file individually? read sorts files size , type , if close, diff on them, independent of filename. can disabled , check same file? never renamed. thought making 1 git every file, lot of repositories. usual? .. compare each new file last 2-3 versions of same file? or last one? since new content appendend, doesn't make sense compare earlier versions. db-dumps data change in middle, does. files not large, prefer

c# - Why am I getting a namespace error with Manufaktura Library -

i attempting use library manufaktura draw music notation in wpf application. i have using statement need according instructions on this page using manufaktura.controls; using manufaktura.model; using manufaktura.music; using manufaktura.controls.wpf; using manufaktura.model.mvvm; i have appropriate dlls referenced in solution explorer of visual studio well. when used code sample getting 2 errors (three 2 same). code instruction: public class testdataviewmodel : viewmodel { private score data; public score data { { return data; } set { data = value; onpropertychanged(() => data); } } public void loadtestdata() { } } errors: error 1 type or namespace name 'score' not found (are missing using directive or assembly reference?) and error 3 type arguments method 'manufaktura.model.mvvm.viewmodel.onpropertychanged(system.linq.expressions.expression>)' cannot inferred usage. try specify

python - There is no improvement when changing from sync to async handler -

i compared sync , async version handler, , there no improvement on 'response time' etc metrics, how debug in situation? handler @gen.coroutine def get(self): calendar = calendar() response = yield (calendar.events()) self.write(response) self.finish() model class calendar(object): @return_future def events(self, callback=none): result = # mysqldb operation callback(result) basic information: cpu: 1 core dababase: mysqldb @return_future doesn't make sense here. used adapt functions asynchronous (and use callbacks) can yielded coroutine. there little reason ever use in modern tornado application; use @gen.coroutine everywhere. to run mysqldb operation without blocking ioloop, must run on separate thread. install futures package , create threadpoolexecutor: executor = threadpoolexecutor(4) class calendar: @gen.coroutine def events(self): result = yield executor.submit(mysqldb_operation)

mysql - Import particular Colums of csv in database in php/sql -

i have csv contains 15 columns. but want import 2 columns csv in database. whats should do? i tried importing it's importing columns. <?php //database connection details $connect = mysql_connect('localhost','root','123456'); if (!$connect) { die('could not connect mysql: ' . mysql_error()); } //your database name $cid =mysql_select_db('test',$connect); // path csv file located define('csv_path','c:/wamp/www/'); // name of csv file $csv_file = csv_path . "test.csv"; if (($handle = fopen($csv_file, "r")) !== false) { fgetcsv($handle); while (($data = fgetcsv($handle, 1000, ",")) !== false) { $num = count($data); ($c=0; $c < $num; $c++) { $col[$c] = $data[$c]; } $col1 = $col[0]; $col2 = $col[1]; $col3 = $col[2]; // sql query insert data database $query = "insert csvtbl(id,name,city) values('".$col1."',&#

ubuntu - Apt-get wants to install different version of dependencies for libboost-all-dev? -

when run sudo apt-get install libboost-all-dev error, seems common. reading package lists... done building dependency tree reading state information... done packages not installed. may mean have requested impossible situation or if using unstable distribution required packages have not yet been created or been moved out of incoming. following information may resolve situation: following packages have unmet dependencies: libboost-all-dev : depends: libboost-context-dev not going installed depends: libboost-coroutine-dev not going installed depends: libboost-exception-dev not going installed depends: libboost-graph-dev not going installed depends: libboost-graph-parallel-dev not going installed depends: libboost-locale-dev not going installed depends: libboost-log-dev not going installed depends: libboost-math-dev not going installed

sql server - skip records based on columns condition -

i have question in sql server table name : emp id |pid |firstname| lastname | level 1 |101 | ram |kumar | 3 1 |100 | ravi |kumar | 2 2 |101 | jaid |balu | 10 1 |100 | hari | babu | 5 1 |103 | nani | jai |44 1 |103 | nani | balu |10 3 |103 |bani |lalu |20 here need retrieve unique records based on id , pid columns , records have duplicate records need skip. finally want output below id |pid |firstname| lastname | level 1 |101 | ram |kumar | 3 2 |101 | jaid |balu | 10 3 |103 |bani |lalu |20 i found duplicate records based on below query select id,pid,count(*) emp group id,pid having count(*) >=2 this query duplicated records 2 records need skip retrieve output please tell me how write query achieve task in sql server. since output based on unique id , pid not have duplicate value, can use count partition achieve desired result.

reactjs - How to make simple button navigation to other view? -

i trying make simple button navigation 1 view other ( i'm yet unsure called view or not ). for example have featured.js as var searchpage = require('./search'); class featured extends component { showsearchpage(){ console.log('showing search page'); this.props.navigator.push({ title: "search", component: searchpage }); } render() { return ( <touchablehighlight onpress={() => this.showsearchpage()}> <view style={styles.row}> <text style={styles.label}>open search page</text> </view> </touchablehighlight> ); } } module.exports = featured; then have search.js class featured.js . how can create button in view on tap open search.js view. currently getting "can not read property push of undefined". how define navigator or there other simple way

android - PushWoosh - add custom broadcast receiver -

what want achieve: upon receiving pushwoosh notification, check payload , direct user specific activity accordingly. i'm following example in pushwoosh faq section regarding using custom push broadcast receiver in android however, i'm unable receive push inside custom push.. here's androidmanifest.xml : <receiver android:name="com.google.android.gcm.gcmbroadcastreceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.send"> <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <action android:name="com.google.android.c2dm.intent.registration" /> <category android:name="${applicationid}" /> </intent-filter> </receiver> <receiver android:name=".receivers.pwbro

Android how can i get thumb image of video file from gallery -

i need show selected video file gallery in listview. have fetched uri of video file not able thumb image of video file. here code have used fetching image of video file uri, causes app crash. there other way image of video file..? please assist me if can achieved in other way.... public static string getfilemetadata(context context,string uri){ uri queryuri = uri.parse(uri); // relevant columns use later. string[] projection = { mediastore.files.filecolumns._id, mediastore.files.filecolumns.data, mediastore.files.filecolumns.date_added, mediastore.files.filecolumns.media_type, mediastore.files.filecolumns.mime_type, mediastore.files.filecolumns.title }; // return video , image metadata. string selection = mediastore.files.filecolumns.media_type + "=" + mediastore.files.filecolumns.media_type_image + &quo