Posts

Showing posts from July, 2012

ruby on rails - Is it correct architecture for adding user's posts? -

create action in posts controller: def create @post = current_user.posts.build(post_params) if @post.not_exists?(current_user) if @post.save #flash redirect_to root_path else #flash[:error] redirect_to root_path end else #flash[:error] redirect_to root_path end end post model: class post < activerecord::base belongs_to :user ##validations def not_exists?(user) return true unless user.posts.find_by(name: self.name) end end my question: correct build create action this? or there better architectural design? think fat action. why not use validation instead ? class post < activerecord::base belongs_to :user validates_uniqueness_of :name, :scope => :user_id

android - How can I make HttpClient works faster? -

i have application posts , gets php , mysql server. used function actions took 5 seconds. used httpparams didn't work, too. is there way make faster? string responsebine(){ log.d("destpek wext",""); try{ httpclient httpclient = new defaulthttpclient(); httpget httpget= new httpget(urlindex); if(logged) { httpresponse rs = httpclient.execute(teketin.httppost, localcontext); entityutils.tostring(rs.getentity()); rs = httpclient.execute(httpget, localcontext); entityutils.tostring(rs.getentity()); } responsehandler = new basicresponsehandler(); string rsp = new string(httpclient.execute(httpget, responsehandler).getbytes("iso-8859-1"),"utf-8"); return rsp; }catch(exception e){ system.out.println("exception : " + e.getmessage()); } log.d("destpek wext",""); return "&qu

html - CSS/JavaScript: Liquid Design issue -

i'm trying make website similar one. on website use javascript change padding on first section keep in windows viewport. have done this, have issue making button move way theirs move when window size changed. see video below, when make height smaller (to extent) button should move up, on copy doesn't can't figure out how have done it. video below shows css code , html , no values seem changes javascript make button move, does, padding of element doesn't change 96. youtube video edit: code far, html: <body> <div class="container"> <section id="header" class="arrows" style="padding:280px 0px"> <header> <h1>mobile paint solutions</h1> <p>since 1980</p> </header> <footer> <a onclick="test()" href="" class="button white">about</a>

java - Thread safe access to arraylist: two producer one consumer. Lock object is enough? -

