Posts

Showing posts from May, 2014

zsh - Keep active virtualenv on new tab -

i use gnome-terminal zsh. had issue keeping current working directory when opening new tab ( ctrl + shift + t ) since used reset $home everytime. solved adding: . /etc/profile.d/vte.sh to .zshrc file. now, since use virtualenv (and virtualenvwrapper) avoid having workon virtualenv_name each time open new tab. the obvious solution put command in .zshrc , don't want always enter virtualenv. want when open new tab , inside virtualenv. now, since virtualenv modification path , ps1 , , stuff that, guess can in way. ideas?

c# - How to get the name of a method at runtime? -

i'm using event system takes string callback method name. i'd avoid hardcoding strings. there way can method names of given class in runtime? something similar to: typeof(myclass).name; but methods perfect. edit: i've been googling problem , results seem people looking name of current executing method. isn't i'm looking - instead i'd name of other methods within same class. it sounds you're talking nameof operator, added in c# 6.0. msdn documentation excerpt: used obtain simple (unqualified) string name of variable, type, or member. when reporting errors in code, hooking model-view-controller (mvc) links, firing property changed events, etc., want capture string name of method. using nameof helps keep code valid when renaming definitions. before had use string literals refer definitions, brittle when renaming code elements because tools not know check these string literals. a nameof expression has form: if (x == null

.net - Can't view designer when coding a form in C# -

Image
i'm following this tutorial on winforms, , far tutorial coding form without using toolbox. believe it'll introduce toolbox in more depth shortly. following tutorial, i've made partial class in following 2 pieces of code: first file : using system; using system.windows.forms; public class numeric : system.windows.forms.textbox { public numeric() { } } public partial class exercise { private numeric txtbox; system.componentmodel.container components; } second file : using system; using system.windows.forms; public partial class exercise : form { private void initializecomponent() { txtbox = new numeric(); controls.add(txtbox); } public exercise() { initializecomponent(); } } public class program { public static int main() { application.run(new exercise()); return 0; } } when run code f5, looks fine: form pops textbox. but reason, when right-click on second f

javascript - Why are my ng-repeat items not filtering as expected here? -

Image
plnkr: http://plnkr.co/edit/q34j9szbleggc4jkcnum?p=preview i have simple array called tags, contains 4 objects tweets value , vol value. when click order tweets , or order vol buttons expect numbers make sense, going high low or low high, numbers out of order. markup: <div class="sidebar" ng-controller="sidebar"> <header class="my-header"> <button ng-click="reorderbytweets()">order tweets</button> <button ng-click="reorderbyvol()">order vol</button> </header> <ul> <li ng-repeat="t in tags" ng-mouseleave="leavetag(t)"> <div class="tag-container"> <div class="tag border1" ng-mouseover="showtagdetails(t)">{{t.name}} | tweets: {{t.tweets}} | vol: {{t.vol}}</div> <tag-details tag="t"></tag-details> </div> </li>

angularjs - Making promises in modules -

