Posts

python - Ineq and eq constraints with scipy.optimize.minimize() -

i attempting understand behavior of constraints in scipy.optimize.minimize : first, create 4 assets , 100 scenarios of returns. average returning funds in order best worse d > b > > c #seed first np.random.seed(1) df_returns = pd.dataframe(np.random.rand(100,4) - 0.25, columns =list('abcd')) df_returns.head() b c d 0 0.167022 0.470324 -0.249886 0.052333 1 -0.103244 -0.157661 -0.063740 0.095561 2 0.146767 0.288817 0.169195 0.435220 3 -0.045548 0.628117 -0.222612 0.420468 4 0.167305 0.308690 -0.109613 -0.051899 and set of weights weights = pd.series([0.25, 0.25, 0.25, 0.25], index=list('abcd')) 0 0.25 b 0.25 c 0.25 d 0.25 we create objective function: def returns_objective_function(weights, df_returns): result = -1. * (df_returns * weights).mean().sum() return result and constraints , bounds cons = ({'type': 'eq', 'fun...

httprequest - Get referrer URL with parameters in Rails -

i have site basic rails scaffold, when user deletes record default action redirect home page. return list user looking at. right i'm using request.referrer technically getting referral url parameters not included... in rails logs can see "started /books/book_preview?name=hunger+games" request.referrer shows " https://x.x.x.x/books " have tried .original_url , .original_fullpath return path of current page record "/books/hungergames". tried uri(request.referrer).query @ least parameters threw error. previous path parameters like: /books/books_preview?name=hunger+games also list remote partial rendered through js. can't see url in browser url bar when highlight on or in rails logs. doesn't show in request when looked through using request.inspect . thanks in advance help! have been stuck on day! you're not getting query string url, according this answer (& docs ), need: request.fullpath #-> book_preview?na...

android - Cannot find method onClick in the Activity even though it is there -

i have made button: <button android:id="@+id/btn_dialog" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/showdig" android:onclick="onclick" /> and onclick method in main activity public void onclick(view v){ log.d("click test", "log"); this.showdialog(0); } but when click button get: 03-12 16:37:24.995: e/androidruntime(755): fatal exception: main 03-12 16:37:24.995: e/androidruntime(755): java.lang.illegalstateexception: not find method onclick(view) in activity class com.example.telefon.mainactivity onclick handler on view class android.widget.button id 'btn_dialog' 03-12 16:37:24.995: e/androidruntime(755): @ android.view.view$1.onclick(view.java:2670) 03-12 16:37:24.995: e/androidruntime(755): @ android.view.view.performclick(view.java:3110) 03-12 16:37:24.995: e/a...

php - Implement secure login in Codeigniter test with Wireshark -

today try test website build codeigniter. try check using wireshark (for network administrator). in traffic, still see username , password login. maybe ideas solve problem. maybe else have problem too. here controller public function val() { $this->form(); if($this->form_validation->run()==false) { $this->load->view('form_login_val'); }else { $username = $this->input->post('username'); $password = $this->input->post('password'); $cek = $this->m_login->takevalidator($username, $password ); if($cek <> 0) { $this->session->set_userdata('validator_status', true); redirect('home/validate'); } else { $this->session->set_flashdata('gagal_login', "username atau password yang anda masukkan salah...

Do-while loop to erase cells with certain values in Excel -

i want delete cells have '+' , '-' in d column. i've tried following macro, thought work, nothing happens. sub dowhile4() 'replace blank spaces underscores in range of cells, using vba loops; or 'remove blank spaces in range of cells, using vba loops. dim icell range dim textstring string dim n integer 'icell cell in specified range contains textstring 'textstring text in cell in blank spaces replaced 'underscores. n position of blank space(s) occurring in textstring each icell in activesheet.range("d2:d34") textstring = icell n = instr(textstring, "+") 'the vba instr function returns position of first occurrence of string within 'another string. using determine position of first blank space in 'textstring. while n > 0 textstring = left(textstring, n - 1) & right(textstring, len(textstring) - n) 'this line of code remove blank spaces in...

hibernate - onetomany unidirectional with jointable setup using jpa -

i have 2 entities namely customer , order in onetomany relationship. 1 customer can have multiple orders. since needed relationship unidirectional, using jointable. i able add entries customer entity using jpa. able add entries order entity using jpa. i wondering how connect 2 data. let's have 1 entry in customer table , 2 entries in order table. associate these 2 entries in order table 1 entry in customer table. currently, don't see entries in jointable customer_order. how make association? guess while adding orders order table, have mention customer id number somehow. not sure how that. there criteria query in jpa? thanks. customer class - @entity public class customer implements serializable { @id @generatedvalue(strategy = generationtype.table, generator = "generatorcustomer") @tablegenerator(name = "generatorcustomer", allocationsize = 1) @column(name="customer_id") private long id; public long getid() {...

r - Color mismatch using rgl -

i using rgl create scatterplot of points imported .csv dataset. colors i'd points set in dataset. works fine, except when scatterplot displayed colors of points not match colors defined in data. e.g., points designated "blue" might green, , points designated "yellow" might show red. data=read.csv("explayout.csv", header = true) x=data$x y=data$y z=data$z color=data$color plot3d(x=x, y=y, z=z, type="s", col=color) this due read.csv converting strings factors see difference in reproducible example library(rgl) x<-1:5 y=1:5 z <- 1:5 colors <- c('red','green','blue','orange','purple') plot3d(x=x,y=y,z=z,col=colors, type = 's') colorsf <- factor(c('red','green','blue','orange','purple')) plot3d(x=x,y=y,z=z,col=colorsf, type = 's') so, either read in color character column using stringsasfactors=false or coerce char...