Posts

Showing posts from May, 2013

Laravel 5 Openshift Databse not connecting -

i setting laravel 5 openshift application every time had databse code in project says whoops missing. have added environment in .env in database credential still no success. wondering may cause of since followed instruction website working if omit database code. are trying database working local or remote development? .env file in root directory local development, while .openshift/.env file remote development. if you're using standard openshift database (such mysql or postgresql), shouldn't need make configuration changes database working. it's configured via environment variables.

overflow - VHDL modulo 2^32 addition -

i working on vhdl implementation of sha-256 hash function. have 32-bit unsigned signals defined such: signal a, b : unsigned (31 downto 0); within specifications of sha-256 algorithm, says addition must performed modulo 2^32 in order retain 32-bit size in case of overflow. now, according answer this question, sounds overflow handled modular addition in vhdl: there no overflow handling, overflow carry lost. result integer result of operation modulo 2^max. i have 2 questions: in case, max = 31 mean addition operation perform on a , b modded 2^31? i need perform addition modulo 2^ 32 doesn't make sense since working 32-bit numbers , 2^32 1 bit large. somehow implied should modding 2^ 31 ? you fine unsigned(31 downto 0) . 2^max in post reference error , should read 2^length . length of 31 downto 0 32. think it, 31 downto 0 can represent numbers 0 2^32-1, wouldn't make sense if addition of range modulo 2^31 if can represent larger numbe...

node.js - Hash mismatch (integrity check failed) with Azure Blob Storage -

i'm following http://willi.am/blog/2014/07/03/azure-blob-storage-and-node-downloading-blobs/ . however despite exact same code, when download blobs azure gives error: [error: hash mismatch (integrity check failed), expected value ...] the line being run blobservice.getblobtotext, blobservice being connection azure (createblobservice...) what's going on? :s my code's below: // azure test function downloadimageastext(blobservice, containername, blobname) { blobservice.getblobtotext( containername, blobname, function(err, blobcontent, blob) { if (err) { console.error("couldn't download blob %s", blobname); console.error(err); } else { console.log("sucessfully downloaded blob %s", blobname); console.log(blobcontent); } }); ...

converting "&" in C to C# -

some c code #include aes.h void encryption(unsigned char aes_key[16], unsigned char _buff[16], unsigned char _iv[16]){ unsigned long encrypt = 1; unsigned char output[]; aes_set_encrypt_key(aes_key, 128, &key); for(i = 0; > 16 ; ++){ aes_cbc_encrypt(&_buff[i], output, 16, &key, _iv, encrypt); } } how '&_buff[i]' in c#? i've been trying use _buff[i] in c# gives different result. know how this? big help. i think looking these search terms: c# string pass reference that c code wrong , bad example. in general, can pass string in order change it. see example below change(buf) . change(&buf[0]) work, it's weird. or can change(buf+3), change string beginning @ 3rd character. void change(char *buf){ strcpy(buf, "changed"); } int main(){ char buf[50]; strcpy(buf, "0123456789"); change(buf);// result => buf = "chagned" //change(&buf[0]);//result => buf =...

Google spreadsheets in-cell string length validation -

i have column want write down numbers, numbers long, 25 characters, , miss type @ least knowing have typed correct amount of characters helpful. when typing in google spreadsheets, can validate answer of column within column using: '=if(len(b1)=25,b1,"wrong number of digits")' which means return cell value if has 25 characters, if other amount wrong number, yet need use column... is there way while typing in cell let me proceed if right number of characters or give error if have wrong number of characters, in same column? untested please try data, validation..., rule of: =and(b1>999999999999999,len(b1)=25)

python 2.7 - InsecurePlatformWarning Using Tweepy -

i'm using python 2.7.7 on mac book air. i've copied code official tweepy documentation - http://docs.tweepy.org/en/latest/streaming_how_to.html?highlight=stream . import tweepy consumer_key = "***" consumer_secret = "***" access_token = "***" access_token_secret = "***" auth = tweepy.oauthhandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.api(auth) class mystreamlistener(tweepy.streamlistener): def on_status(self, status): print(status.text) mystreamlistener = mystreamlistener() mystream = tweepy.stream(auth = api.auth, listener=mystreamlistener()) mystream.filter(track=['@soroushg_']) but whenever run code says insecureplatformwarning: true sslcontext object not available. prevents urllib3 configuring ssl appropriately , may cause ssl connections fail. if knows why love know. in advance. it's pip problem, had update pip! ...

