Posts

Showing posts from August, 2011

r - How to concatenate factors, without them being converted to integer level? -

i surprised see r coerce factors number when concatenating vectors. happens when levels same. example: > facs <- as.factor(c("i", "want", "to", "be", "a", "factor", "not", "an", "integer")) > facs [1] want factor not integer levels: factor integer not want > c(facs[1 : 3], facs[4 : 5]) [1] 5 9 8 3 1 what idiomatic way in r (in case these vectors can pretty large)? thank you. from r mailing list : unlist(list(facs[1 : 3], facs[4 : 5])) to 'cbind' factors, data.frame(facs[1 : 3], facs[4 : 5])

python - Can xgboost.DMatrix be silent by set "silent=True" -

i learning xgboost. want finish demonstration xgboost python api. when use function "xgboost.dmatrix" data set file,silent set true. however, function "xgboost.dmatrix" output message "[23:28:44] 1441x10 matrix 11528 entries loaded file_name". setting error parameters? reference this interesting. silent value taken , passed wrapper, seems wrapper doesn't use ! this shows appropriate code https://github.com/dmlc/xgboost/blob/master/src/c_api/c_api.cc#l202 which says: int xgdmatrixcreatefromfile(const char *fname, int silent, dmatrixhandle *out) { api_begin(); if (rabit::isdistributed()) { log(console) << "xgboost distributed mode detected, " << "will split data among workers"; } *out = new std::shared_ptr<dmatrix>(dmatrix::load(fname, false, true)); api_end(); } i.e. though silent argument, not used in functio...

amazon web services - ElastiCache doesn't show automated backups -

Image
we using aws elasticache , have configured automated backups. seems automated backups missing ui though. attaching following screenshot, idea why? bug on aws ui? there bug in aws ui to view backups: select filter all backups type automatic.large or type of instance , hit enter or using console: $ aws elasticache describe-snapshots --max-records 20

angularjs - Angular 2 - http get return wrong object -

i'm using @angular/http fetch data server, here code : private _currentpt: any; public phongtrodetailchange = new subject(); layphongtro(id: number): promise<any> { return new promise((resolve, reject) => { this.http .get(constants.apiurl + 'phongtro/' + id, { headers: constants.headers }) .map((resp: response) => resp.json()) .subscribe(resp => { console.log(resp); // if (!resp.result) { // this._currentpt = resp; // this.phongtrodetailchange.next(true); // resolve(resp); // } else { // this.handleerror('layphongtro', resp.result); // reject(resp.result); // } }, error => this.handleerror('layphongtro', error)); }); } when commented code that, property "tiencoc" of resp has right value means value 0, here picture of console.log https://i.stack.imgur.com/7oygw.png but when uncommented, value of "tiencoc" same property ...

html - Add to Cart button missing ID -

my add cart button on shopify front page not getting added cart. gives error when clicking:parameter missing or invalid: required parameter missing or invalid: id the form looks this: <form action="/cart" method="post" enctype="multipart/form-data" id="addtocartform" value="{{ item.variant.id }}"> <span id="productprice" class="h1 price" itemprop="price"> {{ current_variant.price | money }} </span> {% if product.compare_at_price_max > product.price %} <p id="compareprice" class="h3 price"> {{ current_variant.compare_at_price | money }} </p> {% endif %} <div class="form__row" style="margin-top: 10px"> <select name="id" id="productsele...

wordpress , problems with text blocks, they dissapear -

i'm beginner in wordpress,recently installed dokan plugin online shop, gave me problems , read solution add code add_action('wp_enqueue_scripts', 'mgt_dequeue_stylesandscripts',99); function mgt_dequeue_stylesandscripts() { if ( class_exists( 'woocommerce' ) ) { wp_dequeue_style( 'select2' ); wp_deregister_style( 'select2' ); wp_dequeue_script( 'select2'); wp_deregister_script('select2'); } } i using handy store template, put code in file "function", when use function, text-blocks stop working, literally disappear, , when remove code come again, how solve it? the above problem had errors when uploading banners , photos. the code of function this <?php /* plumtree functions , definitions */ /** contents: - additional image sizes. - google fonts site. - handy setup. - enqueue scripts , styles. - handy init sidebars. ...

