Posts

Showing posts from January, 2013

c# - Hash a file as its being recived -

end goal: users uploading large number of files in different sizes web site. , dont want duplicate files on disk. the solution have been using simple sh1 hash of file when uploaded. code this: public static string hashfile(string filename) { using (filestream stream = file.openread(filename)) { sha1managed sha = new sha1managed(); byte[] checksum = sha.computehash(stream); string sendchecksum = bitconverter.tostring(checksum).replace("-",string.empty); return sendchecksum; } } this "works" fine smaller files, big pain when file 30gb. hash file im reciving client. file client in "chunks" , size of chunk not static. code recives file. int chunk = context.request["chunk"] != null ? int.parse(context.request["chunk"]) : 0; int chunks = context.request["chunks"] != null ? int.parse(context.request["chunks"]) : 0; string filename = context.request["name&qu

Python with NetLogo-like graphics? -

i'm trying build model paper i'm writing , in python. problem is, graphic output updated in real-time netlogo's "world" really, help, since i'd observe dynamics , not final output. i did quick search on stack overflow , many people recommend tkinter or pygame. checked them out, seem way complex need (i want observe evolution of network). have suggestions?

ios - Error when presenting different storyboard programmatically -

i have app 2 storyboards. 1 of them main app stuff, , 1 setup storyboard set user profile. right now, have set main interface setup.storyboard . in first view controller in storyboard, in -viewwillappear:animated method, checks nsuserdefault see if setup complete. if is, execute code. - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; if ([[nsuserdefaults standarduserdefaults] boolforkey:@"userhascompletedsetup"]) { uistoryboard *sb = [uistoryboard storyboardwithname:@"main" bundle:nil]; swrevealviewcontroller *vc = [sb instantiateviewcontrollerwithidentifier:@"initialvc"]; [self presentviewcontroller:vc animated:yes completion:null]; } } i error warning: attempt present <swrevealviewcontroller: 0x7ff20a595220> on <mposetuponeviewcontroller: 0x7ff20a720b80> view not in window hierarchy! (i using swrevealviewcontroller in app menu.) i error, , view controller not switch.

d3.js - D3 translation relative to rotation -

does d3 have built in way translate object location relative rotation? for example, have rectangle that's 50x50, located @ coordinates (100, 100). rectangle rotated 45 degrees. want move 100 units "forward". i can trig hand figure out, in fiddle: http://jsfiddle.net/qh9x5/6530/ function toradians (angle) { return angle * (math.pi / 180); } var svg = d3.select("body").append("svg") .attr("width", 500) .attr("height", 500) .append("g"); svg.append('rect').attr('width', 50).attr('height', 50).attr('fill', 'blue') .attr('transform', "translate(100, 100) rotate(45)"); var h = 100; var angle = 45; var o = math.sin(toradians(angle)) * h; var = math.cos(toradians(angle)) * h console.log(o) svg.append('rect').attr('width', 50).attr('height', 50).attr('fill', 'red') .attr('transform', &qu

tfs2015 - TFS Query from Backlog created differentlly -

Image
i creating query backlog in 2 different tfs projects using link on backlog page: it generating differently each project. 1st project created in tfs2103 , upgraded 2015: the 2nd project created new in tfs 2015 after upgrade. note difference in query area path. 1 project created before upgrade uses 'under' operator. 1 create after upgrade uses '=' operator. can explain causing difference? this governed area configuration team. can find in configuration panel:

ios - blank screen appears when click on UILabel in swift -

