Posts

Showing posts from May, 2010

angularjs - Utility functions for directives -

say want make angular directive generates links resources this: <a href="http://link/to/resource/1234">link/to/resource/1234</a> from object looks like: resource = { id: 1234, otherproperty: 'foo' } how can w/ directive? ie, i'd not have repeat part goes '/link/to/resource/{{id}}' . can't seem work right. 1 of several things i've tried: app.directive('myresource', function() { return { restrict: 'e', scope: { resource: '=' }, baseurl: 'link/to/{{resource.id}}', template: '<a href="http://{{baseurl}}">{{baseurl}}</a>' }; }); which ends rendering: <a href="http://" class="ng-binding"></a> other things i've tried (like making baseurl function/sticking in scope ) have resulted in similar things/errors. is there way work? one way handle use directive's link function set variab...

c# - Using Forms Auth. with Claims Based Auth -

using this guide i've implemented claims based auth on asp.net webforms successfully. problem while using claims based auth. cannot use forms based auth in same app pool: <authorization> <deny users="?" /> </authorization> <authentication mode="none" /> is there way use both?

python - abort method in Flask-Restful ignoring CORS options -

i have flask-restful api configured cors options: api = api() api.decorators=[cors.crossdomain(origin='*', headers=['accept', 'content-type'])] ... api.init_app(app) my api accepts post requests may fail if data in request invalid: class myapi(resource): def post(self): args = request.get_json() if args.get('something'): return {'message': 'request worked, data received!', 'something': args['something']} else: abort(500, "error: data must contain 'something' field!") when make successful post request api can see cors options set: ... * upload sent off: 81 out of 81 bytes * http 1.0, assume close after body < http/1.0 200 ok < content-type: application/json < content-length: 205 < access-control-allow-origin: * < access-control-allow-methods: head, get, post, options < access-control-max-age: 21600 ...

html - CSS - Overflow and Positioning -

i saw similar post dealing issue, problem wee bit different. in issue outlined here , concept outer div positioned relative, , inner div positioned absolute, , overflow:hidden preserved. my issue both divs, inner , outer positioned absolute. how can still preserve overflow: hidden on outer div? not sure of question, try achieve? see jsfiddle css: #outer { position: absolute; top: 10px; left: 10px; height: 80px; width: 50px; overflow: hidden; } #inner { position: absolute; top: 10px; left: 10px; height: 50px; width: 50px; } with html: <div id='outer'> <div id='inner'> // stuff here </div> </div>

assembly - Most efficient/idiomatic way to test a 256-bit YMM AVX register for zero -

i have x86_64 routine ends 0 in ymm register if successful, , i'd return non-zero if ymm register. i have way clearing ymm register, vptest'ing register against one, , conditionally incrementing resturn register (rax in case) if cf not set: " xor %%rax, %%rax \n" // clear rax " vxorpd %%ymm0, %%ymm0, %%ymm0 \n" // clear ymm0 " vptest %%ymm1, %%ymm0 \n" // compare ymm1 0 " jc endcheck \n" // branch on if no residue " inc %%rax \n" // inc rax otherwise "endcheck: \n" // result in rax this seems opaque way it. there better way, or more idiomatic or readable way? combining comments above, can done in 3 lines of assembly: "xor %%rax, %%rax \n" // clear rax "vptest %%ymm1, %%ymm1 \n" // if ymm1 zero, set zf "setnz %%al...

database - Postgresql : Loop thorugh each table and check for column? -

i trying write simple sql query in pgadmin loop through each table in database , change specified column name if exists. have never coded in sql after searching through many forums have managed come with: do begin in select table_name information_schema.tables loop if select column_name information_schema.columns table_name = 'i.table_name' alter table i.table_name rename column old_column_name new_column_name end if; end loop; any great. you can skip information_schema.tables entirely. just: do $$ declare rec record; begin rec in select table_schema, table_name, column_name information_schema.columns column_name = 'x' loop execute format('alter table %i.%i rename column %i newname;', rec.table_schema, rec.table_name, rec.column_name); end loop; end; $$ language plpgsql; with appropriate substitutions 'x' , newname . or make function takes them parameters, what...

How do you access params[:model][:field] in Rails 4? -

from understand... if have form_for @model , params[:model] available when form submitted. furthermore, if form has 2 attributes attr1 , attr2 , params[:model][:attr1] , params[:model][:attr2] available when form submitted. in rails 4, you're supposed write method model_params says params.require(:model).permit(:attr1, :attr2) . you'd use model_params so: model.new(model_params) . however, do if need 1 of fields form? if needed params[:model][:attr1] ? example: def create @user = user.new(user_params) if @user.save # need access params[:user][:password] here redirect_to root_url, :notice => "signed up!" else render :new end end private def user_params params.require(:user).permit(:email, :password, :password_confirmation) end the gem responsible behaviour strong_parameters . permit() method decides pass on model based on attributes pass it. in case, passed :attr1 , :attr2 : params.require(:m...