can't compile a simple Cython program -

Image
i'm starting cython tutorial, available at: http://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html but, can not compile .pyx files: i wrote file containing print("hello world") , saved under hello.pyx then made setup.py file, containing: from distutils.core import setup cython.build import cythonize setup( ext_modules = cythonize("helloworld.pyx") ) then, cmd used command: $ python setup.py build_ext --inplace but i'm getting error - description in picture i've used pyximport module well, , got same error. i'm sure problem eazy fix, , know how! :) i useing python 3.4 on windows

html - Input element and CSS not working -

Image
i've been fighting input element , css. not in design. trying create that: my input inside form inside : <li> <form class="searchform" name="search" action="./index.cfm?p=128" method=post > <input type="text" name=search value="" style="color: #676767; background-color: #282828; line-height: 18px" size="10" maxlength="40" placeholder="search"> <input class="search_button" type=submit name="submitbutton1" value="search" id="submitbutton1"> </form></li> here css: @import url(http://fonts.googleapis.com/css?family=montserrat); body, html {height: 100%; margin: 0; font-size:16px;} body {font-family: arial;} header {width: 100%; background-image: url('img/top-bg.png'); background-repeat: repeat-x; background-color: #dfebf2; position: fixed; height: 70px; z-index:2;} aside {width: 270px; mi...

eloquent - laravel collective form database autoselect -