i'm trying open iphone call screen selected number when click on uilabel hyperlink in swift. a blank screen appears 1 second , goes. no iphone call screen appears. don't know wrong in code. code in viewdidload let strphone = "080 2854 2105" let attributedphonestr = nsmutableattributedstring(string:strphone, attributes:[nslinkattributename: nsurl(string: "http://aerospace.honeywell.com")!]) lblphonecontact.attributedtext = attributedphonestr lblphonecontact.userinteractionenabled = true let gesturerecognizer = uitapgesturerecognizer(target: self, action: selector("labelpressed")) lblphonecontact.addgesturerecognizer(gesturerecognizer) function labelpressed func labelpressed() { let url:nsurl = nsurl(string: "tel://08028542105")! uiapplication.sharedapplication().openurl(url) } what wrong or missing in code. tried running on iphone device. for swift use let url:nsurl = nsurl(string: "telprompt:0

indexing - Logstash & Elasticsearch: Unwanted indexes being added -

Image
i haven't worked on elasticsearch + kibana project in while, when go on elasticsearch-head frontend now, notice addition of multiple indexes (image below) if scroll right, see logstash related files, such logstash-2015.06.26 . seems normal besides fact these elements appear (they numerous) surely must have done wrong happen, seems if logstash parsing files of unwanted directory. cannot find unusual in input or filter files. any ideas on how figure out? thank you. you scanned vulnerability scanner. since had no security on cluster, vulnerability scanner tried post urls on port 9200 caused indexes created.

java - Stop Swingworkers correctly -

i want improve gui-lag-free "live search" of database jtextfield. imagine got large database entries 0001, 0002, ... million (just example; entries contain strings). every time when press key start swingworker searching current content of jtextfield (within added documentlistener), because want search start after every press of key. lets assume i'd search "123" , enter jtextfield... the first swingworker starts when enter "1" , searches entries contain "1" , in it's done()-method sets model of jtable: public static class xrefreshen_speed_up extends swingworker<void, void> { public jxtable jxtabelle; public string sql_anweisung; public resultset mysqlresultset; public string get_sql() { return sql_anweisung; } public xrefreshen_speed_up(jxtable jxt, string str) { this.jxtabelle = jxt; this.sql_anweisung = str; } @override public void doinbackground() {

CouchDB - Is it safe to delete the view files in mrview? -

i working on project using couchdb , partition or storage dedicated couchdb files reached maximum capacity site fails connect couchdb , produces connection errors. know couch storage hungry never expect soon. have tried compacting methods such as: curl -h "content-type: application/json" -x post http://localhost:5984/dbname/_compact curl -h "content-type: application/json" -x post http://localhost:5984/dbname/_view_cleanup and, localhost:5984/dbname/_compact/all_view_documents the above commands released 2gb of storage. searched files in partition consumes of storage, found out in particular folder /usr/local/var/lib/couchdb/.dbname/mrview found view file 144gb in size in still there when used compact view documents. note: compacted document file / database file 1.6gb, total partition storage 150gb i encountered problem too. apparently these files increase when design views modified because indexes recomputed test delete files , functionall

html - Image is not coming in center with applying the css to it -

i want make image in center not able aspx code is <figure class="centercarosal"> <img src="uimages/<%#eval("logo") %>" style="height: 100px" alt=""> </figure> and class centercarosal .centercarosal{ text-align:center!important } i think missing browser specification both please try this .centercarosal { text-align: -moz-center; }

java - wifiSetEnabled(true) occasionally not working -

i'm making first app i'm not expert. btw in app i've create service should enable or disable wi-fi according boolean value i'm passing service through pending intent use start (the service, i'm using alarmmanager this). now, works fine in cases, wifi won't turn on, , i'm sure service started because complete other works it's supposed do. i first thought permission's fault, can see permission i'm using in manifest below. looking around here in stackoverflow suggested add update_device_stats permission don't think solution because said: works. important: notice can't enable when wifi turned off while, few hours. this snippet service: (tsmanagerhelper class pending intent , values) public int onstartcommand(intent intent, int flags, int startid) { boolean op2; wifimanager wifimanager=(wifimanager)getsystemservice(wifi_service); bundle bundle; if(intent!=null) { bundle = intent.getextras(); o

boot2docker - Marathon not loading docker container: Failed to get resource statistics for executor -

trying spin docker container using marathon. using docker 1.8 , marathon 0.11 , mesos 0.23 , boot2docker here how docker images , how run https://gist.github.com/manishrajkarnikar/3dad3cfb149384d080aa here how marathon post request , logs mess master , slave https://gist.github.com/manishrajkarnikar/96d2031e621201d94f7f note in containers started have "executer" @ end of container name, while mess-slave info log put warning looks searching container without executor @ end of container name , docker inspect failing causing status of task failed failed resource statistics executor 'helloworld.ed922c9d-6ed4-11e5-a8fb-aa13c24df26f' of framework 20151009-222455-1731963072-5050-5-0000: failed 'docker inspect mesos-20151009-222455-1731963072-5050-5-s0.79b421f0-2135-437c-b4be-c95dd841ba9a': exit status = exited status 1 stderr = error: no such image or container: mesos-20151009-222455-1731963072-5050-5-s0.79b421f0-2135-437c-

how to put text on floating action bar (fab) in android, let the action bar be cart and text be number of items -

screenshot bigbasket app i have achieved same thing custom layout. there way can put text above fab provided android. the floatingactionbutton extends imagebutton, not support text. if want achieve effect in link using native floatingactionbutton, you'll need create different icon each digit want represent.

Android themes change checkbox item text color -

Image
how change text color of checkbox views in android studio's styles.xml? i want create theme checkbox items color different default black like: except want box same color text. should using following in theme? <item name="android:checkboxstyle">@style/app_checkboxstyle</item> i know question asked long time ago want add solution. works sdk versions. you right in order change checkbox style in whole project, have add line theme: <style name="apptheme" parent="theme.appcompat"> ... <item name="android:checkboxstyle">@style/mycheckboxstyle</item> ... </style> and style itself, set custom text , checkbox color: <style name="mycheckboxstyle" parent="widget.appcompat.compoundbutton.checkbox"> <item name="android:textcolor">@android:color/holo_purple</item> <item name="buttontint">@android:color/holo_p

c++ - Simple calculator issues (Not outputting answers) -

just started reading c++ book , 1 of practice problems write small calculator takes input 1 of 4 arithmetic operations, 2 arguments operations, , prints out results. sadly, program works until user inputs arithmetic option. if chose multiplication, id write "multiplication" , stay there , not after. image of problem im having #include <iostream> #include <string> using namespace std; int main(){ // simple calculator program // declaring 3 variables float numberone; float numbertwo; string operationoption; // asking user 2 numbers he/she use cout << "enter first number apply arithmetic operation to: "; cin >> numberone; cin.ignore(); cout << "now enter second number: "; cin >> numbertwo; cin.ignore(); // using cin input users selection cout << "enter operation want perform." << endl; cout << "the options have are: &q

How do I turn an array of JSON objects into an array of structs with default values in Go? -

i'm working on go api can receive posts consisting of json array of objects. structure of post like: [ { "name":"las vegas", "size":14 }, { "valid": false, "name":"buffalo", "size":63 } ] let's have following struct: type data { valid bool name string size float64 } i want create bunch of data s valid set true anytime it's not specified in json false . if doing single 1 use how specify default values when parsing json in go , doing unknown number of them thing i've been able come like: var allmap []map[string]interface{} var structs []data _, item := range allmap { var data data var v interface{} var ok bool if v, ok := item["value"]; ok { data.valid = v } else { data.valid = true } id v, ok := item["name"]; ok { data.name = v } ... structs = append(structs, data) } return structs

What do the following phrases mean in C++: zero-, default- and value-initialization? -

what following phrases mean in c++: zero-initialization, default-initialization, and value-initialization what should c++ developer know them? one thing realize 'value-initialization' new c++ 2003 standard - doesn't exist in original 1998 standard (i think might difference that's more clarification). see kirill v. lyadvinsky's answer definitions straight standard. see previous answer behavior of operator new details on the different behavior of these type of initialization , when kick in (and when differ c++98 c++03): do parentheses after type name make difference new? the main point of answer is: sometimes memory returned new operator initialized, , won't depending on whether type you're newing pod, or if it's class contains pod members , using compiler-generated default constructor. in c++1998 there 2 types of initialization: 0 , default in c++2003 3rd type of initialization, value initialization added.

c# - How to add row with default values into System.Data.DataTable -

i have datatable , need add row default values , save database. bonus: awesome auto increment key column. how can achieve that? static int = 1; private void createdefault() { datacolumn column = null; datatable table = new datatable(); column = new datacolumn(); var col1 = column; col1.datatype = system.type.gettype("system.int32"); col1.defaultvalue = i; col1.unique = false; table.columns.add(column); = + 1; column = new datacolumn(); var col2 = column; col2.datatype = system.type.gettype("system.string"); col2.defaultvalue = "your string"; table.columns.add(column); datarow row = null; row = table.newrow(); table.rows.add(row); } variable i auto increment key column. insert datatable database .

c# - Where to put code to create lots of buttons in the view? -

i learning mvvm. until have window (without mvvm) in call in code behind constructor method createletterbuttons() creates buttons each letter in alphabet in stackpanel. because it’s easier creating these buttons in xaml – if want change these buttons. public selectionwindow() { initializecomponent(); createletterbuttons(); } private void createletterbuttons() { (int = 65; <= 90; i++) // - z { addletterbutton(i); } } private void addletterbutton(int i) { button button = new button(); button.content = (char)i; button.minwidth = 20; button.previewmousedown += letterbuttonmousedown; letterstackpanelauto.children.add(button); } the buttons used in window input text (just few letters) instead of keyboard. now question: should keep code in code behind window? guess correct according mvvm because these buttons part of view , used input text view. have no connection underlying data (model) guess code should not in view model, c

Xpages - How to prevent users from creating a new document if one already exists -

i'm working on notes database. want prevent user creating new document if there exists completed document from/by user. in notes classic form, have incorporated check in queryopen event (see code below) , works well. how can have similar event in xpages? lot anthony if isnewdoc mkey = evaluate("@name([cn]; @username)") set db = session.currentdatabase set view = db.getview("view-name") view.autoupdate = false set ve = view.getentrybykey(mkey) if not (ve nothing) messagebox "please note have document" continue = false else continue = true end if else continue = true end if sessionscope allows store information relevant current browser session (often used capture user-specific information). many apps tend use along lines of inituser() function - @ http://xhelp.openntf.org , example, has initcurruser() in application ssjs library. with kind of approach, run check when user first hits page in application,

java - Text printing in an infinite loop -

this question has answer here: reading , displaying data .txt file 10 answers the text printing in infinite loop. way avoid these? if (eload) { file file = new file("reservation.txt"); /** reading file */ try(fileinputstream fis = new fileinputstream(file)) { int content; while ((content = fis.read()) != -1) { // convert char , display system.out.print((char) content); /**print out result contents of file. */ } } catch(ioexception e) { e.printstacktrace(); } } ooutput shown homeworkdue sat oct 10 00:00:00 pdt 2015 23:00 23 homeworkdue sat oct 10 00:00:00 pdt 2015 23:00 23 homeworkdue sat oct 10 00:00:00 pdt 2015 23:00 23 can add system.out.print(content); after system.out.print((char) content); i'm not knowledgeable yet in

java - Error when trying to populate JTable from mysql using arraylist -

i have tried populate data mysql jtable although got size of rows printed. couldnt figure out what's wrong on loop used following code , got error mentioned in end. however, query works on dbms. one select data database public class search{ public arraylist<string []> select_by_book(){ arraylist<string []> data = new arraylist<>(); try { string query="select * " + "from detail d " + "join user_editor_author uea on d.detail_id = uea.detail_id " + "join author on a.author_id = uea.author_id " + "join editor e on e.editor_id = uea.editor_id " + "join user u on u.user_id = uea.user_id" + "where d.reference_type = 'book'" + "and u.user_id="+loginandregister.id; resultset rs = connect.get(query); while(rs.next()){

r - count adjacent NAs in data.frame column -

i add column "na_count" counts adjacent nas in column value, like value na_count 8 0 2 0 na 4 na 4 na 4 na 4 5 0 9 0 1 0 na 2 na 2 5 0 na 3 na 3 na 3 8 0 5 0 na 1 is there perhaps way dplyr window functions? here option using dplyr (as author asked for). create grouping column taking difference of logical vector ( !is.na(value) ), compare 1 , cumsum , create 'na_count' multiplying logical vector number of elements in group ( n() ). library(dplyr) df1 %>% select(-na_count) %>% #removing column not needed group_by(grp=cumsum(c(true,abs(diff(!is.na(value)))==1))) %>% mutate(na_count = is.na(value)*n()) %>% ungroup() %>% select(-grp) or can convert 'data.frame' 'data.table' ( setdt(df1) ), grouped rleid of logical ve

coldfusion - jQuery Datatables/CF variable issue -

Image
i using jquery datatables , coldfusion along sql database. trying figure out way have status field show processing if there no date date_complete , completed if there date in date_complete . doing on html cf side if statement. but since posting completed or processing in column when try call in js date not providing date providing terminology now. on picture below see date complete: completed should show date. any appreciated. database table html <table id="processing" class="table table-hover"> <thead> <th></th> <th><b>item id</b></th> <th style="display:none;"><b>dealer id</b></th> <th style="display:none;"><b>date received</b></th> <th style="display:none;"><b>op id</b></th> <th><b>due date</b></th> <th>

ssl - Client Certificate Authentication with Xamarin iOS -

i've managed use client certificates .net httpwebrequest class i'm trying update modernhttpclient support client certificates it's using more efficient ios libraries requests. i've modified didreceivechallenge function in nsurlsessionhandler check clientcertificate challenges , attempted follow through information on https://developer.apple.com/library/ios/documentation/cocoa/conceptual/urlloadingsystem/articles/authenticationchallenges.html , convert work xamarin ios. code compiles correctly , stepping through causes no errors printed out still system.net.webexception thrown message 'the server "xxx.example.com" requires client certificate'. my code below... public override void didreceivechallenge(nsurlsession session, nsurlsessiontask task, nsurlauthenticationchallenge challenge, action<nsurlsessionauthchallengedisposition, nsurlcredential> completionhandler) { ...snip... if (challenge.protectionspace.authenticationme

html - How to spread a div to cover available space in a parent container? -

let's have div container , container dynamically resized third-party javascript code. <div class="container"> <div class="header"> ...some content... </div> <div class="body"> ...body content... </div> </div> is there css way how let body div spread available horizontal , vertical space of parent container? note can't set fixed height on header div because content generated on fly , it's not same height. css flexbox can if height of container isn't known/set explicitly: .container { width: 348px; /* random value simulate being set javascript */ border: 1px solid black; /* here demonstration purposes */ display: flex; flex-direction: column; -webkit-flex-direction: column; } .body { background: tomato; height: 100%; } <div class="container"> <div class="header">

c# - DNN Module TSQL order -

to preface: producing dnn module(a) dependency on released module(b) , should not modify other module(b). i having problem retreiving information sql table should modified module b. module b may delete row on page_load, need generate controls based on info in sql table. i have tried waitfor delay '00:00:xx'; precede sql commands in module a, unfortunately, merely prolongs page_load , delete on module(b) occurs during/after page_load. i contemplated using unload event, controls can not added after page rendered. currently redirecting twice every postback, seems hacky, , implement smoother solution if possible. again, modules have on same page, , cannot modify module b.

.net - MobileService Publish does not change the Mobileservice -

Image
i have mobileservice , running, 1 function stopped getting updated when publish, , no errors. other when want contact it. the code function was: [route("api/game/getcurgame")] [authorizelevel(authorizationlevel.user)] public async task<ihttpactionresult> getcurgame(dto.returngamefounddata search) { services.log.info("getcurgame function"); using (db db = new db()) { try { dto.returngamefounddata ret = new dto.returngamefounddata() { playersturn = true, gameid = search.gameid, navigationparameter = 1 }; //services.log.info("getcurgame function"); return ok(ret); } catch(exception) { dto.returngamefounddata ret = new dto.returngamefounddata() { playersturn = false, gameid = search.gameid, navigationparameter = -1 }; return ok(ret); } } } so simpl

odoo - How to create a field for project sale orders -

i have fields quick access of entities related project. example: class project(models.model): _name = "project.project" _description = "project" _inherit = 'project.project' production_order_ids = fields.one2many('mrp.production', 'project_id', 'production orders') purchase_order_ids = fields.one2many('purchase.order', 'project_id', 'purchase orders') .... i trying create sale_order_ids in project.project model. first try did not work: sale_order_ids = fields.one2many('sale.order', 'project_id', string='sale orders') because because field sale.order .project_id of type account.analytic.account . a project.project object inherits account.analytic.account . query should work ok if share same id, not. navigation be: "project.project".analytic_account_id" -> sale.order".project_id and result corresponding sale.order (s)

rss - Joomla fetching feed issue after an upgrade -

i have feed problem , hope can me. few days ago upgraded joomla 2.5.28 3.4.4. process successful, , thought ok, noticed k2 feed isn't being fetched partner website. have 6 partners whom using rss ( http://my.site/index.php?option=com_k2&view=itemlist&layout=category&itemid=200&format=feed ), , 5 6 still working, 1 of them doesn't fetch. strange, because partners using same feed link. tried things, removed old, unnecessary components, disabled unnecessary plugins, nothing changed. upgrade caused this, no doubt, don't know how. maybe problem feed fetching stopped @ partners site, , can't start again, want can this. there method force feed refresh @ partner site, or have other idea? list of things tried: - disabled unnecessary component - disabled unnecessary plugins - updated components, modules , plugins - removedd system cache , expired cache in administrator section i hope have ideas. in advance! since feed working 5 other partners, pr

pug - In a Jade template how do I put a literal URL as a link anchor? -

in node.js express web app, include link documentation in 1 of views, , show url anchor text. following jade: links inside paragraph , tried: p see #[a(href="http://example.com/help/123") http://example.com/help/123] however, causes error, "the end of string reached no closing bracket found." if put quotes around anchor text, works, end quotes visible in html output, don't want. p see #[a(href="http://example.com/help/123") "http://example.com/help/123"] is unquoted url messing evaluation of stuff inside brackets? if so, can escape somehow prevent problem? use variable: -var helpurl="http://example.com/help/123" p see #[a(href=helpurl) #{helpurl}] the double slash in url being interpreted start of comment, , preventing evaluator reading rest of expression, including closing bracket. edit : issue kindly opened @laggingreflex ( https://github.com/jadejs/jade/issues/2144 ), colon-slash sequence problematic

uml - XMI suitable as file format for team-developing a Sparx EA model via version control (SVN)? -

i thought putting sparx enterprise architect uml model in our svn repository. .eap project file large binary , that's why not suitable, can export/import via xmi 2.1 file format manage model text file. 2 questions: is xmi-approach idea developing uml model in team, based on svn source control? i noticed every export xmi file changes ea_localid attribute values in xml tags, , seems make impossible me letting sharing base on xmi, since it'll result in huge disturbing diff. idea? you can put packages under svn version control. lock packages exclusive use. 1 person can check out package , make changes until checking in again. from personal experience not recommend path unless have distributed system bad wlan. in case use of ea version control solution. generally should put repository on server (ms sql, mysql, postgres, oracle, etc. whatever supported natively ea or via odbc). turn on ea security (which misleading name since not in way security, accidental d

pointer assignments not holding through multiple functions c++ -

i'm writing small program simulate schedulers inside os , during execution noticing when assign new value head pointer of linked list not carry on next function. if don't have written. //insert @ head of event queue if(ecursor == ehead){ cout << "insert @ head" << endl; eve->prev = null; eve->next = ecursor; ecursor->prev = eve; ehead = eve; ecursor = eve; } ive double checked insert login make sure im not missing anything, , works other insertions. @ point never assigns head pointer correctly. after insert head pointer read main body of program displays time @ event take place (presumably event in made head equal to) event type: 2 check events in queue ecount: 1 check event order eve->time: 0.0667091 ecursor->time: 0.0108831 insert after tail scheduling arrival: 1 event type: 1 check events in queue ecount: 1 check event order eve->time: 0.015281 ecursor->time: 0.0667091

cmdlets - Determining internet connection using Powershell -

is there simple cmdlet can run in powershell determine if windows machine connected internet through ethernet or through wireless adapter? know can determine on gui, want know how can managed in powershell. the powershell cmdlet get-netadapter can give variety of info network adapters, including connection status. get-netadapter | select name,status, linkspeed name status linkspeed ---- ------ --------- vethernet (meandmahvms) 10 gbps vethernet (theopenrange) disconnected 100 mbps ethernet disconnected 0 bps wi-fi 2 217 mbps another option run get-netadapterstatistics show stats connected device, use way of knowing connected web. get-netadapterstatistics name receivedbytes receivedunicastpackets sentbytes sentunicastpackets ---- ------------- ---------------------- --------- -----------------

c++ - QByteArray from QFile -

i want read byte array 3d texture. qfile file(filename); if(!file.open(qiodevice::readonly)) { return false; } qbytearray* data = new qbytearray(file.readall(), m_imagewidth*m_imageheight*m_imagecount ); glgentextures(1, m_textures); glactivetexture(gl_texture0); glbindtexture(gl_texture_3d, m_textures[0]); glteximage3d(gl_texture_3d, 0, gl_luminance, m_imagewidth, m_imageheight, m_imagecount, 0, gl_luminance, gl_unsigned_byte, data); can this? access violations in project , want check if come here. it write violation @ glteximage3d() your data variable holds pointer place in memory qbytearray object stored, actual data encapsulates stored somewhere else. when glteximage3d tries read big block of memory starting @ data pointer, runs unmapped memory. to pointer acutal data, use data->constdata() instead. qbytearray::constdata

RegEx Issue: Preg_Match Only 2 non consecutive spaces, no special characters [PHP] -

so class simulating putting in first, middle, , last name form. have variable $fullname concats them , pulls out middle initial strtolower , ucfirst ... so robert james smith parsed robert j smith . now if put r!bert j smith (note special character" ! ") accepted. combat did if / else statement pregmatch . if (preg_match("/[^a-z\s]/i",$fullname)) { echo ("<span class = 'warning'>invalid user name!</span>"."<br>" ."please use characters a-z name."."<br>"); exit; } else { echo ("user name: ".$fullname."<br>"); } this says if there besides letters , whitespace, throw echo message. now have run issue if enter r obert j smith . (note space character inbetween r , o ). because allow whitespace says okay. goes on mess " create username , password " functions later on. tldr

java - Sl4a run Tasker Task and pass variable -

i try start tasker task sl4a , passing variable %par1. i have found solution here: https://groups.google.com/forum/#!starred/tasker/ayw-lhctqwg it run task "test" variable %par1 isn't passed. here script: import android droid = android.android() task_name = 'test' par1 = 'test variable' extras = {'task_name': task_name, '%par1': par1} taskintent = droid.makeintent('net.dinglisch.android.tasker.action_task', none, none, extras).result droid.sendbroadcastintent(taskintent) the developer "pent" has answered tip: extras = {'task_name': task_name} extras['varnames'] = namelist extras['varvalues'] = valuelist i don't know python, looks array rather array list (array list java dynamic array). so try change extras to: ... task_name = 'test' varvalues = 'test variable' varnames = '%par' extras = {} extras['task_name'] = task_name extras[

.htaccess - Directory Listing at domain level (Apache) -

i have subdomain on apache 2.4 web server (an aws ec2 host), indexes set - it's not displaying index @ top level: in subdirectories. if there no directoryindex file (index.html) @ top level ( http://stuff.example.com ), displays amazon linux ami test page. if have index.html file @ top level, it's displayed normally. i've tried find documentation indexes not displayed domain pages, , couldn't. therefore must missing in basic configuration (httpd.conf): <directory "/data/stuff"> allowoverride indexes authconfig require granted </directory> <virtualhost *:80> servername stuff.example.com documentroot /data/stuff options +indexes +followsymlinks </virtualhost> in aws ec2 configuration of apache 2.4 (at least), there additional config file /etc/httpd/conf.d/welcome.conf : <locationmatch "^/+$"> options -indexes errordocument 403 /.noindex.html </locationmatch> <dire

angularjs - Mocking a service and calling through in Jasmine -

i'm trying test service in angularjs project. i'm trying see if method on service has called through. thought when use 'and.callthrough()' in jasmine called method , can see if called. however, when test function karma giving me response of 'expected spy of getartists have been called'. describe('practice', function(){ beforeeach(module('myapp')); var ctrl, loadartists, rootscope, datafactory; beforeeach(inject(function($controller, $rootscope, datafactory){ spyon(datafactory, 'getartists').and.callthrough(); datafactory = datafactory rootscope = $rootscope; scope = rootscope.$new(); ctrl = $controller('launchctrl',{scope: scope, artistspicsrotate: []}); })); it('should nothing',function(){ expect(ctrl.artistspicsrotate).toequal([]) }); it('should call through datafactory', function(){ expect(datafactory.getartists).tohavebeencalled(); expect(datafactory.getartists.calls.c

sql server - To add a column to a view -

i working on view in sql server 2012 long (has around 800 columns). allow users add custom columns table(a separate ui allows user specify column name, type , max length).once column added table, must reflected in view too. there way automatically accomplish ? right now, need create alter view statement existing 800+ columns , newly added column. also, can sp_refreshview used purpose? looking answers. in advance. if manually set columns included view (i mean select column1, column2 from ), automatic update isn't possible. if select * used in view (bad practice), there solution : exec sp_refreshview [dbo.v_customer] and more common form here (update views).

How to load a Javascript file without Script tag? -

i have code have nested <script> tag, inner script tag nothing loads javascript file using src attribute. because, how in code, inner script tag closing outer script. since inside javascript mode, there way load script without using <script src=""> call? var js = document.createelement("script"); js.type = "text/javascript"; js.src = "path_to_the_file.js"; document.body.appendchild(js); but asynchronous, have wait until script loaded use - var js = document.createelement("script"); js.type = "text/javascript"; js.src = "path_to_the_file.js"; js.onload = function() { //code using script here }; document.body.appendchild(js);

java - Can I run long tasks in a Spring Boot application? -

i have spring boot application, shows data mongodb on angularjs page , allows user change it. now need create mechanism, allows me to run long (1-3 hours) java method, which produces files and observe state via web (does run, finished, did crash?). can implement in scope of spring boot application? if yes, parts of spring can use that? i argue it's not idea embed batch processing service exposing mongodb data store. i create separate batch application . spring batch natural choice if using spring stack. need figure out how want host spring batch job , how want trigger , schedule it. spring batch needs sql storage it's metadata . status of batch processing monitored 1 other application spring batch admin module running on servlet container . if point application sql storage of spring batch job application, monitoring of status via web ui out of box . of course run each app spring boot. if don't want handle operational complexity brings host

r - SAX function of TSclust package generate an error -

i using tsclust package sax (symbolic aggregate aggregation) plots. in accordance example shown on page 25 , using function sax.plot(as.ts(df$power), w=30, alpha=4) but, generates error as: error in if ((n <- as.integer(n[1l])) > 0) { : argument of length 0 i not able debug it. looked source code of sax.plot function not find relevant error message typed in. the required r dataobject can found @ link r version: 3.2 tsclust version:1.2.3 hello apparently it's because need normalize data, check out example : # parameters w <- 30 alpha <- 4 # paa x <- df$power paax <- paa(x, w) plot(x, type="l", main="paa reduction of series x") p <- rep(paax,each=length(x)/length(paax)) #just plotting paa lines(p, col="red") # sax convert.to.sax.symbol(paax , alpha) # [1] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 # need scale paa result convert.to.sax.symbol(scale(paax) , alpha) # [1] 1 1 1 1 1 1

auto increment - nature key vs auto_increment key as the primary key -

my problem nature key , auto_increment integer primary key. for example, have tables a , b , a_b_relation . , b may object, , a_b_realtion record many many relation of , b. both , b have own global unique id, such uuid. uuid available user, means user may query or b uuid. there 2 ways design table's primary key. use auto_increment integer. a_b_relation reference integer fk. use uuid. a_b_relation reference uuid fk. for example, user want query b's info associate a's uuid. for first case, query flow this: first, query a's integer primary key uuid `a`. , then, query b's integer primary key `a_b_relation`. @ last, query b's info `b`. for latter case, flow below: query b's uuid `a_b_relation` a's uuid. query b's info `b`. so think, latter case more convenient. right? what's shortage of latter case? according opinion convenience of using either natural key of auto-increment key depends on program solution pr

What is the best way to get windows full name from go? -

in windows, can run systeminfo | findstr /c:"os name output windows full name console. i've tried couple different variations of piping output 1 command other, empty strings. example first := exec.command("systeminfo") second := exec.command("findstr /c:'os name'") reader, writer := io.pipe() first.stdout = writer second.stdin = reader var buffer bytes.buffer second.stdout = &buffer first.start() second.start() first.wait() writer.close() second.wait() output := buffer.string() log.printf("output: %s", output) ` are there built in methods information? one way use golang.org/x/sys/windows/registry package. a simple example: package main import ( "fmt" "golang.org/x/sys/windows/registry" ) func main() { key, _ := registry.openkey(registry.local_machine, `software\microsoft\windows nt\currentversion`, registry.query_value) // error discarded brevity defer key.close()

Get text value with PHP simple HTML DOM parser -

how can text value <span>your name:<span> php simple html dom parser without children command? <div class="adds-info"> <span>price:<span>1000000000 </span></span> <span>txt1</span> <span>your name:<span>aaa</span></span> <span>phone:<span>02632402210</span></span> </div> php simple html dom parser api assuming html in post in variable $str , straightforward: // parse html string dom object $html = str_get_html($str); // find second nested span inside <div class="adds-info">, parent $span = $html->find('.adds-info span span', 1)->parent; // innerhtml of parent span $name = $span->innertext; if number of elements changes, need check each 1 text you're looking for... // spans inside <div class="adds-info"> $spans = $html->find('.adds-info span'); // loop through each

javascript - Show commands' labels in AppBar with More button -

so i've got myself appbar in winjs uwp app <div data-win-control="winjs.ui.appbar" id="appbar" data-win-options="{ closeddisplaymode : 'compact', placement:'bottom'}"> <button data-win-control="winjs.ui.appbarcommand" data-win-options="{id:'flyoutbutton', type:'flyout', label:'třída', icon:'otheruser', flyout:select('#classflyout')}"></button> <button data-win-control="winjs.ui.appbarcommand" data-win-options="{id:'flyoutbutton', type:'flyout', label:'schovávání hodin', icon:'calendarday', flyout:select('#hidingflyout')}"></button> <button data-win-control="winjs.ui.appbarcommand" data-win-options="{id:'morebutton',label:'more',icon:'more',sect

Cassandra Data Modeling - Design Concept -

i new cassandra, trying understand concepts. please me : here have data of citizens language , state. create table citizens_by_state_and_language( citizenid bigint, state varchar, language varchar primary key((language,state), citizenid) ); i can query this select * citizens_by_state_and_language language = 'spanish' , state = 'kentucky' however these queries wont work: select * citizens_by_state_and_language language = 'spanish'; select * citizens_by_state_and_language state = 'kentucky'; now make working can create indexes on these, below: create index on citizens_by_state_and_language(language); create index on citizens_by_state_and_language(state); i not sure whether right approach in designing or should create separate tables(one query per table) each of these queries?. please throw lights concepts. that because language , state partition keys. in cassandra can't query on single partition key, have specify both