i have 2 thread can produce value , add in arraylist, , other thread can access read value. my problem producer can access list in same time consumer use data. this code : public class commandtree { lock lock = new reentrantlock(); arraylist<command> cmdtosend = null; jsonobject sendcmdmap; public commandtree(jsonobject sendcmdmap) { this.cmdtosend = new arraylist<command>(); this.sendcmdmap = sendcmdmap; } private synchronized void addmacrocmd(string macro, int fmt, int tgt, int sid,int count,jsonarray sli,string paramname,jsonobject params,int function) { boolean check = false; int = 0; lock.lock(); try { for(i=0; i<cmdtosend.size(); i++) { if(cmdtosend.get(i).getmacroname().equalsignorecase(macro)) { check = true; break; } } if(check == false) { cmdto

javascript - Log how many people visited my site? -

is possible find out, how many people have visited website? javascript or html. if user on website, should count +1 or sth that. have no idea , have not tried yet. guys :) try use code in php: <? session_start(); $today = time(); $query="insert logged_in (today, sessionid, currentpage, browsertype, ip) values ('".$today."','".$_session['sesid']."','".$_server['php_self']."','".$_server['http_user_agent']."','".$_server['remote_addr']."')"; $result = mysql_query($query); ?> but need logged_in table. hope you!

c# - Dynamically adjust ListView height on adding / removing items? -

Image
i have 3 level nested listview binded same 3 level nested collection. mainitems added @ 3rd level. unmodified, there scrollbars on all levels. on item added, edit containing grid of listviewitem adjust height dynamically. i have succeeded on removing 3rd level scroll bar . however, want remove 2nd level also, can't seem do. when try adjust height of 1st level listviewitem , scrollbars on 1st level disappears height not adjusted @ all. what want only have scrollbar on 1st level , scroll there. basically, this: this current code: <grid x:name="parentgrid"> <listview x:name="level1listview" itemssource="{binding path=level1}"> <listview.itemtemplate> <datatemplate> <grid x:name="gridlevel1"> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="*"

oracle - Object not exists error while using TABLE expression -

here code: quite straight forward.. create or replace package types type rec record ( employee_id number, fname varchar2(20) ); type tab_rec table of rec; type tab_numbers table of number; type tab_chars table of varchar2(10); end types; / create or replace function get_employees_rec ( o_error_msg in out varchar2, l_access_tab out types.tab_chars ) return boolean --o_access_tab types.tab_chars; cursor c_rec select first_name employees; begin open c_rec; fetch c_rec bulk collect l_access_tab; close c_rec; return true; exception when others o_error_msg:=substr(sqlerrm,1,100); return false; end; / declare o_error_msg varchar2(100); l_access types.tab_chars; begin if get_employees_rec(o_error_msg,l_access)=false dbms_output.put_line('got you'); end if; rec in(select * employees e,table(l_access) f value(f)=e.first_name) loop dbms_output.put_line(rec.first_na

c# - Read Barcode in an WP8.1 app with ZXing -

im writing first app wp8.1. app need scan barcode. public async void scanbarcodeasync(windows.storage.storagefile afile) { writeablebitmap bitmap; bitmapdecoder decoder; using (irandomaccessstream str = await afile.openreadasync()) { decoder = await bitmapdecoder.createasync(str); bitmap = new writeablebitmap(convert.toint32(decoder.pixelwidth), convert.toint32(decoder.pixelheight)); await bitmap.setsourceasync(str); } zxing.barcodereader reader = new barcodereader(); /*reader.options.possibleformats = new zxing.barcodeformat[] { zxing.barcodeformat.code_128, zxing.barcodeformat.code_39 };*/ reader.options.tryharder = true; reader.autorotate = true; var results = reader.decode(bitmap); if (results != null) { edtbarcode.text = results.text;

c++ - OpenCV 3.0.0 with cmake - where are the includes/libraries -

Image
i compiled opencv 3.0.0 tbb using cmake , unsure include , library directories (for vs 2012). followed these instructions, library not in folder mentioned in "set environment path" blurb (which copied earlier version). am right in assuming relevant folder "opencv/build" , "opencv/source" no longer plays role new projects? are needed includes , libraries in "opencv/build/install/include" , "opencv/build/install/x86/lib/vc11/lib" respectively? added those, corresponding additional dependancies - program #include "opencv2/opencv.hpp" int main( int argc, char** argv ) { cv::mat src = cv::imread( "c:\\pics\\test.tif",0); cv::imshow("end",src); return 0; } compiles, crashes saying: the program can't start because opencv_core300.dll missing computer. try reinstalling program fix problem. what reason? then need specify libraries in linker should into. go linker ‣ input , u

asp.net mvc - Use Ajax.Beginform to send multipart/form-data -

i trying post multipart/form-data web api in view. code of view is: @{ viewbag.title = "upload"; } <h2>upload image</h2> <div> @using (ajax.beginform(null, null, null, new ajaxoptions { httpmethod = "post", url = "http://localhost:59650/api/ingestion/upload", onsuccess = "onsuccess", onfailure = "onfailure", onbegin = "onbegin" }, new { enctype = "multipart/form-data" })) { <div> <ol> <li> <input type="file" name="fileupload" /> </li> <li> @html.label("sheetname: ") @html.textbox("sheetname") </li> <li> @html.label("columns: ") @html.textbox("columns") </li> <li> @html.label("f

python - Remove symbolic link to development version -

on pandas developers page says describes how work development version of pandas. it mentions python setup.py develop allow use development environment: this makes symbolic link tells python interpreter import pandas development directory. thus, can using development version on system without being inside clone directory. it doesn't symbolic link created, nor mention how "undo" operation. had quick in setup.py couldn't find symbolic link created. so if run python setup.py develop how can using release version of pandas? you can remove symlink created using python setup.py develop via: python setup.py develop --uninstall as symlink itself, it's not strictly symlink rather normal file .egg-link extension. created in site-packages folder of python installation used run python setup.py develop . using virtualenv named my_test_virtualenv, mine created @ /home/chuck/.virtualenvs/my_test_virtualenv/lib/python2.7/site-packages/pand

vba - Connect from Excel to Access database on internet server -

i hope able me out following. have excel based tool able retrieve , upload data (via ado) access database. works fine, need use on server approached via internet. running macro not work more giving me run time error: 'your network access interrupted'. use following connection string: pad = activeworkbook.path xdatabase = pad & "\rolling forecast database.accdb" stdb = xdatabase stconn = "provider=microsoft.ace.oledb.12.0;" _ & "data source=" & stdb & ";" although see people encounter same problem not sure causes macro not function more. has fact server not local? solutions problem? grateful swift response, cheers michiel you use hivelink ( https://hivelink.io ) this.. it turn spreadsheet live service , need computer running time have original spreadsheet. hivelink create "lightweight" spreadsheet users can use anywhere, doesn't have macros or calculations. person using a

html - Minimal Responsive Menu (Pure CSS) in not working on android default browser -

i use minimal responsive menu (pure css) in project navigation menu. http://codepen.io/nickisix/pen/julqa i test navigation in useful browser. results in google chrome, mozilla firefox , opera ok, in android (4.2) default browser when click on ≡, nothings happened. how can fix this? i think you've forgotten <meta name="viewport" content="width=device-width, initial-scale=1.0"> in head. tells device use media queries, included in css. may fix problem.

osx - SpriteKit Music & Sound FX Management -

in spritekit, texture atlases great tool when comes managing art assets. there equivalent managing sound files? in game have lot of short sound fx , music files longer , looped. i've decided on creating class purpose called audioengine , can't decide upon how store sounds in project. should keep track of them in plist of sort or scan .caf, .wav, etc files? i'm sorry if sounds opinion based question, i'd know best practices this.

Can I use Firefox developer toolbar commands in my addon? -

i developing firefox addon making fullpage screenshots of web pages. know several addons available, have specific needs thought try make own. i read can screenshot --fullpage in firefox developer toolbar . seems works well. can call command within addon? if so, how go that?

php - What is the best practise for loading extra JavaScript in the footer? -

every page of website consist of: generic header the page itself generic footer in code page looks this: <?php require_once('header.php'); load_header('title', 'meta description'); // loads menu ?> // unique content of page <?php // footer settings $load_contact_info = true; // load footer require_once('footer.php'); load_footer($load_contact_info); ?> on same pages load content (like more js libraries) in footer.php (right before - closing body tag): <?php function load_footer($load_contact_info = false) { ?> <footer> <?php if ($load_contact_info) { ?> <div id="contact-us"> // contact info </div> <?php } ?> <div id="inner-footer"> // more generic footer content </div> </footer> <script src="<?php echo($url); ?>js/vendor/jquery.js"></script> // want load more unique js co

bit manipulation - Python How to get set bit -

say have number in memory looks (or similar, don't know how python stores numbers): 0000 0000 0000 1000 i want bit set (thanks @muddyfish, clarify these numbers have 1 bit set), in case 3, because 2^3 = 8. use log2 achieve this, seems solved 'bit twiddling' techniques. loop through bits this: def getsetbit(num): if num == 0: return -1 bit = 0 while num != 1: bit += 1 num >>= 1 return bit # getbitset(0b100000) == 5 # getbitset(1) == 0 however me seems awkward , slower should be. if way this, guess live it, if wasn't. to bit number of highest bit set, use int.bit_length()-1 this more efficient using math.log() or other function had posted edit: as requested, timeit results posted: python -m timeit -s 'import math;x=100' 'int(math.log(x,2))' 1000000 loops, best of 3: 0.5 usec per loop python -m timeit -s 'i = 100' 'i.bit_length()-1' 10000000

bash - if grep statement never returning true, always returns 'no such file or directory' -

i have been tasked writing method counts number of red ford fiestas in list of cars, outputs number .txt file, without using -c option in grep numbercars=0 while read car echo $car if grep -e ford\:fiesta.*red $car; echo "-------done------" (($numbercars++)) fi done < $userinput echo $numbercars > output/fiesta_red.txt the first echo $car works, know while loop working correctly. however, each if grep returns details of car followed " no such file or directory ". have tested, each if returning false, regardless of whether pattern i'm searching exists or not for reference, example of how carslist.txt formatted: peugeot:206:2000:black:1 ford:fiesta:2000:red:2 possible solution test pattern [[ $car =~ ford\:fiesta.*red ]] && echo "-------done------" && (($numbercars++))

c# - Change color of LineSeries -

hoping can help. i've spent 4hrs far trying examples i've found on forums no avail. below xaml code; think there a simple way insert parameter set color, i've not found 1 works. i've tried code behind; examples i've found not change anything. <grid> <charting:chart name="linechart" title="stock" verticalalignment="top" margin="0,10,10,0" height="550"> <charting:lineseries name="price" title="price" dependentvaluepath="value" independentvaluepath="key" itemssource="{binding [0]}"

r - Edit row and col names in Pheatmap -

Image
i want edit row , col names in pheatmap or delete , add new row , col names edited. in case set show_colnames , show_rownames false . library("pheatmap") pheatmap(scale(dat), show_colnames = t, show_rownames = t,legend = true, cluster_rows=f, cluster_cols=f, border_color = "grey60") can me thanks. you can use labels_row , labels_col parameters. > set.seed(1) > mat <- matrix(rnorm(100), 10, 10, dimnames=list(letters[1:10], letters[11:20])) > pheatmap(mat) > pheatmap(mat, labels_row=paste0("foo", 1:10), labels_col=paste0("bar", 1:10)) alternatively can modify rownames / colnames of matrix pass pheatmap function. library(magrittr) mat %>% set_rownames(paste0("foo", 1:10)) %>% set_colnames(paste0("bar", 1:10)) %>% pheatmap()

amazon web services - DynamoDB UpdateItem Doesn't Work -

this pretty straight out of documentation ( http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/expressions.modifying.html ), things aws, doesn't work , isn't documented @ all. the following fails "the document path provided in update expression invalid update" var messageid = "f244ed33-d678-4763-8f46-0f06514d5139" var sequenceid = "00000000-0000-0000-0000-000000000000" var = datetime.utcnow; var lastactivitythreshold = now.subtract(timespan.fromseconds(10)); var response = client.updateitem(new updateitemrequest { tablename = "thetable", key = new dictionary<string, attributevalue> { { "sequenceid", new attributevalue { s = sequenceid } } }, expressionattributevalues = new dictionary<string, attributevalue> { {":messageid", new attributevalue {s = messageid}}, {":now", new attributevalue {n = now.ticks.tostring()}}, {":lastactivit

java - Make a list and initialize it to include all the values of an Enum -

i have enum direction , want make temporary list of values of enum , able remove or add values list. public enum direction { top, right, bottom, left } list<direction> directions = arrays.aslist(direction.values()); directions.remove(0); // error directions.add(direction.bottom); // error with current code, when remove element @ 0, or if add element, run time exception java.lang.unsupportedoperationexception . suppose way list immutable ? how can ? arrays#aslist returns list doesn't support add or remove elements since wraps array. instead, create new arraylist , pass result of arrays#aslist parameter: list<direction> directions = new arraylist<>(arrays.aslist(direction.values()));

javascript - Polymer 1.1 Paper-Header-Panel Breakage in Template -

with polymer 1.1, having 2 issues paper-header-panel i can't not content below panel show i can't height: 2000px; applied div can have scrolling bar have waterfall effect. i using https://github.com/polymerelements/paper-header-panel/blob/master/demo/index.html example go by. after doing trouble shooting div id="maincontainer" 0 height. if remove flex class, height applied. breaks scrolling waterfall effect. <dom-module id="custom-paper-header-panel"> <template> <style> #foobar { height: 2000px; } </style> <paper-header-panel mode="waterfall-tall"> <paper-toolbar> <div class='title'></div> <paper-tabs> <paper-tab> <div>contact</div> </paper-tab> </paper-tabs> <div class='title bottom'> <h1 id="name-title">

Unable to refer external module in TypeScript -

i want use external module in typescript code, failing. specifically, want use methods referring external.d.ts file in typescript script. my code is: module test { //this not working. want know syntax refer express here. private express: typeof express = require("express"); export testserver { constructor(private app:express.application) { //can not find express symbol } } //this not working. want know syntax refer express here. private express: typeof express = require("express"); use import : import express = require("express"); export testserver { constructor(private app:express.application) { } } and don't mix internal , external modules. more in youtube video typescript modules demystified: internal, amd requirejs, commonjs node.js .

javascript - How do I activate this HTML class in Wordpress -

i have web tool plugin in wordpress need active class disables selection. here link: https://sotogloves.com/product/customization-tool/?gd_nonce=24e370d2e1 this line disables functionality: class="mspc-menu-item disabled" how delete "disabled" portion have functionalities active? one way in js file: $(document).ready(function() { $('.mspc-accordion a').click(function() { $(this).removeclass('disabled'); }); }); here's example: https://jsfiddle.net/z8aurqc1/3/

angularjs - Two controllers depending on same data returned asynchronously -

there app allows users create or join rooms. there roomslistcontroller displays rooms, roomdetailscontroller shows contents , controls activity inside particular room. , of cause, roomservice provides getrooms() (async) method. now angular way make 2 controllers wait same data returned roomservice.getrooms() ? details: there authentication in app , list of rooms depend on userid. calling roomservice.getrooms() @ application start not option roomdetailscontroller doesn't request list of rooms. whenever room provided via $stateparams exists , active displayed. if not, there logic guides user room (here list of rooms required) or displays message no rooms available , perhaps it's time create one. let's assume getrooms() heavy operation server , it's not desired twice when same data on client can reused. it's desired have logic doesn't depend 1 controller function executed first, can influenced layout update in template take @ route r

exception - return inside an except python -

what problem when including function inside except? in case have following function: def inventedfunction(list1): print "initial list %r" %list1 creates list2 based on list1 try: list2[1] print "inside try %r" %list2 inventedfunction(list2) except: print "inside except %r" %list2 return list2 after running inventedfunction(somelist) seems working: initial list [3, 562, 7, 2, 7, 2, 3, 62, 6] inside try [[3, 562], [2, 7], [2, 7], [3, 62], [6]] initial list [[3, 562], [2, 7], [2, 7], [3, 62], [6]] inside try [[2, 3, 7, 562], [2, 3, 7, 62], [6]] initial list [[2, 3, 7, 562], [2, 3, 7, 62], [6]] inside try [[2, 2, 3, 3, 7, 7, 62, 562], [6]] initial list [[2, 2, 3, 3, 7, 7, 62, 562], [6]] inside except [[2, 2, 3, 3, 6, 7, 7, 62, 562]] but not returning anything. if include return list2 outside except returns [[3, 562], [2, 7], [2, 7], [3, 62], [6]] not [[2, 2, 3, 3, 6, 7, 7, 62, 562]] want.

python - Making a faster wavelet transform/Appending data faster -

i taking 1-d wavelet transform of data. how can make faster? have 1.4 million samples , 32 features. def apply_wavelet_transform(data): ca,cd=pywt.dwt(data[0,:],'haar') in range(1,data.shape[0]): ca_i,__=pywt.dwt(data[i,:],'haar') ca=np.vstack((ca,ca_i)) return ca consider don't care memory usage as speed of execution. this common mistake. don't want append rows array 1 @ time, because each iteration requires copying entire array. complexity: o(n**2). better keep intermediate results in list , form array @ end. better because lists not require elements contiguous in memory, no copying required. def apply_wavelet_transform(data): results_list = [] row in data: ca, cd = pywt.dwt(row, 'haar') results_list.append(ca) result = np.array(results_list) return result

perl - Extract the string in each line in a text file and count the occurrence of that string in the file -

i have log file sample output below. want extract value of string starting k= in each line using perl , count frequency of string in full log file. threaddistributor dispatch k='/678605358297;type=f', i=2 threaddistributor dispatch k='/678605358297;type=w', i=0 threaddistributor dispatch k='/678605358297;type=w', i=1 expected result: k='/678605358297;type=f' occurs 1 times k='/678605358297;type=w' occurs 2 times this have tried far: use test::more qw(no_plan); use strict; use warnings; use data::dumper; $data::dumper::sortkeys=1; @key; @keystrings; open (infile, "1.txt") or die "error:cannot open test result file $!"; foreach $line (<infile>) { @key = split(' ',$line); push @keystrings, $key[2] } print "$key[2]\n"; %counts; $counts{$_}++ @keystrings; print dumper(\%counts); close infile; use regular expression grab string care about, , hash count occurrences. save

html - Centering an article tag -

Image
i trying center content of html article element. content aligns left margin of page. here html using: <article> <h1>sign in</h1> <div class="display-new"> <form action="" method="post"> <div class="label-field"> <label for="email">email: </label> <input type="text" name="email" /> </div> <div class="label-field"> <label for="password">password: </label> <input type="password" name="password" /> </div> <input type="submit" value="sign in" class="submit-button"/> </form> </div> <div class="forgotten-password"> <a href="../index.php?action=resetpassw

ios - different methods on one standard headCell in func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ -

i have 2 tableviews in same view controller: "studentstable" , "professorstable". wanted create standard head cell both tables. subclassed uitableviewcell , created headcell type. assigned 1 headcell both if indexpath.row==0. went smooth, however, there 1 problem. whenever click "addingbutton" want "addstudent" function called if on "studentstable" , "addprofessor" if on "professorstable". can create 2 headcells, 1 each of tables wonder if there more professional way of handling writing less code. here code suppose may work if right "if" condition given. in advance func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell{ var actiontype:string=string() if(/*what condition should put?*/) {actiontype="addstudent"} else {actiontype="addprofessor"} if(indexpath.row==0) { var theheadce

jung2 - jung-visualization build fails -

i'm having issue compiling guava branch of jung found here . jung-visualization's pluggablerendercontext.java has compile error. appears problem has come before visible this google search , link redirects jung github repository. i've cloned github repository local machine , imported maven project eclipse. when running goals "clean install" following output when building jung-visualization. [info] ------------------------------------------------------------------------ [info] building jung-visualization 2.0.2-snapshot [info] ------------------------------------------------------------------------ [info] [info] --- maven-clean-plugin:2.5:clean (default-clean) @ jung-visualization --- [info] [info] --- maven-resources-plugin:2.6:resources (default-resources) @ jung-visualization --- [warning] using platform encoding (utf-8 actually) copy filtered resources, i.e. build platform dependent! [info] skip non existing resourcedirectory /users/eric/documents/

javascript - Merging the cell using button in handsontable -

in handsontable, can merge cell pressing ctrl + m . want merge cell in handsontable using button. not in coding, suggestion or appreciated. <script> document.addeventlistener("domcontentloaded", function() { var container = document.getelementbyid('maintable'), hot; hot = new handsontable(container, { data: handsontable.helper.createspreadsheetdata(50, 26), minrows: 5, mincols: 6, rowheaders: true, colheaders: true, mergecells: true, currentrowclassname: 'current row', currentcolclassname: 'current col' }); hot.selectcell(2,2); function binddumpbutton() { if (typeof handsontable === "undefined") { return; } handsontable.dom.addevent(document.body, 'click', function (e) { var element = e.target || e.srcelement

Not getting Email Address from linkedin I can use jar file but emailaddress is null? -

accesstoken=linkedindialog.oauthservice.getoauthaccesstoken(linkedindialog.litoken,verifier; linkedindialog.factory.createlinkedinapiclient(accesstoken); client = factory.createlinkedinapiclient(accesstoken); person profile = client.getprofileforcurrentuser(enumset.of( profilefield.id, profilefield.first_name, profilefield.email_address, profilefield.last_name )); your code doesn't show don't know if issue or not, access email address requires request r_emailaddress member permission in oauth scope when request auth token. check code , ensure you're asking permission.

numpy - How calculate the Error for trapezoidal rule if I only have data? (Python) -

i got array of data , need calculate area under curve, use numpy library , scipy library contain functions trapz in numpy , integrate.simps in scipy numerical integration gave me nice result in both cases. the problem is, need error each 1 or @ least error trapezoidal rule. thing is, formula ask me function, don't have. have been researching way obtain error return same point... here pages of scipy.integrate http://docs.scipy.org/doc/scipy/reference/integrate.html , trapz in numpy http://docs.scipy.org/doc/numpy/reference/generated/numpy.trapz.html try , see lot of code numerical integration , prefer use existing ones... any ideas please? while cel right cannot determine integration error if don't know function, there can do. you can use curve fitting fit function through available data points. can use function error estimation. if expect data fit kind of function sine, log or exponential use basis curve fitting. for instance, if measuring dra

Xamarin Shared Library and PCL -

what exact difference between xamarin shared project , portable class library? when use shared library , when use portable class library? is possible write native functionality in shared projects showing alert,accessing camera , use both android , ios? can please explain me. in shared projects each code file compiled each destination (android, ios, windows phone etc). able include platform specific code using #if compiler directives. when want access camera need write access code inside #if block destinated platforms. can mess code can easier find different implementations. learn more: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/shared_projects/ protable class libraries (pcl) compiled against general .net subset compatible platforms want. can access system.net.http cannot access platform specific code. if want access camera inside pcl code need access generalized interface via dependency injection. there pretty frameworks help

c# - Performance evaluation of Web API calls with Database LINQ queries -

i have ui calls webapis (webapi 2.0), web api linq queries (to ms sql database) , processing logic data. want performance evaluation of complete flow (click ui api, ui display data) upon huge db 30k - 60k records in it. how can done? let me know methods/tools used this. currently tracking time-taken in chrome debug window, shows total time each network call. wow. subject in own right here's approach: the bits independent break down. measure linq queries without of logic or web api stuff getting in way. if linq against stored procedures measure first. measure cost of logic, measure cost of sending x rows of data using webapi. should avoid including cost of retrieving rows database you're checking connectivity. i'd consider writing browserless test client (i.e. gets/posts or whatever) eliminate browser variable. now you've got picture of time gets spent. know if you've got db issues, query issues, network issues or application server issues

python - ImportError: The _imagingft C module is not installed -

i use django-simple-captcha in django. command: ./manage.py test apatcha shows error "importerror: _imagingft c module not installed" i install package in order below: yum install freetype-devel libjpeg-devel libpng-devel pip uninstall pillow pip uninstall pillow-pil pip install pillow pip install pillow-pil but still doesn't work. wrong? system:centos 6.5 python: _imagingft c module not installed the link above doesn't solve problem, otherwise won't here. finally, solve problem download tar.gz file official website , install manually. python: _imagingft c module not installed the link above doesn't solve problem, otherwise won't here. finally, solve problem download tar.gz file official website , install manually. by way, should paste hot links didn't solve problem prove did googled before ask?

ios - Implement custom Cancel Button in a SDK -

i want implement payment functionality paysbuy sdk....the problem doesnot have cancel option on user can cancel operation of close after payment has been successful. by default sdk provides method opens default webview covers whole part of screen..and there no cancel option.. i want add cancel button load payment on specific view ..or viewcontroller ..i tried using in container view..to load view inside container view , cancel button outside container view ,but when try process,it shows default in full screen webview .also tried creating popup didnot succeed so, how can load webview of sdk on specific portion of view can put cancel button?? this method sdk provides start service - (void) callservicewithcurrentview :(uiviewcontroller *) currentviewcontroller invoice:(nsstring *)invoice item:(nsstring *)item amount:(nsstring *)amount paypal_amount

videoview - Disable seekforward and seekbackward of mediacontroller android? -

i playing video url , want disable seekbar tracking of video. how can done. this code: videourl = "http://download.itcuties.com/teaser/itcuties-teaser-480.mp4"; videoview.setvideopath(videourl); mediacontroller = new mediacontroller(this, false); int topcontainerid = getresources().getidentifier("mediacontroller_progress", "id", "android"); seekbarvideo=(seekbar)mediacontroller.findviewbyid(topcontainerid); seekbarvideo.setenabled(false); mediacontroller.setanchorview(videoview); videoview.setmediacontroller(mediacontroller); the app crashes: seekbarvideo.setenabled(false); java.lang.nullpointerexception @ com.vfirst.offers.videobufferactivity.onclick(videobufferactivity.java:93) @ android.view.view.performclick(view.java:4575) @ android.view.view$performclick.run(view.java:18578) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmess

ios - How to return to your app using google callback url scheme in swift? -

i using gooogle url scheme show directions press of button in swift. how can use url callback scheme app, after have opened native google maps app. using below code if (uiapplication.sharedapplication().canopenurl(nsurl(string:"comgooglemaps://")!)) { uiapplication.sharedapplication().openurl(nsurl(string: "comgooglemaps://?saddr=&daddr=\(place.latitude),\(place.longitude)&directionsmode=driving")!) } else { nslog("can't use comgooglemaps://"); } } i have tried referring link google map url scheme if knows how it, pls answer sample swift code you can use openingooglemaps component provided google maps. lets encode redirect url app, displayed on top of directions in google maps application. this code looks in swift: var place: cllocationcoordinate2d var definition = googledirectionsdefinition() definition.destinationpoint = googledirectionswaypoint(location: pla

java - jna Pointer in 32 bit JRE -

i using jna call magnification api functions in java. magimagescalingcallback.java package jna.extra; import com.sun.jna.callback; import com.sun.jna.pointer; import com.sun.jna.platform.win32.windef.hrgn; import com.sun.jna.platform.win32.windef.hwnd; import com.sun.jna.platform.win32.windef.rect; public interface magimagescalingcallback extends callback{ public boolean magimagescalingcallback(hwnd hwnd, pointer srcdata,magimageheader srcheader, pointer destdata,magimageheader destheader,rect source,rect clipped,hrgn dirty); } magimageheader.java package jna.extra; import java.util.arrays; import java.util.list; import com.sun.jna.platform.win32.guid.guid; public class magimageheader extends com.sun.jna.structure { public int width; public int height; public guid format; public int stride; public int offset; public int cbsize; public list getfieldorder() { return arrays.aslist("width","height","format&