i have forms store data in db, next time when open page want autoselected values selected already {!! form::select('week_starts', [ 'monday' => 'monday', 'tuesday' => 'tuesday', 'wednesday' => 'wednesday', 'thursday' => 'thursday', 'friday' => 'friday', 'saturday' => 'saturday', 'sunday' => 'sunday' ]) !!} so need form check db (that's not problem) , if found in database example monday , tuesday these fields autoselected param selected=true any idea how that. tried <?php if... ?...

c++ - trouble checking for overlap in a 2-D array of chars -

i having trouble part of program takes dynamically allocated object called userrect , checks overlapping on array of chars arranged in shape of rectangle. other rectangles rect[0] , rect[1] randomly placed on imaginary grid in console window. rect[0] prints out '0' rect[1] prints out '1' userrect prints out '#' if no overlap present. userrect prints out '+' @ each char in array overlapping object. the object userrect movable w,a,s,d keys. supposed happen when user moves userrect object , overlaps rect object. each character overlaps replaced '+'. the program not printing '+' when userrect overlapping rectangle. can point out causing this? here sample of code: bool isoverlapping(rect const & r) const { return !(min.x >= r.max.x || max.x <= r.min.x || min.y >= r.max.y || max.y <= r.min.y); } int main() { srand(time(null)); // initialization rect * userrect; con...

list - getting undefined reference to a function in commonLISP -

i'm trying compile following code: (defun nextstates (st) "generate possible states" (setf n 0) (setf states-list (make-list 9)) (setf list-actions (possible-actions)) (loop x in list-actions (setf aux (nextstate st x)) (when (not(member aux (states-list) :test #'equalp)) (progn (setf (nth n states-list) aux) (setf n (+ n 1)) ) ) ) (values states-list) ) nextstate function , states-list list, both of defined. i'm getting "undefined reference states-list". don't know i'm doing wrong. appreciated renaming badly camel case lisp case i'm left this. (defun next-states (st) "generate possible states" (loop :for action :in (possible-actions) :for aux := (next-state st action) :then (next-state st action) :when (not (member aux states-list :test #'equalp)) :collect aux :into states-list :finally (re...

virtual reality - How do I use SteamVR_LoadLevel to fade between scenes in unity3d? -

i've got @ top, public gameobject maincamera and i've got within if statement, steamvr_loadlevel tempload = maincamera.getcomponent<steamvr_loadlevel>(); tempload.fadeouttime = 1f; tempload.fadeintime = 1f; tempload.trigger(); but i'm getting error when triggering if statement, coroutine 'loadlevel' couldn't started because the game object 'camera (head)' inactive! edit 1. figured out, should have made maincamera variable of type steamvr_camera , should have nullchecked tested being active , enabled. check state game object "camera (head)" in hierarchy window , active him

PHP DOM Parser parse html table -

how use php dom parser parse content of table, get: the username the mobilephone number the status so output of try extract be: randomusername - 0123456789 - active randomusername2 - 0987654321 - active this html try parse (some part of it): ... <div class="table tbl-process-mobile"> <div class="table-cn"> <div class="table-bd"> <table cellspacing="0" id="idd7"> <thead> <tr id="idd9"> <th scope="col"> <span>username</span> </th> <th scope="col"> <span>status</span> </th> <th scope="col"> <span>prefered number</span> </th> <th scope="col"> <span>action</span> </th> </tr> </thead> <tbody id=...

android - RecyclerView and Picasso images disappear after scrolling -

i didn't find answer here , here , here . i have activity shows list of posts (with or without images). when scroll down , scroll or refresh list using swiperefreshlayout of images may disapper. use recyclerview show list of posts , picasso load images. here adapter binding: @override public void onbindviewholder(itemviewholder holder, int position) { // <...> if (item.getphoto() != null) { picasso.with(context) .load(item.getphoto()) .into(holder.mpostphoto); } else { holder.mpostphoto.setimagedrawable(null); holder.mpostphoto.setvisibility(view.gone); } } i send http request posts , when have new data call postsadapter : public void addall(list<postresponse> items) { this.items.clear(); this.items.addall(items); notifydatasetchanged(); } in mainactivity: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setco...

ruby - rspec --init not working/ `mkd ir': Invalid argument - ./C: (Errno::EINVAL) -

i'm following codeschool's class on rspec . installing worked fine. made file called rspec-zombie project. fine. when tried rspec --init in powershell, got unholy error message. i'm under impression there supposed files made inside directory, aren't there. follows. c:\users\roman\the-odin-project\rspec-zombie> rspec --init create .rspec c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib/rspec/support/directory_maker.rb:17:in `mkd ir': invalid argument - ./c: (errno::einval) c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib/rspec/support/directory_maker. rb:17:in `block in mkdir_p' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib/rspec/support/directory_maker. rb:13:in `each' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib/rspec/support/directory_maker. rb:13:in `mkdir_p' c:/railsinstaller/ruby1.9.3/lib...

wordpress - Hide or replace text using jquery -

on this page can see text "0here" below breadcrumb. that text coming theme not have installed. suspect it's coming database because duplicated old db build new site. anyway, i'm trying hide/delete/replace "0here" or else appear on every page. i'm trying... <script> jquery(document).ready(function() { jquery(':contains("0here")').html().replace("0here", ""); }); </script> but not working. missing? try replace. dont think need html. works on selector. //use 1 of them jquery(':contains("0here")').replace("0here", ""); jquery(':contains("0here")').html(""); jquery(':contains("0here")').val(""); //if input or text area

Does new Firebase Auth for polymer have changing password process included? -

i can't find sign of methods reseting password or sending password reset email in new firebase-auth polymer 1.0 , above. can find if exists? need able complete sign in / procedure. i can see old version polymer 0.5 , older has methods documentation says it's polymer 0.5 , older. any appreciated. i believe can use standard firebase user methods directly on firebase-auth's user property. ie like: <firebase-auth user="{{user}}"></firebase-auth> <script> this.$.user.updatepassword(newpassword); </script> & of course following requirements function specified in https://firebase.google.com/docs/reference/js/firebase.user.html#updatepassword

c# - Line chart with two series based on single column values -

Image
i want build line chart based on table: each different kpiname has own line on chart. how should this? tried this: foreach (kpi_pg kpi in _pg.kpi_pg) { series currentpg = new series(kpi.kpiname); chrt_pgbyyear.series.add(currentpg); currentpg.charttype = seriescharttype.line; currentpg.borderwidth = 3; currentpg.xvaluetype = chartvaluetype.string; currentpg.xvaluemember = "year"; currentpg.yvaluetype = chartvaluetype.int32; currentpg.yvaluemembers = "value"; } but doesn't work because of same chart name. series names must unique. should check if series exists , if don't add it. otherwise add series. private void createnewseries(string seriesname) { if(chrt_pgbyyear.series.isuniquename(seriesname)) { series currentpg = chrt_pgbyyear.series.add(seriesname); currentpg.charttype = seriescharttype.line; currentpg.borderwidth = 3; currentpg.xvaluetype = chartvaluetype....

javascript - Dropdown menu move elements -

is there way make dropdown menu move diagonal if submenu opened? menu moves , down can see http://jsfiddle.net/lthgy/1280/ add curved picture next since moves , down, crashes picture $(document).ready(function(){ $("#menu > li > a").on("click", function(e){ if($(this).parent().has("ul")) { e.preventdefault(); } if(!$(this).hasclass("open")) { $("#menu li ul").slideup(350); $("#menu li a").removeclass("open"); $(this).next("ul").slidedown(350); $(this).addclass("open"); } else if($(this).hasclass("open")) { $(this).removeclass("open"); $(this).next("ul").slideup(350); } }); }); sure -- can rotate dropdown box transform #menu { transform: rotate(45deg); } can added css achieve this. http://jsfiddle.net/lthgy/1281/ edit: comment regarding having elements re...

.htaccess redirect my site gives internal error -

i trying first time make .htaccess file. @ start make redirect, if person writes: https://example.com/robots.txt the person redirected https://example.com i made file, , added following code: redirect 301 https://example.com/robots.txt/ https://example.com/index.php i tried with: redirectmatch 301 ^/bonus https://example.com/robots.txt redirectmatch 301 ^/ https://example.com/ which both resulted in site got internal error. how correct way that? i'm not 100% sure why want direct away robots.txt file stop search engine crawlers accessing file... can using this: redirect 301 /robots.txt /index.php or, try this: redirect 301 /robots.txt https://www.example.com/ to rid of www use this: rewriteengine on rewritecond %{http_host} ^www.example.com$ [nc] rewriterule ^(.*)$ http://example.com/$1 [r=301,l]

PostgreSQL, can't set default value using ALTER COLUMN SET DEFAULT -

i want set default value existed column of integer type in table. according postgresql doc should use following statement: alter [ column ] column_name set default expression therefore sql statement looks this: alter table users alter column board_consecutive_share_days set default 0; after issued command nothing happened, default value was't set column: ownpleasuretestdb=# select board_consecutive_share_days users; board_consecutive_share_days ------------------------------ (3 rows) so, please tell me wrong in sql statement? you've set default column. means, whenever insert new row table, if omit column, default value used. for example, if create table so: create table foo (a int, b int default 0); then can issue: # insert foo values (1, 2); # insert foo (a) values (2); # select * foo; ---+--- 1 | 2 2 | 0 (2 rows) if, on other hand, want set existing values 0, can update statement. work: update users set board_consecutive_sh...

Customize non form errors with django crispy form -

i customize way django crispy shows non form error. know how change text, don't know change css. this image: my login area forms.py class loginform(forms.form): alphanumeric = regexvalidator(r'^[0-9a-za-z]*$', 'only alphanumeric characters allowed.') username = forms.charfield(label='', required=true, widget=forms.textinput(attrs={'placeholder': 'username'})) password = forms.charfield(label='', required=true, widget=forms.passwordinput(attrs={'placeholder': 'password'})) name = forms.charfield(label='', required=true , validators=[alphanumeric], widget=forms.textinput(attrs={'placeholder': 'name'})) def clean(self): username = self.cleaned_data.get('username') password = self.cleaned_data.get('password') user = authenticate(username=username, passwo...

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 6, and there are 5 supplied -

this question has answer here: programming error: incorrect number of bindings supplied 2 answers i not understand doing wrong. table is: conn.execute('''create table users (email text not null, password text not null, first_name text not null, last_name text not null, date text not null, sex text not null);''') and when trying insert table: conn.executemany("insert users values (?, ?, ?, ?, ?, ?)", [email, password, first_name, last_name, date, sex]) i error: sqlite3.programmingerror: incorrect number of bindings supplied. current statement uses 6, , there 5 supplied. if add question error same now: sqlite3.operationalerror: table users has 6 columns 7 values supplied if add comma without question mark ...

node.js - Unable to create a new spreadsheet with the Google Sheets API -

i'm using googleapis package create new google spreadsheet , fails. same request works when use web-based tools in google api documentation . google.prototype.createsheet = function(filename, callback) { var services = google.sheets('v4'); services.spreadsheets.create({ properties : {title:filename}, auth : this.auth }, function(err,response) { if( err ) { console.log('error : unable create file, ' + err); return; } else { console.dir(response); } }); } the result, error : unable create file, error: invalid json payload received. unknown name "properties": cannot bind query parameter. field 'properties' not found in request message. i've tried using property name of "resource" instead of "properties" because found in other sheets endpoints. didn't work resulted in both different error message different api request when debug g...

python - Clicking on a menu cascade clicks on the canvas behind -

i'm trying image creator , editor in style of paint. in order switch tool, save/open files , stuff, created menu multiple cascades. have bound canvas function via mouseclick event, , now, when click on menu cascade command on canvas, function called. so, basically, try use menu bar , clicks on canvas, don't want happen. idea of how stop it?

angular - Rx Observable not updating when other component causes its data to update and call next -

in angular2 app have rx observable exposed view. observable created in store , passed component via subject.asobservable i having problem getting page's reference register next() being called on subject if operation on sub-page initiates action, works if same page calls store. below shows layout , flow of item, , below illustrate in case fails. base.store, houses subjects next() call options: { collection: string }; _subject$: subject<array<any>>; protected datastore: {}; constructor(protected http: http) { } init(options) { this.options = options; this.datastore = {}; this.datastore[options.collection] = []; this._subject$ = <subject<array<any>>>new subject(); this.load(); } load() { this.http.get(endpointurl).map(response => response.json()).subscribe( data => { this.datastore[this.options.collection] = data; this._subject$.next(this.datastore[this.options.collection]...

phpMyAdmin hangs during mySql file import -

i received bunch .sql files, none of them > 200k use phpmyadmin in xammp import db @ 80% of successful import, must bad .sql file caused phpmyadmin hang, there no error massage whatsoever. how can phpmyadim recover without erasing imported files? btw, use xampp 1.7.3 mac thanks as pma web interface, limited same post size limits , timeout limits, etc, other web app. if have import large files have them command line. mysql -u username -p db_name < /path/to/importfile.sql replace username db username, db_name database name, , /path/to/importfile.sql full path import file. if have large files, recommend big dump stagger upload. i've used tool several times , works , easy use.

Finding factors of number and factoring a polynomial (Lua) -

Image
i'm attempting program lua syntax (i have experience it) find factors of , number , possibly factor input polynomial. i'm not sure if has done factoring learned doing "multiply to" , "add to"/"x-box" method. it'd interesting draw out method in lua (see picture attached) , display answer. if not draw, i'd use print command. i program have 2 parameters: 1 number determine prime factors , other polynomial input (like a, b , c values ax^2+bx+c) factored. may attempt perfect squares , difference of squares. i'd guidance in , i'm in no way expecting full working program. in advance. you can make for chunk loop function this function factor(val) val=math.floor(val) found={} rev={os.time()*4} halt=0 lasti=0 lastm=0 m=1,val if halt==1 break end if lasti == m halt=1 break else i=0,val if m*i == val print(m.."*"..i.."="..val) ta...

html - Using Margin: auto; is not centering div -

margin: auto; isn't centering <div class="users"> . .users { margin: auto; } .admin { margin: 5px; border-style: solid; border-width: 1px; border-color: grey; box-shadow: 2px 2px 1px grey; background: white; background: -webkit-linear-gradient(#fff , #f1f1f1); background: -o-linear-gradient(#fff , #f1f1f1); background: -moz-linear-gradient(#fff , #f1f1f1); background: linear-gradient(#fff , #f1f1f1); } .admin img { display: block; border-style: solid; border-width: 1px; border-color: grey; max-width: 100%; margin: auto; margin-top: 20px; margin-bottom: 20px; box-shadow: 2px 2px 1px grey; } .info { position: relative; background-color: #e0e0e0; } .info h1 { padding-top: 10px; } ...