i try make facebook registration module in app. facebook api faster angular controller, promise should used here. problem $q seems empty object , defer function undefined. module: var module = angular.module('app.facebook', []); module.constant("fbappid", 'herecomesmycode'); module.factory('facebook', facebookapi); facebookapi.$inject = ['$ionicloading', '$q', '$ionicplatform', '$state', 'authservice', 'datacontext', '$location']; function facebookapi(userservice, $q, $ionicloading, fbappid, $state, authservice, datacontext, $location) { return { fbloginsuccess: fbloginsuccess, fbloginerror: fbloginerror, getfacebookprofileinfo: getfacebookprofileinfo, fblogin: fblogin, fbregister: fbregister }; and here $q.defer undefined: function fbregister() { console.log($q.defer); if (!cordova) { facebookconn

forms - How Can I get autofocus on the first element (buildform) symfony -

in topictype class, used : public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('title', 'text') ->add('content', 'ckeditor', array( 'label' => 'contenu', 'config_name' => 'my_custom_config', 'config' => array('language' => 'fr'),)) ->add('save', 'submit') ; } how can autofocus on first field "title", when display form? $builder->add('title', 'text', array( 'attr' => array( 'autofocus' => true ) );

Php & Mysql Image updating and deleting -

Image
i creating simple employee management system practicing php & mysql. admin can add, edit & delete staffs, admin can upload image every employees i know how upload images but, how update uploaded images, example admin wants change profile image of staff? don't want delete old image should there , front page should show updated new image, admin can view , delete images of staffs seperate page.. the profile page profile.php show details of employee including profile image. know how create this. in page there link called view images go profile_images.php?id=users id undeleted old images should shown here. how design database thing.. currently database looks looking help.. :) you should store 1 path/filename profile pic in database table. if upload new 1 need replace old filename new filename , image replaced. if want store 'old' images, there no magic fix. have build using logic. when uploading image if 1 exists copy existing image fi

mysql - Error 1045 Access denied for user 'root'@'localhost' (using password: NO)) in connect -

hi guys getting error error 1045 (access denied user 'root'@'localhost' (using password: yes) in connect when join arma 2 epoch server changed file login requirements thing , database log in match each other still error.

android - Action items appear to the left of the action bar -

running app custom actionbar , 2 action bar items, displayed differently on different devices. on 1 device, items appear left of action bar logo , on other device action items appear right. action bar view: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:focusable="true"> <imageview android:id="@+id/btn_slide" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@null" android:scaletype="centerinside" android:src="@drawable/logo_advanced" android:layout_alignparenttop="true" android:layout_centerhorizontal="true"/> </relativelayout> action bar items: <?xml version="1.0" encoding="

javascript - Angular $scope and ng-if/ng-show issue. Status not changing in the view -

i using firebase authentication on web app. have buttons on different pages want appear if admin logged in. i've been trying use ng-if on button show if loggedin = true. i've console logged stated of 'loggedin' , appears changing correctly, buttons not show up. i can't figure out happening here life of me. i've checked out angular docs reading $scope, ngif, , ngshow directives, nothing clicking me. reviewed this stackoverflow post shows process came in first place. appears working people in thread, no joy me. this code in controller: app.controller('welcomectrl', function ($scope, welcomedata, $routeparams, $location) { var ref = new firebase('https://mywebapp.firebaseio.com/'); //authentication check var auth = new firebasesimplelogin(ref, function (error, user) { if (error) { // error occurred while attempting login console.log(error); } // no user logged in else if (user === null) { console.l

objective c - Hotkey when no assistance enabled CGEventTap -

i had used addlocal , work in application, want watch globally tried addglobalmonitorforeventsmatchingmask:handler: nseventkeydown not getting triggered @ all. apparently needs assistive permission enabled. i able watch nsscrollwheel events globally. interesting. before put bunch of time , come same roadblock hoping ask first, using cgeventtap monitor key events work globally without assitive turned on? https://developer.apple.com/library/mac/documentation/carbon/reference/quartzeventservicesref/index.html#//apple_ref/c/tdef/cgeventtaplocation i explore other methods curious (for learning) if cgeventtap work globally no problems. seems hint here may work comments show confusion: https://stackoverflow.com/a/9345536/1828637 other methods going use carbon apis. a cgeventtap requires same access assistive devices permissions global event monitor. documentation cgeventtapcreate() : event taps receive key , key down events if 1 of following conditions true:

postgresql - Rails 4.2 and postgres - cannot update an attribute, possible reasons? -

i have stumbled upon strange behavior updates of record. have sample project in have models restaurant, hotel, restaurantrating, hotelrating...they indeticall, copy paste , different names in attributes. have rake task, use populate database. in rake task, creating ratings hotels , restaurants , in after_save callback, recounting average rating each attribute hotels , restaurants. same code works hotels, doesn't work restaurant since update rails 4.2.1 (it worked in 4.0.12). the update looks this: def update_restaurants_avg_rating da::restaurant_rating_types.each |type| result = activerecord::base.connection.execute("select avg(restaurant_ratings.#{type}) restaurant_ratings restaurant_ratings.restaurant_id = #{self.restaurant_id}").values[0][0].to_f restaurant.where(id: self.restaurant_id).first.update_attribute("avg_rating_#{type}", result) end end no update seen in log (i can see update command hotels not restaurants), value not persisted

c# - How Can I Unfold This Event to an Observable Sequence? -

i'm trying write add-in outlook, , 1 of events i'm using itemsevents_event.itemchange - , handler's signature takes object parameter (the item changed): items.itemchange += calendaritems_itemchange; private void calendaritems_itemchange(object anitem) {...} how use observable.fromevent or observable.fromeventpattern create observable sequence event "stream" instead of attaching/detaching event usual? you need use fromevent conversion overload tell rx how should interpret event: iobservable<teventargs> fromevent<tdelegate, teventargs>(func<action<teventargs>, tdelegate> conversion, action<tdelegate> addhandler, action<tdelegate> removehandler); in case like: var source = observable.fromevent<itemsevents_itemeventchangehandler, object>( emit => new itemsevents_itemeventchangeh

c++ - ZLib gZip compress generates corrupted result -

i'm trying generate gzip compressed file xml using following code: stream.next_in = inbuf; stream.avail_in = 0; stream.next_out = outbuf; stream.avail_out = mybuffersize; int infile_remaining = infilesize; if (deflateinit2(&stream, z_default_compression, z_deflated, windowsbits + 16, 9, z_default_strategy) != z_ok) { return 0; } ( ; ; ) { int status; if (!stream.avail_in) { int n = min(buffer_size, infile_remaining); if (myfilereadfunc(pinfile, inbuf, n) != n) { deflateend(&stream); return -1; } stream.next_in = inbuf; stream.avail_in = n; infile_remaining -= n; } status = deflate(&stream, infile_remaining ? z_no_flush : z_finish); if ((status == z_stream_end) || (!stream.avail_out)) { int w = mybuffersize - stream.avail_out; if (myfilewritefunc(poutfile, outb

Splitting string into words in php -

i need split string array of words using non alphabetic , numeric characters(including '_') delimiter present code here $result= wordarray(preg_split("#[&,$'_.;:\s-*]# ", $data)); as can see can't work these characters )(@#+-*/=!~`/ \ please me adding characters code. thanks in advance. you can use ^ not operator... $result= preg_split("/[^a-za-z0-9]/", $data);

C++ Logic Error (boolean) -

template <class t> bool bst<t>::printsubtree(t item) { int id; bool result; if (root==null) { cout << "empty tree, please insert data" << endl; return false; } cout << "enter id print sub-tree" << endl; cin >> id; result=searchsubtree(id, item); if(result == false) { cout << "record not found" << endl << endl; } //preorderprint(); return true; } template <class t> bool bst<t>::searchsubtree(int target, t &item) { btnode<t> *cur, *curtemp; bool flag = false; if (root==null) { cout << "empty tree, please insert data" << endl; return false; } cur = root; curtemp = root; while(!flag && cur!= null) { if(curtemp->item.id == target) { flag = true; root = curtemp; //promote desired node become root temporarily inorderprint(); flag = true; } else if (curtemp-&

apache - Need help to write correct MOD_REWRITE -

i have mod_rewrite enabled on server decided use better urls on blog. below i'll try describe i'd do. when people visit url: https://student.sps-prosek.cz/~pilarda14/cms/post_test_url i want them see content located here: https://student.sps-prosek.cz/~pilarda14/cms/post.php?post=post_test_url so far have in .htaccess : rewriteengine on rewriterule ^~pilarda14/cms/(.*) ~pilarda14/cms/post.php?post=$1

.net - Try-catch on PostgreSQL not catching exception -

i testing postgresql connection using npgsql . want know happens when make mistake ,for example wrong connection string ,database down .... etc. made simple program test npgsqlexceptions try statement not catching exception: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using npgsql; namespace windowsformsapplication1 { public partial class form1 : form { public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { npgsqlconnection conn = new npgsqlconnection("server=127.0.0.1;port=5432;user id=postgres;password=knbvbnv;database=testdb;"); try { conn.open(); } catch (npgsqlexception ee) { console.writeline("======== ee.code =========

Creating a Football Field in HTML & CSS -

Image
i'm trying create football field in html & css i'm stuck. tried debugging hours no avail. here's code: #endzone { float: left; width: 300px; height: 500px; background-color: red; } .tophash div { margin-left: 300px; width: 30px; height: 30px; border-right: 1px solid white; } #middletophash div { margin-top: 170px; width: 30px; height: 30px; border-right: 1px solid white; float: left; } .middlebottomhash div { margin-top: 270px; width: 30px; height: 30px; border-right: 1px solid white; float: left; } .bottomhash div { margin-top: 470px; width: 30px; height: 30px; border-right: 1px solid white; float: left; } <div class="footballfield"> <div id="endzone"></div> <div class="tophash"> <div id="oneyardlinetophash"></div> <div id="twoyardlinetophash"></div> <div id=

javascript - Can't get jQuery to work in index.js in Blank Cordova App in Visual Studio 2015 -

i using visual studio 2015 create blank apache cordova app shown in link: http://i.imgur.com/1pl3el0.png using nuget package manager, i've added jquery project: http://i.imgur.com/smhvnyz.png from basic understanding, adding jquery through nuget manager doesn't add script tag index.html (or index.js) instead get's packaged in cordova.js file. i've added following basic link tag in index.html <a href="#" id="mylink">link</a> however, if try reference anchor tag using jquery in index.js file, following error: uncaught referenceerror: $ not defined however, in debug window, in javascript console, can use jquery fine access elements. missing basic here. can explain why jquery failing? here index.html , index.js files: index.html: <!doctype html> <html> <head> <meta charset="utf-8" /> <!-- customize content security policy in meta tag below needed. add 'unsafe-inline'

javascript - Add element works but clears input value -

i have script below adds element form, text input field. adds new text input field if type first 1 add new field removes input text first one. i cant see im going wrong here, im new javascript please go easy :) function addanother() { var id = 1; var elemebt = document.getelementbyid('quest'); var number = elemebt.getelementsbytagname('*').length; var add = number + 1; var element = '<input type="text" name="question[]" id="quest'+ add + '" placeholder="example: previous experiance have?" class="form-control" id="cloan"><a id="name'+ add +'" onclick="removeele('+ add +')">remove</a>'; document.getelementbyid('quest').innerhtml += element; } in javascript, following 2 statements practically identical: str = str + ' more text '; str += ' more text '; the key point here in end,

Android Studio Java classes dont seemed linked to layout files -

i having issue can not link layout files java classes. importing code know worked project, , moved source code , associated layout xml files other project. (copy , paste) is way link them back> here example: setcontentview(r.layout.activity_camera_protocol_demo); it can not resolve activity_camera_protocol_demo. is fix this? it text views , buttons ect on layout file. go build --> rebuild project . solved me problems had.

qt - QTreeView: column resize from columns and not from headers? -

is there way allow user interactively resize columns when headers hidden? you can install event filter on table's viewport , implement needed behavior manually. below sample implementation. header: #include <qtableview> class table_cell_resizer : public qobject { q_object public: explicit table_cell_resizer(qtableview *view = 0); protected: bool eventfilter(qobject* object, qevent* event); private: qtableview* m_view; //max distance between mouse , cell, small enough trigger resize int m_sensibility; //variables saving state while dragging bool m_drag_in_progress; qt::orientation m_drag_orientation; int m_drag_section; int m_drag_previous_pos; // check if mouse_pos around right or bottom side of cell // (depending on orientation) // , return index of cell if found qmodelindex index_resizable(qpoint mouse_pos, qt::orientation orientation); }; source: #include "table_cell_resizer.h" #include <qmouseevent>

python - Car Following Model with Optimal Velocity function - overtake occurence -

i creating project on car simulations , i've run problem. when run code, cars overtake 1 another. i have spent few days trying figure out why happening , still have no idea. optimal velocity function should set (de)acceleration, overtake not happen, reason, still allows cars overatake each other , not decelerate fast enough. could me, or push me in direction should looking ? here optimal velocity function: def optimal_velocity_function(dx, d_safe, v_max): vx_opt = v_max * (np.tanh(dx - d_safe) + np.tanh(d_safe)) return vx_opt now using within euler's method solve ode: def euler_method(x, v, n_cars, h, tau, d_safe, v_max): # euler method used solve ode # returns new position of car , new velocity dv = np.zeros(n_cars) j in range(n_cars - 1): dv[j] = tau ** (-1) * (optimal_velocity_function(x[j+1] - x[j], d_safe, v_max) - v[j]) dv[n_cars - 1] = tau ** (-1) * (v_max - v[n_cars - 1]) # speed of first car v_new = v + h * dv x_new = x + h * v_new re

c++ - OpenGL drawing triangles -

i pretty new opengl, have followed tutorials , trying play on own. i've got structure: struct vertex { vec3 position; vec3 color; }; and if have done of this: glgenvertexarrays(1, &vaoid); glgenbuffers(1, &vboverticesid); glbindvertexarray(vaoid); glbindbuffer(gl_array_buffer, vboverticesid); glbufferdata(gl_array_buffer, sizeof(vertex) * mesh.vertcount, mesh.verts, gl_static_draw); glenablevertexattribarray(shader["vvertex"]); glvertexattribpointer(shader["vvertex"], 3, gl_float, gl_false, sizeof(vertex), (const glvoid*)offsetof(vertex, position)); glenablevertexattribarray(shader["vcolor"]); glvertexattribpointer(shader["vcolor"], 3, gl_float, gl_false, sizeof(vertex), (const glvoid*)offsetof(vertex, color)); mesh.vertices vertex* type. put in array every following 3 forms triangle. the question how call render triangles? have tried gldrawarrays(gl_triangles, 0, mesh.vertcount); nothing happened, no erro

c++ - Error while trying to build stasm minimal -

i not have experience on c++. , have use stasm face detection. i'm traying build minimal example. on page 4 of tutorial possible know necessary make work. i'm these 2 errors: g++ -wno-deprecated -o teste minimal.cpp `pkg-config opencv --cflags --libs` -i/home/caaarlos/workspace/stasmdesbravando/stasm in file included minimal.cpp:46:0: /home/caaarlos/documentos/tcc/stasm4.1.0/stasm/pinstart.cpp: in function ‘void stasm::copypoint(stasm::shape&, const shape&, int, int)’: /home/caaarlos/documentos/tcc/stasm4.1.0/stasm/pinstart.cpp:138:13: error: redefinition of ‘void stasm::copypoint(stasm::shape&, const shape&, int, int)’ static void copypoint( // copy point oldshape shape ^ in file included minimal.cpp:37:0: /home/caaarlos/documentos/tcc/stasm4.1.0/stasm/convshape.cpp:9:13: error: ‘void stasm::copypoint(stasm::shape&, const shape&, int, int)’ defined here static void copypoint( // copy point oldshape shape this code: // minim

javascript - three.js simultaneous castShadow and receiveShadow in a large scene -

i'm looking way make realistic self shadows on buildings using both castshadow , receiveshadow produces artifacts. currently found way of adding plane on top of building (just below flat roof) drops shadow on , on ground. temp workaround i'd better i.e. scenes light being low above ground more detailed shadows needed. it's large scene can drive around in car suggestions how solve problem welcome.

ios - How to dismiss keyboard in a tableView after typing in textview -

in app have uitableview , includes in first cell uitextview , in other cells uilabel s. how can dismiss keyboard after typing in uitableview ? want dismiss anytime tap on other cells or scroll tableview. you can use uitableviewdelegate conforms uiscrollviewdelegate implement: func scrollviewwillbegindragging(scrollview: uiscrollview) { dismisskeyboard() } func dismisskeyboard(){ self.view.endediting(true) } //add viewdidload: var tapgesture = uitapgesturerecognizer(target: self, action: "dismisskeyboard") tableview.addgesturerecognizer(tapgesture) //or since wanted dismiss when cell selected use: func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath){ dismisskeyboard() }

c# - How do I properly format this MongoDB update clause? -

i have following document: { "_id": { "$oid": "55e1f841ff149c2228a5c33d" }, "status": "open", "date": "8/30/2015", "contestname": "test contest", "searchablecontestname": "test contest", "classname": "test", "searchableclassname": "test", "judges": [ { "name": "first last", "isheadjudge": null, "_id": { "$oid": "55e20962ff149c1f70d1aab0" }, "contestscores": null }, { "name": "another name", "isheadjudge": null, "_id": { "$oid": "55e20947ff149c1f70d1aaaf" }, "contestscores": [ 1, 2, 3, 4, 5, 6

ios - CloudKit saveRecord Complete -

i using code below update record. once record has been updated run refresh function. @ moment refresh function called before record has been updated refresh results same before record updated. thanks var tempdocumentsarray:nsarray! let recordid = ckrecordid(recordname: "layerabove") var predicate = nspredicate(format: "recordid = %@", recordid) let query = ckquery(recordtype: "layers", predicate: predicate) self.publicdb.performquery(query, inzonewithid: nil) { (results, error) -> void in tempdocumentsarray = results print("results are: \(tempdocumentsarray)") let record = tempdocumentsarray[0] as! ckrecord var layeraboveprevpos = record.objectforkey("layernumber") as! int layeraboveprevpos = layeraboveprevpos - 1 let nlnchanged = record.setobject(layeraboveprevpos, forkey: "layernumber") self.publicdb.saverecord(record, completionhandler: { (returnrecord, error) -> void in if let err = error { prin

osx - crash on document close when binding trough one-to-one relationship -

build environment: xcode 7 beta 7 os x: 10.10.5 swift 2 i have project using bsmanageddocument class github wrap core data nsdocument. using cocoa bindings data core data nsoutlineview using nstree controller. the object model simple. object (called sourcegroup_ tied tree controller has one-to-many relationship provide hierarchical data tree controller. has optional one-to-one relationship media object provides url associated media (image, video, etc.). the outline view has 3 columns bound, 2 bound properties of main object while third thumbnail image comes one-to-one media relationship. everything displays fine someitmes when close document exc_bad_access in _nsgetusingkeyvaluegetter goes though nsautounbinder , [nstablecellview release] through [nsautoreleasepool drain]. doesn't happen every time happen occasionally. it remove column bound through one-to-one relationship never crashes. if add in non-core data property on sourcegroup returns image preferredmedia rela

node.js - mongoose find not work as expected - null result -

i have started search google , in stackoverflow.com can not solve this. when use: suppliers.find({}, function(err, supplier) { get suppliers mongodb. but when call following returns: {"suppliers":[]} , not suppliers smaid (for examples: 1) show. suppliers.find({ "smaid": req.params.supplierid }, function(err, supplier) { here following complete code schema understand problem (give not on result when search smaid). router.get('/:supplierid', function(req, res) { suppliers = conn.model('suppliers') suppliers.find({ "smaid": req.params.supplierid }, function(err, supplier) { if (err) { return res.sendstatus(500) } if (!supplier) { return res.sendstatus(404) } res.send({ suppliers: supplier }) }) }) the schema var schema = require('mongoose').schema var suppliersschema = new schema( { smaid: string , companyname: string , companynametwo: string , street: string

javascript - Stop playing audio when new audio is played -

if button pushed should play new sound , stop current sound playing. should make when sound playing class "pause" toggled on. if sound associated button not playing class normal "play". //this buttons can pressed play sound <span class="play" sound="sound1.mp3">play</span> <span class="play" sound="sound2.mp3">play</span> <span class="play" sound="sound3.mp3">play</span> <script> // trying make var audio selects sound based on button pressed var audio = document.createelement('sound'); //when button pressed plays sound $(".play").on('click', function(){ if (audio.paused) { audio.play(); } else { audio.pause(); } $( ).toggleclass( "pause" ); // switch new css pause button }); // make if audio playing , sound pressed, audio playing stopped , newly pressed sound plays. if other audio playing{

php - How many arrays does array_chunk return? -

how know amount of arrays php chunk function returns? for example, if execute piece of code know it'll return 3 arrays, how calculate it: $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 2)); output: array ( [0] => array ( [0] => [1] => b ) [1] => array ( [0] => c [1] => d ) [2] => array ( [0] => e ) ) you can calculate programmatically dividing number of values in array should chunked chunk size: $input_array = array('a', 'b', 'c', 'd', 'e'); $chunksize = 2; print_r(array_chunk($input_array, $chunksize)); $count = round(count($input_array) / $chunksize,php_round_up); i'm using php_round_up because last chunk doesn't neccessarly have chunk size values, array, too.

How to upload files into azure media services directly from client(azure website)? -

how upload files azure media services directly client browser using (azure hosted website) ?and azure blob storage using azure website, without using intermediate server. if understand question correctly, azure media services offer rest api. in web application, can things required create media assets, set encoding jobs, , once you've had media file uploaded. after looking, guarav's post seems spot on: http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/

java - Drools - Check if map exist consecutive dates -

i have collection (map) contain data of 7 days. keys of hashmap dates in format yyyy-mm-dd need create rule check if string exists inside list[string] in days , days consecutive dates. there way it? i'm trying using contains it's not include checking of consecutive dates. rule "bonus a" lock-on-active true when databinding : databinding($data : data) items : list( size > 6 ) collect( list(this contains "1" && contains "2" && contains "3" ) $data.values ) databinding.addpoint(7.5); end and here code map<string, object> data = new hashmap<string, object>(); data.put("2015-08-03", arrays.aslist("2", "3", "1", "4")); data.put("2015-08-05", arrays.aslist("2", "3", "1", &

objective c - PHP empty TMP_NAME on iOS Upload Image -

i developing ios project requests user upload image server. i have code in class in objective-c: nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request sethttpshouldhandlecookies:no]; [request settimeoutinterval:60]; [request sethttpmethod:@"post"]; nsstring *boundary = @"------vohpleboundary4quqlum1ce5lmwcy"; nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@", boundary]; [request setvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *body = [nsmutabledata data]; nsmutabledictionary *parameters = [[nsmutabledictionary alloc] init]; [parameters setvalue:[sskeychain passwordforservice:@"id" account:@"spotterbike"] forkey:@"id"]; (nsstring *param in parameters) { [body appenddata:[[nsstring stringwithformat:@"--%@\r\n", boundar

cancan - Rails - CanCanCan - common abilities -

i using rails 4, devise, role model , cancancan. is possible define ability in ability.rb common number of roles? for example, every logged in user can crud own profile page? , roles have specific abilities on top of common ability? how work? need create role in role model common abilities , allow each user have multiple roles, common abilities role specific abilities? for example, in ability.rb, have: class ability include cancan::ability def initialize(user) alias_action :create, :read, :update, :destroy, :to => :crud # define abilities passed in user here. example: # user ||= user.new # guest user (not logged in) #users not signed in can create registration or login # can read publicly available projects, programs , proposals can :read, project, {:active => true, :closed => false, :sweep => { :disclosure => { :allusers => true } } } # {:active => true, :closed => false && :project.s