c# - Why must a static constructor be parameterless? -

i'm encountering error: 'lnkscript.lnkscript.killstreakhud.killstreakhud(infinityscript.entity)': static constructor must parameterless c:\users\home\desktop\lnkscripts.cs 61 20 lnkscript my source code: public class killstreakhud : basescript { static killstreakhud(entity player) { string killstreak = "^3killstreak:^3" + player.getfield<int>("killstreak").tostring(); hudelem hudelem = hudelem.createfontstring(player, "hudsmall", 1f); hudelem.setpoint("topcenter", "topcenter"); hudelem.settext(killstreak); base.oninterval(300, delegate { killstreak = "^3killstreak:^3" + player.getfield<int>("killstreak").tostring(); hudelem.settext(killstreak); return true; }); } } clearly, static constructor not parameterless, , compiler takes umbrage @ fact. why? a static constructor must parameterless ...

dart - Why can I assign List<dynamic> to a List<String>? -

i getting confused around how type checking works dart. shown, assigning general list<dynamic> list<string> ok. means can assign content in list, not string . why that? void main() { list<string> a; = [1]; // pass = new list<int>(); // fail = 1; // fail = new list<string>(); // pass a.add(1); // fail } the dynamic type special. means "turn off type checking this, know i'm doing". in example, assign list<dynamic> instance list<string> variable. static type checker sees: list list, that's ok, , type parameter dynamic, i'll not check @ all, programmer must know doing. whenever use dynamic type, or part of type, taking full responsibility typing being correct. system let whatever want. even without dynamic , dart type system isn't safe . means can create programs no static type warnings still fail type error @ runtime. languages ...

localhost - Site looks good locally in Firefox 29.0.1 but not remotely -

a site working on: http://ninthmind.com , looks remotely in browsers except firefox 29.0.1. have cleared cached , searched syntax errors. weird thing looks expected locally on machine in same firefox browser. there video element within site not appearing (only remotely in firefox) despite having both mp4 , webm sources. in code below class "invis" changes mask's , video's display none mobile devices. <div class="header"> <img class="invis" id="mask" src="images/mask.png"> <video class="invis" id="brain" autoplay loop> <source src="video/brain.mp4" type="video/mp4"> <source src="video/brain.webm" type="video/webm"> </video> <div class="welcome"> <h1>welcome to</h1> <img id="logo" src="images/logo.png...

php - URL Shortener Issue -

after submitting url via shortener. gives url custom code @ end rather redirecting want give error code: not found the requested url /1njchs not found on server. additionally, 404 not found error encountered while trying use errordocument handle request. i unsure file may have issue in have linked 3. shortener.php: <?php class shortener { protected $db; public function __construct() { //demo purposes $this->db = new mysqli('localhost', 'langers_langers', '^m%kt3&50pwn','langers_website'); } protected function generatecode($num){ return base_convert($num, 10, 36); } public function makecode($url){ $url = trim($url); if(!filter_var($url, filter_validate_url)) { return ''; } $url = $this->db->escape_string($url); //check if url exists $exists = $this->db->query("select code links url...

c# - Removing a node from a list using a for -

here have done: // example of function, string , remover should variables string delimeter = ","; string remover="4"; string[] separator = new string[] { "," }; list<string> list = "1,2,3,4,5,6".split(separator, stringsplitoptions.none).tolist(); (int = 0; < list.count - 1; i++) { if(list[i]==remover) list.removeat(i); } string allstrings = (list.aggregate((i, j) => + delimeter + j)); return allstrings; the problem retruned string same originial one, same "1,2,3,4,5,6". "4" still in it. how fix it? edit: the solution didnt check last node of list in for, doesnt seem in example because example gave now when remove items list should make loop run in reverse, highest index lowest. if go lowest highest end shifting items down removed , skip items. running in reverse not have issue.

resize - How to make the sizes of two images match in Idrisi ? -

so, have usual error message number of rows , columns of images don't match (in cross ref). have generalised 1 of images , use expand make resolutions match again. however, in process lost few columns (which doesn't bother me), however, don't know in order make both images same size again. can me ? thank l. to make similar column , rows, convert layer raster vector (rastervector conversion tool) convert vector converted layer in raster (resample layer has required column , row)

rails 4.0 undefined method -

i have opportunity model has activity nested resource. on opportunities/show page, have list of activities opportunity , form add new activities. when click "add activity" get: undefined method `activities' nil:nilclass here error source: # post /activities.json def create @activity = @opportunity.activities.new(activity_params) if @activity.save redirect_to @opportunity, notice: 'activity has been added' else i defined opportunity model having many activities , activities belongs to opportunity. here relevant parts of activity controller: def create @activity = @opportunity.activities.new(activity_params) if @activity.save redirect_to @opportunity, notice: 'activity has been added' else redirect_to @opportunity, alert: 'unable add activty' end end and here views/activities/new code <%= form_for ([@opportunity, @opportunity.activities.new]) |f| %> <div class="field...

coldfusion - Access column in query with special character? -

i'm invoking stored procedure coldfusion code returns column column name "my column ™". how can access field...? like: myquery["my column &trade;"] but can't figure out correct syntax. can done? try this: myquery["my column #chr(8482)#"][currentrow]

Intelligent closest match detection with names in MySQL and PHP -

say have mysql table 1 below list of names in organisation, , ids each. id name 1 john doe 2 richard smith 3 jane market ... ... given user query person's first and/or last name (with possibility of typos , nicknames used) , php should return closest match query. for example, if user enters "ricky" (nickname richard), should return id richard smith. for nicknames, have create separate mysql table, lookups (many-to-one relationship). for typos, have loop of names , compare them user has entered using levenshtein function, or similar_text function. user contributed notes help.

reporting services - Report Builder / BIDS - Running specific datasets only via parameter -

we have lot of reports delivered via ssrs. we looking consolidate these reports 'packs' multiple reports run in 1 .rdl. we using separate dataset each report , looking use parameter select reports run (i.e. datasets run) does have guidance on this, avoid using sub reports if possible.

unable to create a file under /data/ android -

i wrote android application in create file under /data/ directory able create file able read , write file want give read access group , other users unable my sample code goes here try{ string path = '/data/'; f = new file(path,"myfile.conf"); f.setreadable(true,false); f.setwriteable(true,false); }catch(exception e){ e.printstackstrace(); } when see file using cmd line -rw------- /data/myfile.conf in androidmanifest.xml -- have android:userid system application running system user my idea create file under /data/ directory , give read access other users suggestion please let me know regards nick

java - Position glCanvas alongside a JPanel containing buttons -

Image
i'd have jbutton panel consume ~30% of frame s horizontal space. , glcanvas on right side taking rest of frame s space. how can achieve layout? currently: main.java glprofile profile = glprofile.get(glprofile.gl2); glcapabilities capabilities = new glcapabilities(profile); glcanvas glcanvas = new glcanvas(capabilities); glcanvas.addgleventlistener(new gamerenderer()); glcanvas.setsize(100, 100); jframe frame = new jframe("tool"); jpanel panel = new jpanel(); jpanel cpanel=new jpanel(); panel.setlayout(null); cpanel.setlayout(null); jbutton buttonbr = new jbutton("1"); jbutton buttone = new jbutton("2"); jbutton buttonr = new jbutton("3"); jbutton buttonc = new jbutton("4"); jbutton buttont = new jbutton("5"); jbutton buttoncr = new jbutton("6"); buttonbr.setbounds(10, 30, 150, 40); buttone.setbounds(10, 80, 150, 40); buttonr.setbounds(10, 130, 150, 40); buttonc.setbounds(10, 180, 150, 40); b...

asp.net mvc - MVC password reset mail NO SIMPLEMEMBERSHIP -

am bad of googler or there no guides out there on how reset password without simplemembership using tokenlink? i want anonymous user input mail of account, send mail link , when visiting link user able reset password without old password. not using simplemembership! i know how send emails , have never created token , use link in mail etc. there decent guides me this? side note, i'm storing user information in azure tablestorage. thanks stack overflow isn't best place asking overly broad "how do this?" questions, nor "recommend me tutorial or guide". (having said that, question/problem) it should simple. the user clicks on "forgot password" link. generate random string ("token"), such guid , store (such in database). store time generated or expiration date. email user link site appropriate token. the user comes site. if token exists , done within expiration time (15 - 30 minutes?) give them form change passwo...

python - Parallel code hangs if run first, but works if run after running non-parallel code -

so sounds bit convoluted, i've had problem joblib lately create bunch of processes , hang there (aka, each process takes memory, uses no cpu time). here simplest code i've got reproduce problem: from sklearn import linear_model import numpy np sklearn import cross_validation cval joblib import parallel, delayed def fit_hanging_model(n=10000, nx=10, ny=32, ndelay=10, n_cvs=5, n_jobs=none): # create data x = np.random.randn(n, ny*ndelay) y = np.random.randn(n, nx) # create model + cv model = linear_model.ridge(alpha=1000.) cvest = cval.kfold(n, n_folds=n_cvs, shuffle=true) # fit model par = parallel(n_jobs=n_jobs, verbose=10) parfunc = delayed(_fit_model_cvs) par(parfunc(x, y, train, test, model) i, (train, test) in enumerate(cvest)) def _fit_model_cvs(x, y, train, test, model): model.fit(x, y) n = 10 = np.random.randn(n, 32) b = np.random.randn(32, 10) ########## c = np.dot(...

javascript - jQuery: determine the [server's] Document Root -

in php can document root by: $_server['document_root'] . ej: php <?php $root = $_server['document_root']; $path = '/example/directory/'; $file = 'some-file.html'; include( $root . $path . $file ); ...etc ?> how can value of $_server['document_root'] in jquery/javascript? jquery //example: var root = ????; var path = 'example/directory/'; var file = 'some-file.txt'; $("#example").load( root + path + file ); notes: whenever work on directories, on html page, "base" directory becomes directory of current file. ej, www.ejample.com/documents/examples/this-ex.html . if call $("#example").load( path + file ) request documents/examples/ + example/directory . said, it's not question server-side stuff. getting correct (and automatic) directory position are looking document.location.hostname ? var root = document.location.hostname; $("#example").load( root + p...

function - invoking php methods directly -

this question has answer here: php: access array value on fly 8 answers why work: $n = explode("@", "some@email.com"); echo $n[0]; and not work? explode("@", "some@email.com")[0] when try latter, get: parse error: syntax error, unexpected '[' it works in later versions of php (>= 5.4.0): php 5.4.0 offers wide range of new features: [...] - function array dereferencing has been added, e.g. foo()[0]. [...] older versions of php not support function array dereferencing, why syntax error (php not know [ , tells "unexpected").

cocoa - Creating an NSWindow that floats over all other windows in the app but not over windows from other apps -

i trying make nswindow show on top in application don't want float on other apps have become active. have tired following code makes window float on other applications: nsrect frame = nsmakerect(100, 100, 800, 800); mywindow = [[nswindow alloc] initwithcontentrect:frame stylemask:nsborderlesswindowmask backing:nsbackingstorebuffered defer:no]; [mywindow setlevel:nsfloatingwindowlevel ]; [mywindow setbackgroundcolor:[nscolor bluecolor]]; [mywindow makekeyandorderfront:nsapp]; i have tried of constants listed in nswindow documentation , did not find 1 make nswindow float on other windows in not other windows of other active apps. not possible? there's no built-in support that. might consider setting window hide on deactivate. alternatively, can have window controller observe nsapplicationwillresignactivenotifica...

DNN Search Results Permissions -

i've made custom dnn 7.2 module entry form (with permissions on page roles), , use razor host scripts retrieve entries , display them in frontend public users, , i've implemented modulesearchbase integrate dnn search, , can see entries in index (using luke open index) the problem can view results if , if i'm logged in user permission use backend module (entry form module), how make results available users anonymous ones ?

Regex for only Select queries? -

i looking regex allows select queries strictly, no inserts, deletes, alters or of sort can allowed , query can have multiple lines.. i tried var pattern="(^select)^((?!insert|delete|alter).)*$"; var pattern=^(?!insert|delete|alter|modify|add|create|drop|truncate|rename|update|rollback|commit|grant|revoke|savepoint)(.(?!insert|delete|alter|modify|add|create|drop|truncate|rename|update|rollback|commit|grant|revoke|savepoint))*$"; how make not match insert or keywords on multiple lines (in javascript). it fails in eg: select * insert which means should start "select" , cannot have insert anywhere in query doesn`t work. there lot of problems idea, mentioned in comments. far how accomplish this: /^select(?:(?!insert|delete|alter)[\s\s])*$/i this make sure select (case-insensitively) first word. used rest of expression exactly. threw * repetition non-capture group, , updated . [\s\s] (because . matches character except newlin...

php - No database selected? -

i trying insert values database using pdo says "no database selected". $host = "localhost"; $dbname = "aura"; $user = "root"; $pass = "somepassword"; try { $db = new pdo("mysql:host=$host;dbname=$dbname", $user, $pass, array(pdo::mysql_attr_init_command => "set names utf8")); $db->setattribute(pdo::attr_emulate_prepares, false); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) { echo $e->getmessage(); } $signup = $db->prepare("insert `users` (`username`, `password`, `name`, `email`, `rank`, `lvl`, `xp`, `money`, `age`, `reg_ip`, `last_ip`, `created`, `last_online`, `last_action`, `online`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $signup->bindvalue(1, $username); $signup->bindvalue(2, $password); $signup->bindvalue(3, $name); $signup->bindvalue(4, $email); $signup->bindvalue(5, '1'); ...

c# - Endpoint which accepts a HttpPostedFileBase and writes the incoming stream to a Webclient for upload -

i have endpoint accepts httppostedfilebase, provides input stream can read download file. don't want read - want re-post endpoint on different domain (this because api built on top of another). can without waiting whole stream read? don't want users of endpoint delayed unnecessarily. public actionresult upload(httppostedfilebase image) string url = "www.example.com"; using (var wb = new webclient()) { var stream = wb.openwrite(url, "post"); int read; byte[] buffer = new byte[0x1000]; while ((read = image.inputstream.read(buffer, 0, buffer.length)) > 0) stream.write(buffer, 0, read); } } unfortunately using openwrite doesn't seem provide easy option read response, i'll buffer entire stream , use uploaddata :(.

uisearchbar - Setting UISearch in navigation bar in ios7 -

i'm having search bar in navigation bar using [self.searchdisplaycontroller setdisplayssearchbarinnavigationbar:yes]; it displays search results view when search bar tapped there no cancel button in search results view.can u please give me suggestion doing programmatically i have programmatically. plz give me hand. thankz in advance you should able use: [self.searchdisplaycontroller.searchbar setshowscancelbutton:yes animated:yes] i'm using myself (implementing uisearchdisplaydelegate): - (void)searchdisplaycontrollerwillbeginsearch:(uisearchdisplaycontroller *)controller { [controller.searchbar setshowscancelbutton:yes animated:yes]; }

java - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version -

i erro when trying execute dao method on java code saying theres error in sql sintax. when manually on mysql nothing goes wrong apparently. error: informações: com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'as p inner join usuario u on p.usuario = u.idusuario p.idprestador=2' @ line 1 dao method: public prestador listarprestadordetalhe(int idprestador) { try { connection conexao = conexao.getconexao(); preparedstatement pstmt = conexao.preparestatement("select p.telefone, p.celular, u.email" + "from prestador p inner join usuario u on p.usuario = u.idusuario p.idprestador=?"); prestador prestador = new prestador(); pstmt.setint(1, idprestador); resultset rs = pstmt.executequery(); while (rs.next()) { prestador.usuario = new usuario(); prestad...

html - how to get unicode text from jtextpane java -

Image
i have set jtextpane content type html , setted ta_description = new jtextpane(); ta_description.setcontenttype("text/html"); ta_description.setfont(new font("latha", font.plain, 12)); ta_description.settext("<![cdata[<br>வேலூர் மாவட்டம், அணைக்கட்டு தொகுதி பா.ம.க.வை சேர்ந்த கலையரசு எம்.எல்.ஏ. நேற்று முன்தினம் காலை முதல்-அமைச்சர் ஜெயலலிதாவை சந்தித்து தனது தொகுதி பிரச்சினைகள் குறித்து பேசினார். அதைத்தொடர்ந்து அவரை கட்சியில் இருந்து நீக்குவதாக பா.ம.க. தலைவர் ஜி.கே.மணி அறிவித்தார்.<br>]]>); when text using ta_description.gettext() , below <![cdata[<html> <head> </head> <body> <br> &#2997;&#3015;&#2994;&#3010;&#2992;&#3021; &#2990;&#3006;&#2997;&#2975;&#3021;&#2975;&#2990;&#3021;, &#2949;&#2979;&#3016;&#2965;&#3021;&#2965;&#2975;&#3021;&#2975;&#30...

sql - What is the use of WITH CHECK keyword -

alter table employee check constraint ck_employee_birthdate when run above line of code not getting error. but when run below line of code getting error " the alter table statement conflicted foreign key constraint " alter table employee check check constraint ck_employee_birthdate can me understand difference between using check , not using it? following on bogdan's comment, http://msdn.microsoft.com/en-us/library/ms190273.aspx explains "with check" syntax ensures data in table validated against new check constraint. link, check assumed new constraints, nocheck assumed when re-enable existing constraint: check | nocheck specifies whether data in table or not validated against newly added or re-enabled foreign key or check constraint. if not specified, check assumed new constraints, , nocheck assumed re-enabled constraints. if not want verify new check or foreign key constraints against existing data, use nocheck. not recommend...

Python: numpy.interp giving curved line -

Image
i'm trying linearly interpolate low resolution curve (10 data points) higher resolution (~1000 data points). new curve of same shape many more x , y values, i.e. high , low resolution curves indistinguishable when plotted lines. i've used numpy's interpolation many times baffles me. usual np.interp(newx, oldx, oldy) i'm getting funny result when plot it. the lines between green squares should straight, not arched this. i'm not sure if matters x values range 0 1000 , y values range 1e-12 1e-16. suggestions appreciated! update: above plot log log scale happens on linear plot too. here's actual data. (it's 1e-15 1e-19): x = array([ 0.3543 , 0.477 , 0.544579, 0.6231 , 0.64142 , 0.7625 , 0.79788 , 0.9134 , 1.02894 , 1.235 , 1.241608, 1.615118, 1.662 , 2.159 , 2.181858, 3.4 , 3.507511, 3.732206, 4.436578, 4.6 , 4.664426, 5.628102, 7.589159, 12. ]...

angularjs - How to create email verification on Firebase simple login -

in angularfire seed project, there account registration process using email , password. how can verify email not fake? mean without server code, client code. you can angularjs-fire seed project @ link angularfire_seed_with_reg_confirmation . explanation of here email verification using angularjs+firebase below quote readme: it angularjs seed firebase backend , feature account registration confirmation via email. feature can used alternative account activation. clone of angularfire seed additional feature above , login feature vial social login ie login facebook, twitter, , google. the account registration differs original seed. can register account supplying email , we'll confirmation email our temporary random password. password recommended changed memorable 1 , @ same time must strong , secure.

grayscale image on webcam using opencv (cant show full image) -

Image
i'm trying create grayscale operation via webcam using opencv (cvcapture). here code void h_grayscale( unsigned char* h_in, unsigned char* h_out) { for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ int index = h_in[i*widthstep + j*channels]; int gray = 0.3*(index)+0.6*(index+1)+0.1*(index+2); h_out[i*widthstepoutput+j]=gray; } } } main code int main(int argc, char** argv) { int c; iplimage *image_input; cvcapture* capture = cvcapturefromcam(1); while(1) { image_input=cvqueryframe(capture); iplimage* image_output = cvcreateimage(cvgetsize(image_input),ipl_depth_8u,image_input->nchannels); unsigned char *h_out = (unsigned char*)image_output->imagedata; unsigned char *h_in = (unsigned char*)image_input->imagedata; width = image_input->width; height = image_input->height; channels = image_input->nchannels; widthstep = image_input->widthstep; widthstepoutput = image_...

c++ - Is gcc 4.8 or earlier buggy about regular expressions? -

i trying use std::regex in c++11 piece of code, appears support bit buggy. example: #include <regex> #include <iostream> int main (int argc, const char * argv[]) { std::regex r("st|mt|tr"); std::cerr << "st|mt|tr" << " matches st? " << std::regex_match("st", r) << std::endl; std::cerr << "st|mt|tr" << " matches mt? " << std::regex_match("mt", r) << std::endl; std::cerr << "st|mt|tr" << " matches tr? " << std::regex_match("tr", r) << std::endl; } outputs: st|mt|tr matches st? 1 st|mt|tr matches mt? 1 st|mt|tr matches tr? 0 when compiled gcc (macports gcc47 4.7.1_2) 4.7.1, either g++ *.cc -o test -std=c++11 g++ *.cc -o test -std=c++0x or g++ *.cc -o test -std=gnu++0x besides, regex works if have 2 alternative patterns, e.g. st|mt , looks last 1 not matched reasons. code ...

java - Cassandra Insertion/ write failed -

i have installed cassandra 2.0 on centos6.5 server , and while testing simple records working fine, have upload 600 billion rows, when use copy on cqlsh failed after 5 minutes , approx rows inserted 0.2 million rpc timeout, opted pycasso , parsed csv , tried import using inserts commands, after every 10k records, opted close connection , develop new connection again. after around 60k records failed with timeout. my debug trace shows while server not accepting inserts, without activity it's still busy. debug [optionaltasks:1] 2014-05-30 04:34:16,305 meteredflusher.java (line 41) flushing 269227480 bytes of 2047868928 max debug [optionaltasks:1] 2014-05-30 04:34:17,306 meteredflusher.java (line 41) flushing 269227480 bytes of 2047868928 max debug [optionaltasks:1] 2014-05-30 04:34:18,306 meteredflusher.java (line 41) flushing 269227480 bytes of 2047868928 max debug [optionaltasks:1] 2014-05-30 04:34:19,012 columnfamilystore.java (line 298) retrypolicy schema_triggers 0.99 deb...

Scraping JavaScript-loaded HTML with Ruby on Rails and Nokogiri -

i trying scrape website product names. my controller following: page = nokogiri::html(open(page_url)) @items_array = page.css("li.item h3") then displaying in view as: <%= @items_array.each |item| %> <%= item.text %><br /><br /> <% end %> the problem html loaded first 10 items. rest generated javascript. can't seem figure out how exactly. any ideas on how scrape rest of content appreciated! it won't work. nokogiri cannot scrape not on page, , can see (using "view source" on browser), part of list not html. how loaded irrelevant in case (probably using javascript). best option ask them if expose api use (that make work easier). scrapping fragile depend on exact layout of page.

javascript - Why is the dismissible alert not being dismissed? -

note: let me start saying i'm aware of question solution incomplete , don't yet have not enough reputation on stackoverflow comment on it. so, left option of creating duplicate question. i'm trying use angularjs , bootstrap (ui-bootstrap) show dismissible alert. however, after including ui-bootstrap-tpls-*.js file (solution suggested on original question) doesn't seem work. although work jquery. please check plunker i found way have dismissible alert without adding logic controller. don't need bootstrap-*-js. have alert close button uses ng-click on $scope variable hide parent div on ng-show . (the controller sets variable whether alert should shown or not.) <div class="alert alert-warning" ng-show="show_alert"> <button type="button" class="close" ng-click="show_alert=false">&times;</button> <strong>warning!</strong> best check yo self, you're not looki...

JYTHON/PYTHON - raw_input losing first character of string -

i reading in name see below, regardless of type in loses first character, example, 'bob' become 'ob'. because of cannot compare user's input searching for, breaking entire program. def find() : global addressbookall success = false persontofind = str(raw_input("\nenter nickname of person find: ")) x in addressbookall : if(x == persontofind) : success = true printnow("\n%s" %(x)) y in addressbookall[x] : printnow("%s" %(y)) if(success == false) : printnow("\nnot found.") there few problems code. first, shouldn't using global variable. make more sense pass address book function. don't worry, reference passed, it's cheap. second, function names (and other variable names except classes) should lowercase. third, no need call str() on raw_input() returns string. fourth, use .format() string syntax instead of % string formatting. fifth, x appear...

SQL server mail function sp_send_cdontsmail -

i wrote procedure in tried send mail using below command. exec sp_send_cdontsmail 'from','to','test','test data' after executing showing "command(s) completed successfully." but not getting mail.please me on this. you need configure database mail , use sp_send_dbmail send mail. supported procedure, part of sql server. ps. aware out there code sample circulates advocates along lines of: create procedure [dbo].[sp_send_cdontsmail] ... exec @hr = master..sp_oacreate 'cdonts.newmail', @mailid out exec @hr = master..sp_oasetproperty @mailid, 'from',@from exec @hr = master..sp_oasetproperty @mailid, 'body', @body ... this horrible code. 1 can see there absolutely 0 (zero, nada, zip) error checking in code. failure reported 'success'. com interop not raise t-sql notification messages, in hresult, goes unchecked. steer away such code.

sql server - How to Compare dates in using C#? -

i have problem comparing dates datetime = datetime.parse(sfromdate); datetime = datetime.parse(stodate); return orderlambda(objcouponuow.repository<couponguids>().entities.where(x=> x.ordercreateddate <= && x.ordercreateddate >= from)); the strings sfromdate='29/05/2014 00:00:00' , stodate='31/05/2014 00:00:00' here not getting error pls give solution dates not in any format in sql server, unless storing them wrong. if view them in ssms renders them in format, viewing convenience. numbers (integer part days epoch, decimal part time). so order/filter them by date, dates .

javascript - Generating source maps from browserify using grunt -

i have followed instructions here: https://www.npmjs.org/package/grunt-browserify , try , set source maps browserify on grunt. options browserify in gruntfile : browserify: { options: { bundleoptions : { debug: true } }, dist: { files: { "public/client.bundle.js": ["bundle.js"] } } } the generation of bundle.js happens without issues, source map generation not happen. there wrong grunt-browserify options. thanks looking. use browserifyoptions instead of bundleoptions browserify: { options: { browserifyoptions: { debug: true } }, ... }

android - How can I make TextToSpeech to speak a text with max volume and restore original volume after speak end? -

i save current volume both stream_ring , stream_music before stts.get().speak(s, texttospeech.queue_add, null) , hope texttospeech can speak text max volume, in fact find texttospeech speak text current volume, seems stts.get().speak asynchronous. how can make texttospeech speak text max volume , restore original volume after speak end? thanks! public class speechtxt { private static softreference<texttospeech> stts; public static void speakout(final context context, final string s) { final context appcontext = context.getapplicationcontext(); if (stts == null) { stts = new softreference<texttospeech>(new texttospeech(appcontext, new texttospeech.oninitlistener() { @override public void oninit(int status) { if (status == texttospeech.success) { speak(appcontext, s); } else { ...

asp.net mvc 3 - How to Encrypt & Decrypt whole URL or URL parameters in mvc3? -

return redirecttoaction("deshboardportal", "portal",new { user_id = session["user_id"], roleid = session["role_id"]}); in above code want encrypt url parameter written below :- new { user_id = session["user_id"], roleid = session["role_id"]} you can try return redirecttoaction("deshboardportal", "portal", new { user_id = encode(session["user_id"].tostring()), roleid = encode(session["role_id"].tostring()) }); public string encode(string encodeme) { byte[] encoded = system.text.encoding.utf8.getbytes(encodeme); return convert.tobase64string(encoded); } public static string decode(string decodeme) { byte[] encoded = convert.frombase64string(decodeme); return system.text.encoding.utf8.getstring(encoded); }

html - Jquery code that copies one pictures source to another -

i plan on making lightbox want learn way around javascript. goal when click 1 of images, copies images source , div id of "copiedto" i cant figure out how code wrong. here html: <body> <div id="gallery"> <ul> <li> <img src="1.jpg"/> </li> <li> <img src="2.jpg"/> </li> <li> <img src="1.jpg"/> </li> <li> <img src="2.jpg"/> </li> <li> <img src="1.jpg"/> </li> <li> <img src="2.jpg"/> </li> </ul> </div> <div id="copiedto"><img src="#"/></div> </body> and javas...

Java - put the csv file in a array -

i'm beginner in java. can me part? i dont know how can read csv file 3 columns , lot of rows array. want change columns , write again csv file. i can read file, can not change this. think must somehow loaded array or list? thanks you can use opencsv . csv parser library java.

java - org.apache.axis2.AxisFault connection refused -

i'm getting following error while tryng suscribe service client app. can tell me reason exception? thanks in advance org.apache.axis2.axisfault: conexión rehusada @ org.apache.axis2.axisfault.makefault(axisfault.java:430) @ org.apache.axis2.transport.http.httpsender.sendviapost(httpsender.java:197) @ org.apache.axis2.transport.http.httpsender.send(httpsender.java:75) @ org.apache.axis2.transport.http.commonshttptransportsender.writemessagewithcommons(commonshttptransportsender.java:404) @ org.apache.axis2.transport.http.commonshttptransportsender.invoke(commonshttptransportsender.java:231) @ org.apache.axis2.engine.axisengine.send(axisengine.java:443) @ org.apache.axis2.description.outinaxisoperationclient.send(outinaxisoperation.java:406) @ org.apache.axis2.description.outinaxisoperationclient.executeimpl(outinaxisoperation.java:229) @ org.apache.axis2.client.operationclient.execute(operation...

c# - Is it necessary to await a single asynchronous call -

this question has answer here: any difference between “await task.run(); return;” , “return task.run()”? 4 answers if i'm returning result of single asynchronous function e.g. in service between application layers, there difference between: public task<byte[]> getinsurancepolicydocument(string itineraryreference) { return this.coreitinerarydocumentservice.getinsurancepolicydocument(itineraryreference); } and: public async task<byte[]> getinsurancepolicydocument(string itineraryreference) { return await this.coreitinerarydocumentservice.getinsurancepolicydocument(itineraryreference); } there few subtle differences in cases - example, if original task returns status of faulted operationcanceledexception async version return task status of canceled ... unless need of subtlety, ...

python - Can't create virtualenv with jython 2.7b2 as an interpreter -

i want execute java code python i've decided install standard python interpreter, jython , join them using pyro4. pyro4 requires python > 2.5 choose use jython 2.7b. here steps made make happen: wget -i jython-installer-2.7-b2.jar http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7-b1/jython-installer-2.7-b2.jar java -jar jython-installer-2.7-b2.jar jython2.7b2/bin/virtualenv-2.7 oscar and i'm getting back: cannot find file /home/mnowotka/jython2.7b2/include (bad symlink) new jython executable in oscar/bin/jython installing setuptools................. complete output command /home/mnowotka/oscar/bin/jython -c "#!python \"\"\"bootstra...sys.argv[1:]) " /home/mnowotka/jytho...ols-0.6c11-py2.7.egg: downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg traceback (most recent call last): file "<string>", line 278, in <module> file "<string>...