swift - How to clear UITextView upon Editing? -

i have following code: class newpostcontroller: uiviewcontroller { @iboutlet weak var messagefield: uitextview! override func viewdidload() { super.viewdidload() messagefield.text = "what's on mind?" messagefield.textcolor = uicolor.lightgraycolor() } func textviewdidbeginediting(messagefield: uitextview) { if messagefield.textcolor == uicolor.lightgraycolor() { messagefield.text = "" messagefield.textcolor = uicolor.blackcolor() } } however, whenever edit messagefield , code within textviewdidbeginediting doesn't run. suspect because of invalid way of referencing messagefield within function, don't know do. looks you're not setting uitextview 's delegate . class viewcontroller: uiviewcontroller, uitextviewdelegate { @iboutlet weak var mytextview: uitextview! override func viewdidload() { super.viewdidload() mytextview.delegate = self } func textviewdidbeginediting(textview: u...

colors - Windows CMD Keyword Highlighting -

is possible change color of keywords in windows cmd.exe? commands "ls, cd, pwd, etc." different colors. also, i've tried "color 1d" using list comes running "color /?", colors of text. i'm looking colors command line keywords. i have extensions console2 , clink; don't think have such features. any appreciated.

osx - How to change the tk version of your Python installation? -

i have removed old python framework using this procedure , , have installed python 3.4.3 architecture, appears i386 according following command uname -p , have downloaded , installed following version mac os x 32-bit i386/ppc installer . now, want use tkinter , seems using tcl/tk version 8.4 instead of lastest 1 8.6 : >>> tkinter.tclversion 8.4 >>> tkinter.tkversion 8.4 >>> now, have cheked under directory /library/frameworks/tk.framework/ versions have installed, result is: 8.5 8.6 current which means python distribution have installed using version of tcl/tk somewhere else. now, how change tcl/tk version being used?

javascript - ChartJS Legend Not Lining Up -

i creating legend line graph generated using chartjs. problem running color boxes in legend not lining correctly. here how generate legend: var chartlegend = "<ul style=\"list-style-type: none;\">"; for(var = 0; < chartdatas.datasets.length; i++) { chartlegend += "<li><div style=\"background-color:" + chartdatas.datasets[i].pointcolor + ";height:20px; width:20px; float:left; margin:5px;\"></div>" + chartdatas.datasets[i].label + "</li>" } chartlegend += "</ul>"; here full code is possible line boxes? var chartlegend = "<ul style=\"list-style-type: none; padding: 0\">"; for(var = 0; < chartdatas.datasets.length; i++) { chartlegend += "<li><span style=\"background-color:" + chartdatas.datasets[i].pointcolor + ";height:20px; width:20px; display:inline-table; margin:5px;\"></span...

excel - Copying a variable based range of cells to another Range -

hello code should evident trying @ point. attempting copy range of cells static portion of worksheet created column keep running error on part of formula i'm hoping here has either solution error, or better method of taking 1 range of cells can static , bringing hard reference point sub mapping() dim map worksheet dim ath worksheet dim lastmap long dim lastath long set ath = sheets("athena greek god") set map = sheets("mapping") lastmap = map.cells(rows.count, "d").end(xlup).row lastath = ath.cells(rows.count, "a").end(xlup).row columns("a:a").select selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove range("a1") = "edited" range("b1") = "edited 2" range(...

sql - Check if value is in different table -

so new sql , have little experience it. please excuse if basic can't seem find after googling... so have table contains serialnumber field. have single inputfield contains comma seperated values each 1 being serialnumber. want display serialnumbers in comma seperated string. so have splitstring function can use splits string @ commas this: select * dbo.splitstring('sn1,sn2,sn3,sn4,sn5,sn6', ',') this returns table each sn being row. so want this: select * tbl_serials sn sn.serialnumber in dbo.splitstring('sn1,sn2,sn3,sn4,sn5,sn6', ',') so display rows serialnumber inside string. don't know how syntactily construct this. any appreciated one method using join : select sn.* tbl_serials sn join dbo.splitstring('sn1,sn2,sn3,sn4,sn5,sn6', ',') ss(val) on sn.serialnumber = ss.val; with route, need subquery: select sn.* tbl_serials sn join sn.serialnumber in (select val ...

JQuery - Increase value output for each 50 entered -

i've got simple text box users enter number - update multiple elements on page value. at moment script multiple number entered set amount. $('input').keyup(function() { var v = $(this).val(); v = isnan(v)?'':v; $(this).val(v); $("#spot1 span").html(v * 100); $('#spot2 span').html(v * 200); }); html: <div><input id="number" name="number" type="text"><br /></div> <div id="spot1">section 1: <span></span><br /></div> <div id="spot2">section 2: <span></span><br /></div> what have output section 2 based on increasing in digest times x entered input box eg. less 50 section 2 shows 1, , every 50 entered increases 1. so, if number 250 entered, section 2 show 4 use division in-line, try sample entering in '250' $('input...

matlab - How to create block image? -

i have 2000 images, size of each xi=320*512 double (i=1:1:2000). want regard each image 1 block, there 2000 blocks, , put them in 1 big image. each block there label corresponding it, label ranges 1 10. question how put 2000 images big block images label each block described above? i have 2000 images this. can tell me how put kind of images blocks? my comment incorrect, reshape not solve problem. however, did use reshape create example array of images. % replace these 320, 512, , 2000. nx = 2; ny = 3; nz = 4; % nz images, each of size nx ny images = reshape(1: nx * ny * nz, nx, ny, nz) % put each image larger image composed of n1 * n2 blocks n1 = 2; n2 = 2; image = zeros(n1 * nx, n2 * ny); % note, nz == n1 * n2 must true iz = 0; i1 = 1: n1 i2 = 1: n2 iz = iz + 1; image((i1 - 1) * nx + 1: i1 * nx, (i2 - 1) * ny + 1: i2 * ny) ... = images(:, :, iz); end end image this creates big block image correctly. may want change inner/...

image - Plot gradients using PIL in Python -

Image
i'm creating images using python, basics. thing i'm using myimage = image.new('rgb', (250, 250), 'rgb(155,89,182)') and well, creates image. but, there way create image background of color i'm choosing gradients? let me explain little bit more, want pick blue color, then, want deep blue in edges , more light blue in center of image. possible using simple pil , python? thank in advance. the code depends on how want gradient look. make rectangular gradient this: or make round gradient this: this code round gradient: import image import math imgsize = (250, 250) #the size of image image = image.new('rgb', imgsize) #create image innercolor = [80, 80, 255] #color @ center outercolor = [0, 0, 80] #color @ corners y in range(imgsize[1]): x in range(imgsize[0]): #find distance center distancetocenter = math.sqrt((x - imgsize[0]/2) ** 2 + (y - imgsize[1]/2) ** 2) #make on scale 0 1 distance...

javascript - How to enter value of datepicker into text field -

i have list of tasks , each task has edit date option use jquery datepicker for. this application.js: $(function() { $('.date').datepicker({dateformat: 'yy-mm-dd'}); }); this _edit_form.html.erb: <%= form_for task |f| %> <div class='form-group'> <%= f.text_field :description, placeholder: 'create task' %> </div> <div class='form-group'> <%= f.label :due_date %> <%= f.text_field :due_date, placeholder: 'select date', class:"date", readonly: 'readonly' %> </div> <%= button_tag(type:'patch', class:"btn btn-default btn-xs") %> <span class='glyphicon glyphicon-plus'></span> <% end %> <% end %> so problem datepicker works first task on list. can pick date, it'll show in text field , it'll pass task#update controller fine. however, every task after isn't able rece...

android - Want to display 2 buttons vertically on top of each other, starting from the centre of the screen - only one button displays -

this first time using xml , working android noob. want have 2 buttons; sign in , create account , sign in @ centre of screen , create account directly beneath it. what have create account button , it's @ top of screen not centre. reason, sign in doesn't appear anywhere. can take @ xml doc , see if can spot why happening? <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:padding="25dp" android:layout_height="match_parent"> <button android:id="@+id/bsignin" android:text="signin" android:layout_centerhorizontal="true" android:layout_width="match_parent" android:layout_height="wrap_content" /> <button android:id="@+id/bcreateaccount" android:text="create ac...

Building CUDA-aware openMPI on Ubuntu 12.04 cannot find cuda.h -

i building openmpi 1.8.5 on ubuntu 12.04 cuda 6.5 installed , tested default samples. intend run on single node following configuration: dell precision t7400 dual xeon x5450 nvidia gt730/tesla c1060 the configure command issued was $ ./configure --prefix=/usr --with-cuda=/usr/local/cuda in generated config.log, clear the configure script not able find cuda.h , cuda_runtime_api.h in /usr/loca/cuda/include, exist. for cuda.h: configure:73774: checking cuda.h usability configure:73774: gcc -std=gnu99 -c -o3 -dndebug conftest.c >&5 conftest.c:645:18: fatal error: cuda.h: no such file or directory compilation terminated. configure:73774: $? = 1 configure: failed program was: | /* confdefs.h */ for cuda_runtime_api.h: configure:73857: checking cuda_runtime_api.h presence configure:73857: gcc -e conftest.c conftest.c:612:30: fatal error: cuda_runtime_api.h: no such file or directory compilation terminated. ...

linux - Bash: How to list only files with read permissions? -

this question has answer here: find writable files in current directory 10 answers how can list files read permissions on current directory ? find -maxdepth 1 -type f -perm xxx where xxx indicate file permission on targer file, according question .

html5 - Does the title tag have content? -

from point of view, content has come defined 2 separate things in html: 1) of information between open , closed body tags visible on webpage. 2) visible on webpage placed between any open , closed tags. this may seem knit-picky, it's important when teaching concept of html content -- believe in establishing , holding consistent definitions when teaching computer programming terminology. is number 1 correct? -- in case <title> not have content. or number 2 correct? -- in case <title> have content. "content" in context of html not subjective. lucky enough have a spec defines everything , there's no "point of view" had. the spec defines every element's content model, defined "a normative description of content must included children , descendants of element." 3.2.4 content models each element defined in specification has content model: description of element's expected contents . html e...

sprite kit - Updating physics body when animating with SKAction moveTo -

i have 'bar' moving , forth, have correctly gotten move sprite right left. seems physics body still in same place originally. can make contact 'bar' when has animated away. does know how can fix this? - (void)setupbars { leftbar = [barnode new]; leftbar.anchorpoint = cgpointmake(0, 0); leftbar.name = @"leftbar"; leftbar.size = cgsizemake(cgrectgetmidx(self.frame), 50); [leftbar setposition:cgpointmake(0, cgrectgetmidy(self.frame) + 275)]; leftbar.physicsbody = [skphysicsbody bodywithrectangleofsize:leftbar.size]; leftbar.physicsbody.dynamic = no; leftbar.physicsbody.contacttestbitmask = nodebitmask; [self addchild:leftbar]; rightbar = [barnode new]; rightbar.anchorpoint = cgpointmake(0, 0); rightbar.name = @"rightbar"; rightbar.size = cgsizemake(cgrectgetmidx(self.frame), 50); [rightbar setposition:cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame) + 275)]; rightbar.p...

php - combine two arrays of arrays by key -

how combine 2 arrays of arrays key? for example:- array 1: array ( array ( 'id' => '1', 'a' => 'abc' ), array ( 'id' => '2', 'a' => 'def' ) ) array 2: array ( array ( 'id' => '2', 'b' => '456' ) array ( 'id' => '1', 'b' => '123' ), ) combined array: array ( array ( 'id' => '1', 'a' => 'abc', 'b' => '123' ), array ( 'id' => '2', 'a' => 'def', 'b' => '456' ) ) the combined array order isn't important, should match based on provided field instead of natural order. what tried. doesn't efficient though. public function combinearraysbykey($array_1, $array_2, $key = 'id') { $combined_array = array(); for...

instagram - Find username with userID and without access_token -

are there ways, find user userid , without access token? you can use endpoint client_id , documentation on instagram says access_token required, works client_id https://api.instagram.com/v1/users/{user-id}/?client_id={client_id}

c# - Possible to wrap Expression<> and Func<> after Func defined? -

i create 2 kinds of identical mapping functions in view models map pocos, 1 queryables , 1 collections. possible create 1 method both can remove duplicate code? i'd keep expression<func<>> use on local collections , entity framework. public class myviewmodel { public static readonly expression<func<mypoco, myviewmodel>> asmap = (e) => new importpattern { id = e.id, name = e.name } public static readonly func<mypoco, myviewmodel>> tomap = (e) => new importpattern { id = e.id, name = e.name } public int id { get; set; } public string name { get; set; } } examples: asmap succeeds entity framework project fields listed in mapping function. var = product .where(p => p.id > 0 && p.id < 10) .orderby(q => q.id) .select( importpattern.asmap ); tomap works on local collections. var products = pr...

excel - Lookup Value in Same Column on Multiple Worksheets -

in column b on 3 (bakery, floral, grocery) of 5 sheets in workbook, want find rows have word flyer in column b. there multiple rows in each worksheet have word flyer in column b. when finds word flyer , paste entire row sheet1. i go work on 1 tab, want same code search 3 tabs (but not 5 ... issue) , paste of rows word flyer in column b sheet1. my code (works, on bakery tab): sub copyrowsflyer() 'this looks in bakery tab , moves has "flyer" in column b sheet 1 dim bottomb integer dim x integer bottomb = sheets("bakery").range("b" & rows.count).end(xlup).row: x = 1 dim c range each c in sheets("bakery").range("b3:b" & bottomb) if c.value = "flyer" c.entirerow.copy worksheets("sheet1").range("a" & x) x = x + 1 end if next c end sub similar other solutions posted. pretty simple. replaces bounding range checking. fewest variables. no ...

android - I am using AsyncTask for a splashscreen and database load in multiplaces. Is this a good idea? -

i have splash screen , main activity. idea show splash while doing db loads. can not use emulation mode not work same apk install directly on phone. when apk installs splash screen shows 5 seconds db listview screen shows. correct. when press application launch icon on phone splash not appear, white screen shows splash screen time , db listview appears. here associated files, supply more if needed: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.loadrunner" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity ...

c# - FluentNHibernate HiLo - can be maxLo read from table and not to be hardwired in code? -

i using generatedby.hilo(string table, string column, string maxlo, string where); for primary key. looking possibility how load maxlo table rather store constant in code. value nexthi loaded database table (ok, must otherwise whole concept not working @ all). did not find way how load maxlo table too. quick code study seems not possible, still maybe missing something. reason why need it: have business application , separate config application needs use same maxlo consistency of ids if inserts tables. of course application can run exclusively. 2 possible workarounds: - can have shared dll maxlo stored - can use table in database , load maxlo on own but still fine want without workarounds. fluentnhibernate version: 2.0.1.0 i wish have the answer, mine is: no. have pass values setting. reason way how table hi-lo generator implemented. check tablehilogenerator code .configure() /// <summary> /// configures tablehilogenerator reading value of <c>t...

ios - Objective-C - What Types of Problems Can Occur When Updating UI Off Main Thread -

i had job interview morning , presented following code , asked find problem: @interface ttwaitcontroller : uiviewcontroller @property (strong, nonatomic) uilabel *alert; @end @implementation ttwaitcontroller - (void)viewdidload { cgrect frame = cgrectmake(20, 200, 200, 20); self.alert = [[uilabel alloc] initwithframe:frame]; self.alert.text = @"please wait 10 seconds..."; self.alert.textcolor = [uicolor whitecolor]; [self.view addsubview:self.alert]; nsoperationqueue *waitqueue = [[nsoperationqueue alloc] init]; [waitqueue addoperationwithblock:^{ [nsthread sleepuntildate:[nsdate datewithtimeintervalsincenow:10]]; self.alert.text = @"thanks!"; }]; } this initiate ui updates off of main thread, no-no. my question is, why, specifically? types of issues 1 expect when updating ui away main thread? my question is, why, specifically? because apple specifically tells us, on uiview reference page...

javascript - Loading more posts on WP site using AJAX -

i have site on wp. , i'm trying load posts ajax. difference other such problems have no pagination, post section simple: 2 posts near , button below. on click on button 2 posts append previous 2 posts. tried write solution myself, have little expirience in php , maybe in problem. post structure: <div class="row"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 news-item"> <div class="news-date"> <?php the_time($format = 'j f y'); ?> </div> <div> <h3><?php the_title(); ?></h3> <p><?php the_content(); ?></p> </div> </div> <?php endwhile; ?> <?php endif; ?> </div> <div...

php - Laravel 5 handle return from controller -

i have application has many views use need inject code specific sections of view. in previous application had used root controller , used special functions kind of changes normal workflow of creating laravel application way. basically have create function public function create() { return view('something'); } and want add specific section, in view , add data needed call view. want in controller since function returning view show same thing in case want simplify bit. i tried looking not find post processing on controller function, there that? here example. public function beforerender($instance) { if ($instance instanceof view) { $instance->getfactory()->inject('context-menu', $somedata); } return $instance; } the beforerender function run after create function in controller , alter return, allowing special return view. so question if there in laravel 5 (or similar) , how might it. in previous app had remade how laravel handl...

c# - How to create Discriminator column in Database First -

i have database first approach application , entity framework. have base class many other classes inherit. trying save class ef database, however, keep getting error there no discriminator column. system.data.sqlclient.sqlexception: invalid column name 'discriminator'. since using database first, how manually create column in table? cannot seem find datatype of anywhere. the entity framework try check column in of derived classes (isn't inheritance about?). can try adding [notmapped] attribute child classes. [notmapped] public class childclass : parentclass { // other stuff here } this minimize problem. attribute tells entity framework of properties ( if applied fields ) or classes not need mapped. read more it: https://msdn.microsoft.com/en-us/data/jj591583.aspx?f=255&mspperror=-2147217396#notmapped

php - phpexcel reads long numbers as boolean -

i'm using symfony2.3.4, php5.6.3 , phpexcel 1.8.0. when tried read excel file works ok cells. if cell contains large number, when read , show value in html view outputs false . i tried use custom value binder mark baker instructed here couldn't make work, comes boolean right beginning. important: the excels i'm trying load in html downloaded(generated) site , noticed when try open them microsoft excel, first prompts warning window telling user file extension , file format not match, although if choose open anyway, opens fine. i think that's what's causing problem, i'm sure(i can't contact guys implemented other site's download function) did this: $objwriter = \phpexcel_iofactory::createwriter($objphpexcel, $ext == 'xlsx' ? 'excel5' : 'excel2007'); when should have done this: $objwriter = \phpexcel_iofactory::createwriter($objphpexcel, $ext == 'xls' ? 'excel5' : 'excel2007'); makin...

javascript - Is it possible to have an object method return a function object and if so how do you access it? -

for instance, if have: var model = { updatecat: function(cat){ var foo1 = function(){ //do }; var foo2 = function(){ //do else }; return{foo1: foo1, foo2: foo2}; } }; model.updatecat.foo1(cat); //does not work what best way trying there? better create separate object methods? you need parentheses after model.updatecat such model.updatecat().foo1() . because updatecat function needs called in order return foo1/foo2 object. also, looks updatecat function takes parameter cat , not foo1 .foo1(cat) incorrect. var model = { updatecat: function(cat){ var foo1 = function(){ //do }; var foo2 = function(){ //do else }; return{foo1: foo1, foo2: foo2}; } }; model.updatecat(cat).foo1(); //does work alternatively, can call updatecat function inline have updatecat reference result ...

sql - Multiple inserts into SQLite getting data from other tables -

in sqlite, have simple message board want timestamp when each user first sees post. create table messages ( message_id integer primary key, mb_topic_id integer not null references mb_topics(mb_topic_id), message_poster integer not null references users(user_id), message_content text, message_post_time timestamp default (strftime('%s', 'now')) ) create table messages_seen ( message_id integer not null references messages(message_id), user_id integer not null references users(user_id), seen_time timestamp default (strftime('%s', 'now')), unique (message_id, user_id) ) what want do, in 1 sql statement if possible when user loads message thread, insert or ignore messages_seen userid (which have) each message_id matching mb_topic_id (which have). so if user_id 4 , mb_topic_id 7, like: select message_id messages mb_topic_id = 7 and return (9,11,14,26). , i'd do: insert or ignore messages_seen (mess...

C++ curl POST for LiFx Control -

i'm using curl c++ list bulbs curl_easy_setopt(curl,curlopt_username, my_api_key); curl_easy_setopt(curl, curlopt_url, "https://api.lifx.com/v1beta1/lights/all/"); curl_easy_setopt(curl, curlopt_ssl_verifypeer, false); curl_easy_setopt(curl, curlopt_writefunction, writecallback); curl_easy_setopt(curl, curlopt_writedata, &data); res = curl_easy_perform(curl); to toggle power light documentation http://developer.lifx.com/#toggle-power says use curl -u "c87c73a896b554367fac61f71dd3656af8d93a525a4e87df5952c6078a89d192:" -x post "https://api.lifx.com/v1beta1/lights/all/toggle" i've tested via pre-built curl binary works fine. can't figure out how construct post format in c++ code. curl_easy_setopt(curl,curlopt_username, my_api_key); curl_easy_setopt(curl,curlopt_post,"https://api.lifx.com/v1beta1/lights/all/toggle"); curl_easy_setopt(curl,curlopt_ssl_verifypeer, false); curl_easy_setopt(curl,curlopt_writefunction, write...

javascript - Accessing ModuleId in ViewModel -

just curious hear guys (and gals) use access moduleid, tabid, or tabmodulesettings while within viewmodel? typically end doing like var localsettings = { "mid": "<%= moduleid%>", "lid": "<%= loadid%>", "priceoverride": "<%= settings[fmsettings.partcostoverride] != null ? settings[fmsettings.partcostoverride].tostring() : string.empty%>", "productoverrideprefix": "<%= settings[fmsettings.partnumberoverrideprefix] != null ? settings[fmsettings.partnumberoverrideprefix].tostring() : string.empty%>", "productoverridesuffix": "<%= settings[fmsettings.partnumberoverridesuffix] != null ? settings[fmsettings.partnumberoverridesuffix].tostring() : string.empty%>" }; and pass vm so ko.appl...

c# - Sleep in for loop to create smooth effect -

i'd create loop change shape of form on course of second create smooth effect. using code below, error reading 'then name 'thread' not exist in current context'. can me out? for (var = 1; > 221; i++ ) { form1.activeform.height += 1; application.doevents(); thread.sleep(4.5); } it's bad idea sleep in gui thread, inhibits normal event processing code that, e.g., keeps gui painted , keeps gui controls responsive. instead, use system.windows.forms.timer same interval otherwise sleep , work in event handler timer.tick . edit: noticed code calls application.doevents() , mitigates ui freezing problem has own sets of gotchas.

curve fitting - How to apply regression to a zoo data frame in R? -

i have zoo data frame, piece of looks like: tlt pcy shy 2015-04-15 122.1545 28.16594 84.63730 2015-04-16 123.9836 28.11196 84.72825 2015-04-17 124.4341 28.07958 84.70804 2015-04-20 125.2258 28.15514 84.74845 2015-04-21 125.9629 28.18753 84.76866 2015-04-22 126.1267 28.28469 84.79897 2015-04-23 126.4923 28.30628 84.85056 2015-04-24 124.5478 28.34947 84.81010 2015-04-27 123.3290 28.36026 84.63820 2015-04-28 124.3560 28.38185 84.83033 2015-04-29 123.5618 28.45742 84.76965 2015-04-30 122.8086 28.53299 84.73932 2015-05-01 124.0000 28.57618 84.80000 or put looks like: structure(c(122.154509543852, 123.983621421486, 124.434078860684, 125.225787705634, 125.962885778852, 126.126687074014, 126.492320227327, 124.547751779181, 123.328974601471, 124.356047962478, 123.561779964634, 122.808613513252, 124, 28.1659442697104, 28.1119613477074, 28.079579550721, 28.1551370770225, 28.187532134368, 28.2846907856862, 28.3062786503438, 28.3494676400...

python - Networkx Finding communities of directed graph -

i graphing , visualizing directional social network. there statistic (modularity) in open source visualization tool called gephi ( http://gephi.github.io/ ) allows me partition nodes separating them communities. i'd accomplish task (finding communities) graph before visualize gephi can run various statistics on each community algorithm finds. however, each community algorithm have found not operate on directed graphs. found 2 different algorithms work won't work digraphs: aynaud's community algorithm based on dendograms @ http://perso.crans.org/aynaud/communities/api.html networkx's own find k cliques @ https://networkx.github.io/documentation/latest/reference/generated/networkx.algorithms.community.kclique.k_clique_communities.html this raises several questions, namely: is limitation of type of community finding algorithm want use? if so, gephi using algorithm removing directionality of graph before looking communities? are there other algorithms s...

ios - Create a circular TableViewCell indicator like the Apple Mail app -

Image
i trying create circular indicator tableviewcell similar 1 in apple mail app when email marked unread. i have following code: var indicator = cashapelayer() var indicatorsize: cgfloat = 10 // standard blue color let bluecolor = uicolor(red: 0, green: 122.0/255.0, blue:1.0, alpha:1) // create circular cashapelayer indicator.bounds = cgrect(x:0, y:0, width:indicatorsize, height:indicatorsize) indicator.position = cgpoint(x: 10, y: 10) indicator.cornerradius = indicator.frame.size.width/2 // add cell sublayer cell.layer.addsublayer(indicator) while seems job, circle doesn't feel smooth 1 in mail app, corners pixelated almost. i'm not sure if because using cashapelayer. know if there better alternatives. also can make object of cell opposed layer can call using cell.indicator? class circleview: uiview { override func drawrect(rect: cgrect) { let context = uigraphicsgetcurrentcontext() self.tintcolor.setfill() cgcontextfillellips...

jquery - How can I insert a Bootstrap modal, containing AngularJS, using .innerHTML then manually open it? -

when page loads trying do: $(function () { urlextract = location.hash foundextract = urlextract.split("#/")[1]; if(foundextract == "zsexdr"){ var createmodal = ""; basicrep = document.getelementbyid('basicreports'); createmodal+='<div class="modal fade" id="#waivermodal" role="dialog">'; createmodal+='<div class="modal-dialog modal-sm">'; createmodal+='<div class="modal-content">'; createmodal+='<div class="modal-header">'; createmodal+='<button type="button" class="close" data-dismiss="modal">&times;</button>'; createmodal+='<h4 class="modal-title">{{z.name}} - downloads</h4>'; createmodal+='</div>'; createmodal+='<div class="m...

powershell - Swapping text in an HTML file -

i want update bit of text in html file. text in html file: <html><body>normal</body></html> i want change normal rollout , vice versa. code @ first was (get-content c:\temp\a.html) | foreach-object {$_ -replace "normal", "rollout"} | set-content c:\temp\a.html this worked great, except want run same script change rollout normal. trying if else if's didn't work either. below 1 of many attempts using if..elseif : $a = get-content c:\temp\a.html (get-content c:\temp\a.html) | if($a -match "normal") { foreach-object {$_ -replace "normal", "rollout"} } | elseif($a -match "rollout") { foreach-object {$_ -replace "rollout", "normal"} } | set-content c:\temp\b.html how can approach differently? using [regex]::replace , script block delegate , substitution hash: $replace = @{ normal = 'rollout' rollout = 'normal' } $x = @( '...

mysql - Spring war file deployed on ec2 showing hibernate persistence failure connecting to rds -

our company has app has been hosted on media temple, since moving amazon ec2. i've been through tutorials, , got apache, php, mysql, java, , tomcat7 running fine. also, have been able connect rds instance mysql workbench. however, when upload war file tomcat manager error states unable connect database. here top of error in catalina.out file -----------------snippet log file---------------------------------------- 17:28:52.311 [http-bio-8080-exec-1] debug o.s.b.f.s.disposablebeanadapter - invoking destroy method 'close' on bean name 'datasource' 17:28:52.311 [http-bio-8080-exec-1] debug o.s.b.f.s.defaultlistablebeanfactory - retrieved dependent beans bean '(inner bean)#73e12051': [org.springframework.se curity.access.method.delegatingmethodsecuritymetadatasource#0] 17:28:52.311 [http-bio-8080-exec-1] debug o.s.b.f.s.defaultlistablebeanfactory - retrieved dependent beans bean '(inner bean)#3b35dc09': [(inner bean)#73e12051] 17:28:52.31...

How to import a 3rd party Python library into Bluemix? -

my python app needs web.py run i'm unable figure out how bluemix. see no options using cf push . tried "import web" , added additional code app without success. when push python app bluemix without web.py fails (naturally) since not have needs run. i'm sure i'm missing import mechanism. help? i recommend try out starter template on github. enabled deploy bluemix button automatically creates python runtime , postgress database django installed. https://github.com/fe01134/djangobluemix the project includes requirements.txt file ensure have right dependencies , .settings file read database user id , password vcap services. leverages declared services in manifest file create database service you. here youtube tutorial on how deploy python app on bluemix https://www.youtube.com/watch?v=qichqqnumle&list=plvsg7o_a5f2dajsnp6aracp6vkqdgsz33&index=5