Posts

Showing posts from September, 2010

multithreading - In Go what happens if you write to closed channel? Can I treat channels as deterministic RE destruction? -

okay warning me subjective title please let me explain. right i'm looking @ go, i've read spec, watched few io talks, looks interesting have questions. one of favourite examples select statement listened channel came "doafter()" or something, channel send @ given time now. something (this wont work, pseudo-go if anything!) to := time.doafter(1000 * time.ms) select: case <-to: return nil //we timed out case d := <-waitingfor: return d suppose thing we're waiting happens fast, function returns , isn't listening to more, happens in doafter? i , know ought not test channel, example if(chantosendtimeouton.isopen()) { chantosendtimeouton<-true } i how channels sync places, example possible function above return after isopen() test before sending of true. against test, avoids channels - hide locks , whatnot. i've read spec , seen run time panics , recovery, in example recover? thing waiting send timeout

C++ How to create a class object that loops and increments by one? -

i have 3 files , output want not elegant. is there way have object num (122) , num(554) output next number in sequence 5 times without having << cout << every time? here main.cpp: #include <iostream> #include "number.h" using namespace std; int main() { number obj(122); cout << nobj (122) << endl; cout << nobj (123) << endl; cout << nobj (124) << endl; cout << nobj (125) << endl; cout << nobj (126) << endl; cout << nobj (554) << endl; cout << nobj (555) << endl; cout << nobj (556) << endl; cout << nobj (557) << endl; cout << nobj (558) << endl; } header file: #ifndef number_h #define number_h class number { public: number(int numa); int operator ()(int numb); int numa; }; #endif number.cpp: #include <iostream> #include "number.h" using namespace std; number::nu

c - reading first line in a file gives me a "\357\273\277" prefix in the first row -

this question has answer here: c++ reading file puts 3 weird characters 3 answers when use function readthenrow row=0 (i read first row) find 3 first chars \357 ,\273 , \277. found prefix how related utf-8 files, files have prefix , don't :( . how ignore type of such prefixes in files want read them? int readthenrow(char buff[], int row) { int file = open("my_file.txt", o_rdonly); if (file < 0) { write(2, "closing fifo unsuccessful\n", 31); exit(-1); } // function's variables int = 0; char ch; // temp variable read int check; // helping variable checking read function // read till reach needed row while (i != row) { // read 1 char check = read(file, &ch, 1); if (check < 0) { // write error message user write(2, "error occurred in reading\n", 27); exit(-1); } if

user interface - GUI Email validator in Java -

i'm working on gui validation... please see problem below... how validate email specific format? @ least 1 digit before @ , 1 digit after , @ least 2 letters after dot. string emailformat = "m@m.co"; pattern patternemail = pattern.compile("\\d{1,}@\\d{1,}.\\d{2,}"); matcher matchername = patternemail.matcher(studentemail); this regex pattern emails string pt = "^[_a-za-z0-9-\\+]+(\\.[_a-za-z0-9-]+)*@[a-za-z0-9-]+(\\.[a-za-z0-9]+)*(\\.[a-za-z]{2,})$"; you can try this list email = arrays.aslist("xyzl@gmail.com", "@", "sxd"); predicate<string> validmail = (n) -> n.matches(pt); email.stream().filter(validmail).foreach((n) -> system.out.println(n)); this description can change according need. ^ #start of line [_a-za-z0-9-\\+]+ # must start string in bracket [ ], must contains 1 or more (+) ( # start of group #1 \\.[_a-za-z0-9-]+ #

javascript - Object only has strings detection -

i have problem can't figure out how determine if object has strings. trying not on figuring out, if has time, explain why answer works, me learn. thank you function hasonlystrings(o) { (var val in o) { var values = o[match]; if (typeof values === 'string') { return true; } else { return false; } } } var car = { name: 'corvette', fast: true, color: 'black' } var truck = { name: 'ford', color: 'blue' } you're testing first value, not of them. function hasonlystrings(o) { (var val in o) { var values = o[match]; if (typeof values != 'string') { return false; } } return true; }

android - OnLongClickListener() not firing up in adapter class -

in android pageradapter class have defined onlongclicklistener . not working while running. couldn't find problem here, appreciated code public class fullscreenimageadapter extends pageradapter { private activity _activity; private arraylist<string> _imagepaths; private layoutinflater inflater; // constructor public fullscreenimageadapter(activity activity, arraylist<string> imagepaths) { this._activity = activity; this._imagepaths = imagepaths; } @override public int getcount() { return this._imagepaths.size(); } @override public boolean isviewfromobject(view view, object object) { return view == ((relativelayout) object); } @override public object instantiateitem(viewgroup container, int position) { touchimageview imgdisplay; button btnclose; inflater = (layoutinflater) _activity .getsystemservice(context.layout_in

Refer to sibling Polymer element in Dart? -

for past few hours have been struggling refer sibling element within polymer project. imagine following setup: /* main.html */ <link rel="import" href="siblinga.html"> <link rel="import" href="siblingb.html"> <polymer-element name="app-main"> <template> <app-siblinga></app-siblinga> <app-siblingb></app-siblingb> </template> <script type="application/dart" src="main.dart"></script> </polymer-element> /* siblinga.html, nothing special */ <polymer-element name="app-siblinga"> <template> <button on-click="{{dosomething))">do something</button> </template> <script type="application/dart" src="siblinga.dart"></script> </polymer-element> /* siblinga.dart */ import 'package:polymer/polymer.dart'; impor

jquery - Backbone.Syphon - always return empty object -

i using backbone.syphon plugin in backbone.marionette app. when click on submit button form, getting empty object({}).. don't know reason that, any 1 me find issue pelase? here view.js define([ 'jquery','underscore', 'backbone','marionette', 'text!./templates/loginview.html'], function($,_,backbone,marionette,template){ "use strict"; var loginview = backbone.marionette.itemview.extend({ classname:'col-xs-12 col-md-4 col-md-offset-4', template:_.template(template), events:{ "submit form" : "loginsubmit" }, loginsubmit:function(e){ e.preventdefault(); var data = backbone.syphon.serialize(e.target); console.log(data); //always return empty object. } }); return loginview; } ); here form: <form action

PHP MySQL unable to get rows from query -

this question has answer here: mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row() expects parameter 1 resource 33 answers brand new php , i'm going through few tutorials @ moment. have created login.php file has hostname, database, username, , password. test1.php page requires login.php file , attempts connect it. i select database, attempt query, , store results. here have far: <?php // test1.php require_once 'login.php'; $db_server = mysqli_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("unable connect mysql: " . mysql_error()); mysqli_select_db($db_server, $db_database) or die("unable select database: " . mysql_error()); $query = "select * classics"; $result = mysqli_query($db_server, $query); if (!$result) die ("database access failed

php - How do I push key/value to array -

i have data trying push array (key/value) my code below when try , print array, empty. what missing? $dataarray = array(); foreach($datatypes $data) { $dataarray[$data->dataid] .= $data->type; } print_r($dataarray); edit this $datatypes looks like. simplexmlelement object ( [dataid] => 1 [type] => account number [description] => user account number [whoadded] => carl [whenadded] => 2014-05-14t00:00:00 ) solution due being xml, had cast vars int , string $dataarray[(int)$data->dataid] = (string)$data->type; try with: $dataarray = array(); foreach($datatypes $data) { $dataarray[$data->dataid] = $data->type; } print_r($dataarray);

android - how to make navigation drawer + scrollable tabs in a single app? -

Image
i first made scrollable tabs in app , working want insert navigation drawer in app .i coded thing navigation drawer not visible . i think because made scrollable tabs main activity launcher , navigation 1 default . so plz guide me how can set 2 classes launcher or there other method? viewpager sliding tab functionality , sliding navigation menu 1 of popular android open source components. there're literally hundreds of clones of such - let me give links below. check out demos, compile them, , play around them. and, let's contribute time projects! https://github.com/astuetz/pagerslidingtabstrip https://github.com/jfeinstein10/slidingmenu

html - Bottom border doesn't show up in Firefox -

Image
i'm attempting replicate webpage learning purposes, , reason bottom border of table not showing up. guess has bottom section overlapping @ end of top section (even though doesn't seem in firebug) don't know how fix it. also, border shows fine in chrome, no problem there. firefox chrome exactly why happening? how can fix it? html <!doctype html> <html> <head> <meta charset="utf-8" /> <title>the beach boys</title> <link rel="stylesheet" type="text/css" href="assets/stylesheets/beach.css" /> </head> <body> <!-- header --> <header> <img class="left-logo" src="assets/images/logo02.gif" alt="george starostin reviews" /> <img class="right-logo" src="assets/images/logo01.gif" alt="only solitaire" /> <table> <tr> <td><a href="#&qu

vb.net - I need help putting all the logic statements in the correct order -

when click search button, happen: if search field empty, display message saying "please enter student number". if search field isn't empty, search database specific record matching user typed search field making sure there numbers in search field, if letter found, display message "numbers only", search db specific record. if record isn't found, display message saying "student not exist". if record found, populate fields data , based off of in record, enable buttons , change color. that's want. , work...mostly. out of order or in wrong spot or something. can't figure out. catch statement towards bottom commented out because use work doesn't - again, or things out of order. i'm not advanced developer @ all, go easy on me. here code click event of search button: if stunumtxtbox.text = "" msgbox("please enter student number.", msgboxstyle.exclamation) stunumtxtbox.select() else

wait - How to delay in Java? -

this question has answer here: i exception when using thread.sleep(x) or wait() 11 answers i trying in java , need wait / delay amount of seconds in while loop. while (true) { if (i == 3) { = 0; } ceva[i].setselected(true); //need wait here ceva[i].setselected(false); //need wait here i++; } i want build step sequencer , i'm new java. suggestions ? thanks! if want pause use java.util.concurrent.timeunit : timeunit.seconds.sleep(1); to sleep 1 second or timeunit.minutes.sleep(1); to sleep minute. as loop, presents inherent problem - drift. every time run code , sleep drifting little bit running, say, every second. if issue don't use sleep . further, sleep isn't flexible when comes control. for running task every second or @ 1 second delay strongly recommend scheduledexecutorservice , either

ember.js - How to come up with the global path to an Ember controller's property when value binding to a view helper? -

let's have following controllers app.personcontroller = ember.objectcontroller.extend(); app.personstuffcontroller = ember.controller.extend({ somethingoncontroller: [] }); with router entries this.resource('person', function() { this.route('stuff'); }); and routes app.personroute = ember.route.extend({ model: function() { this.store.createrecord('person', {}); }, setupcontroller: function(controller, model) { controller.set('model', model); } }); app.personstuffroute = ember.route.extend({ model: function() { this.modelfor('person'); }, setupcontroller: function(controller, model) { controller.set('person', model); this.store.find('thing').then(function(things) { controller.set('things', things); }); } }); and models app.thing = ds.model.extend({ name: ds.attr('string'), // instances of model have name values match person instance's

mongodb - Mongoose authenticating with keyfile -

i have mongo replica set 3 members , using keyfile authorisation. using mongoose , docs not find way authenticate via keyfile. does mongoose support ? if so, how specify keyfile while authenticating ? you not authenticate client via keyfile. can setup ssl , use x509 authenticate. however, keyfile authentication between replication set members. authentication must create user , require authentication in mongodb config. user local database in created. x509 requires steps correlate key/cert given user. if have no need ssl, i'd recommend creating admin user entire database, creating user database you're trying access in app.

Graph databases utilizing locality -

dag = directed acyclic graph; roots = vertices without incoming edges. i have dag larger available ram, need disk-based graph database work it. my dag shallow: have billions of roots nodes, each node dozens of nodes reachable. it not connected: majority of nodes have 1 incoming edge. couple of root nodes reachable subgraphs have few nodes in common. so dag can thought of large number of small trees, few of intersect. i need perform following queries on dag in bulk numbers: given root node, nodes reachable it. it can thought batch query: given few thousands of root nodes, return nodes reachable there. as far know there algorithms improve disk storage locality graphs. 3 examples are: http://ceur-ws.org/vol-733/paper_pacher.pdf http://www.cs.ox.ac.uk/dan.olteanu/papers/g-store.pdf http://graphlab.org/files/osdi2012-kyrola-blelloch-guestrin.pdf it seems there older generation graph databases don't utilize graph locality. example popular neo4j graph database:

javascript - Create an SVG DOM element from a String -

how go creating svg dom element string ? example: var svgstr = '<svg width="500" height="400" xmlns="http://www.w3.org/2000/svg"><!-- created method draw - http://github.com/duopixel/method-draw/ --><g><title>background</title><rect fill="#fff" id="canvas_background" height="402" width="502" y="-1" x="-1"/><g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasgrid"><rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/></g></g><g><title>layer 1</title><path id="svg_1" d="m118,242l64,-153l63,157c0,0 45,-71 49,-68c4,3 11,146 12,146c1,0 -173,-7 -173,-7c0,0 -61,-72 -61,-72c0,0 110,-156 46,-3z" fill-

Setting up wordpress on Ubuntu 12.04 -

i have dual-booted win7 laptop ubuntu 12.04, , i'm trying install wordpress. have installed apache2, mysql-server, , wordpress , keep getting asked ftp credentials when try , install plugins/themes. know how install themes etc. manually downloading , unzipping correct folders, isn't permanent solution. i've tried uninstalling , reinstalling keep getting faced tutorials on setting virtual hosts , i'm not sure if need have one? can point me easy follow (for beginners) tutorial scratch? or tell me if i'm missing something? my wordpress site needs moved local machine server when it's finished (i don't know server yet can't start using it) need easy use possible. yes, there available tutorials that. step 1- installing server- installing server initial setup ( optional ) step 2- installing wordpress- https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04

javascript - Angular Simple filter on ng-Repeat (>5) -

i have simple angular form, i'd filter ng-repeat values>5 shown. <body ng-controller="mainctrl"> <div ng-repeat="item in items | filter:value:>5??????/p> <p><input type=text ng-model="item.value"></p> </div> </body> i can't determine syntax this. assuming it's built in filter. reference: app.controller('mainctrl', function($scope) { $scope.items = [ { value: 1 }, { value: 2 }, { value: 5}, { value: 7 } ]; there no filter built in this, nor there syntax can pass default filter. you can either: 1. pass function default filter. html: <div ng-repeat="item in items | filter:filterfn"> js: $scope.filterfn = function(item) { return item.value > 5; }; 2. register own filter html: <div ng-repeat="item in items | greaterthan:5"> js: app.filter('greaterthan', function() { return function(items, valu

c# - Having wired outputs while Rfc2898DeriveBytes implementation in TripleDES -

Image
this simple code taking hours find out why getting wrong output. can't seem find problem. okey specially rfc2898derivebytes implementation? need find out whats causing wrong output, , how solve make code work. static void main(string[] args) { string data = "welcome jungle"; string pass = "monkey"; string salt = "12345678"; byte[] textdata = encoding.utf8.getbytes(data); byte[] password = encoding.utf8.getbytes(pass); byte[] saltbyte = encoding.utf8.getbytes(salt); rfc2898derivebytes keygenerate = new rfc2898derivebytes(password ,saltbyte ,1000); rfc2898derivebytes keygenerate1 = new rfc2898derivebytes(password, saltbyte, 1000); byte[] key1 = keygenerate.getbytes(16); byte[] key2 = keygenerate1.getbytes(16); console.writeline("plaintext: " + data); tripledescryptoserviceprovider tdes = new tripledescryptoserviceprovider(); tdes

c# - Entity Framework, Transactions and Stored Procs -

i have stored procedure writes data table, based on values different table. so, reads start/end dates table, creates whole lot of data , writes separate table. what happens user selects start/end date something, , store start/end date table. call stored procedure, within ef, , procedures reads table updated, , populates different table. if proc fails, want roll data proc wrote, initial update of table. i think data written table (the initial update, done in ef) when call 'savechanges'. call that, , call procedure. there way detect if procedure failed, , if so, rollback udpates (the table update, , proc did)? currently, code looks this, seems paremeter in savechanges invalid (wants no parameters), , 'acceptallchanges' invalid: using (var scope = new transactionscope()) { context.savechanges(false); context.project_scheduled_event_payments(st.id); context.acceptallchanges(); } you can use transaction scope. you'll need add reference

ruby on rails - RubyOnRails Authorization : I have changed my authorization method and after making some changes to routes.rb I am now getting NO ROUTE errors -

in first few lines made changes. there way can post project can give information possible? not using users controller/file @ all. authorization require me use user scaffold, because using newuser scaffold. cms::application.routes.draw root :to => "home#merchant" controller :sessions 'login' => :new post 'login' => :create delete 'logout' => :destroy end resources :newusers resources :users resources :maintenances resources :leases resources :sales resources :saleterminals resources :salesreps resources :terminaltypes resources :processings resources :manufacturers resources :promotions "community/index" resources :currents resources :merchants "home/index" "home/about" "home/contact" "home/processing101" "home/terminaloptions" "home/weekend" "home/conditionsofuse" "home/privacy

c++ - Calling boost::asio::io_service::run from a std::thread -

i have class handles connection has boost::asio::io_service member. i'm wanting call io_service::run() std::thread, running compilation errors. std::thread run_thread(&boost::asio::io_service, std::ref(m_io_service)); does not work. see various examples out there doing using boost::thread, wanting stick std::thread this. suggestions? thanks there 2 ways have known, 1 create std::thread lambda. std::thread run_thread([&]{ m_io_service.run(); }); another create boost::thread boost::bind boost::thread run_thread(boost::bind(&boost::asio::io_service::run, boost::ref(m_io_service)));

any client SVN tools to make external on repository from another repository? -

i want make external 1 repository repository. the story in our company each project has 2 or 3 repositories , people commit files on them, going have 1 main repo each project , gather files together. i created main_repo , should make external main_repo other repo (the developers commit files on previous repo , here in main_repo using external have new version files). i have read svn:external of them how make external on checkout folders on local machine , command line syntax. please tell me how can make external on repository tools tortoise or else ? any suggestion appreciated.

Unable to get the list from domain class to GSP in grails 2.3.7 -

i have embedded class , stored list. embedded class(questionairre) initailization , made list in domain class class surveyquestions{ questionairre questionairre list questionairrelist static embedded = ['questionairre', 'questionairrelist'] } below method called domain object list controller class method : def show(surveyquestions documentinstance) { list<surveyquestions> surveyquestionslist = documentinstance.list() [eventslist:surveyquestionslist] } gsp page list , iterate inside gsp page. <g:each in="${eventslist}" var="p"> <li>${p}</li> </g:each> please surveyquestionslist object controller gsp page displaying list.

javascript - MongoDB - $set to update or push Array element -

in products collection, have array of recentviews has 2 fields viewedby & vieweddate. in scenario if have record viewedby , need update it. e.g if have array :- "recentviews" : [ { "viewedby" : "abc", "vieweddate" : isodate("2014-05-08t04:12:47.907z") } ] and user abc , need update above & if there no record abc have $push . i have tried $set follows :- db.products.update( { _id: objectid("536c55bf9c8fb24c21000095") }, { $set: { "recentviews": { viewedby: 'abc', vieweddate: isodate("2014-05-09t04:12:47.907z") } } } ) the above query erases other elements in array. actually doing seems doing not si

buttons are lost after redirection of the page using ObservableCollection in windows phone 8 c# -

in windows phone application creating dynamic buttons using observablecollection btn_groupname_click event below: using system; using system.collections.generic; using system.linq; using system.net; using system.windows; using system.windows.controls; using system.windows.navigation; using microsoft.phone.controls; using microsoft.phone.shell; using microsoft.phone.userdata; using system.windows.media; using microsoft.phone.maps.controls; using system.collections.objectmodel; using system.collections; namespace getcontacts { public partial class creategroups : phoneapplicationpage { string buttonname = ""; public observablecollection<group> groupbtn; list<customcontact> contact = new list<customcontact>(); list<customcontact> listofcontact2 = new list<customcontact>(); //list<group> buttons = new list<group>(); list<button> buttons = new list<button>();

uinavigationcontroller - UIAlertView showing up in other view when going back fast to previous view controller -

i having problem uialertview . using nstimer showing uialertview on moment when loop done. the problem: my uialertview popping on previous viewcontroller when pressing button fast, before loop done. on moment when uialertview showing up, app crash when pressing button on uialertview . how can check viewcontroller still delegate or not show in other view? it crashing because have set current view controller delegate , while pressing no more in memory when alert appears on previous view while pressing @ time reference delegate handling no more why crashing. uialertview crash issue on view controller

printing - Printer crashing when trying to print from Internet Explorer -

i had issue when when printed ie printer crash, , need restarted. find nothing online, , fixed thought i'd put here in case ran same issue. the problem main css file being included, , apparently large ie handle when in print mode. excluded file print (set media screen) , fixed issue.

asp.net - System.argumentException while inserting xml node into document -

i trying insert xml node node in xml document continuously getting "system.argumentexception" whenever test it. have tried several ways of inserting node cannot work out how fix it. here's code: dim content string = "<name>" + songname + "</name><artist>" + songartist + "</artist><album>" + songalbum + "</album>" dim doc new xmldocument doc.load(getpath()) dim xmlnode = doc.createelement("song") i.innerxml = content try list.appendchild(i) catch end try doc.save(getpath()) return true end if end if i know stepping , using try catch statement error "the node inserted different document context." , occurs @ "list.appendchild(i)" line in code. could offer suggestions fix error please? edit i tried using doc.appendc

c# - The reason behind slow performance in WPF -

i'm creating large number of texts in wpf using drawtext , adding them single canvas . i need redraw screen in each mousewheel event , realized performance bit slow, measured time objects created , less 1 milliseconds! so problem? long time ago guess read somewhere rendering takes time, not creating , adding visuals. here code i'm using create text objects, i've included essential parts: public class columnidsinplan : uielement { private readonly visualcollection _visuals; public columnidsinplan(baseworkspace space) { _visuals = new visualcollection(this); foreach (var column in building.modelcolumnsintheelevation) { var drawingvisual = new drawingvisual(); using (var dc = drawingvisual.renderopen()) { var text = "c" + convert.tostring(column.groupid); var ft = new formattedtext(text, cultureinfo, flowdirection,

java - Knuth Morris Pratt application no error but not working -

here's application "textform", take value searchbox. "listkamus", take value array. "player name", change value string. "kmp.knutmorris(textform, playername)", send textform, playername value knutmorris class main class public void ontextchanged(charsequence s, int arg1, int arg2, int arg3) { string textform = s.tostring(); searchresults.clear(); for(int i=0;i<listkamus.size();i++) { string playername=listkamus.get(i).tostring(); kmp.knutmorris(textform, playername); if(kmp.value==1){ searchresults.add(listkamus.get(i)); } } adapter.notifydatasetchanged(); } kmp class public class kmp { /** failure array **/ private int[] failure; public static int value; /** constructor **/ public kmp(string text, string pat) { /** pre construct failure array pattern **/ failure = new int[pat.length()]; fail(pat); /** find match **/ int pos = posmatch(text, pat

ms access - option button value -1 when selected -

i have option button has control source. button not part of option group. when button not selected stores 0 (which want) however, when option button selected stores -1 instead of 1. cannot seem find property in menu set option value. is there way set storage value when selected 1 not -1? i tried me.controls("optionbuttoncontrolname").optionvalue = 1 got error. i know do: if (optbtn.value = -1) optbtn.value = 1 end if each time button clicked there has easier way i'm not seeing. thanks! in access (and in vba in general recall) true value -1. option button (and other control boolean value setting in vb/vba) show value when true. a less verbose option might grab absolute value of control: myvalue = abs(optbtn.value)

hadoop - hive Drop table not working -

i new bee in hadoop world. created internal table in hive , tried importing data same. then tried drop table got following error. failed: error in metadata: metaexception(message:javax.jdo.jdoexception: cannot join org.datanucleus.store.rdbms.mapping.java.persistablemapping@6a9ccd9f org.datanucleus.store.rdbms.mapping.java.persistablemapping@55eb1db2 since have different numbers of datastore columns! nestedthrowables: org.datanucleus.exceptions.nucleusexception: cannot join org.datanucleus.store.rdbms.mapping.java.persistablemapping@6a9ccd9f org.datanucleus.store.rdbms.mapping.java.persistablemapping@55eb1db2 since have different numbers of datastore columns!) failed: execution error, return code 1 org.apache.hadoop.hive.ql.exec.ddltask what can resolved? any highly appriciated. looks hive client not matching metastore connecting to. please provide hive-site.xml contents, .metastore. related properties. here properties into <property> <name>javax

gruntjs - 'module' is undefined in grunt javascript -

i want integrate grunt on java script project. have installed npm, grunt , all. i have created package.json file , gruntfile.js grunt. but when run "grunt" command getting error 'module' undefined. gruntfile.js module.exports = function(grunt) { grunt.initconfig({ pkg: grunt.file.readjson('package.json') }); grunt.registertask('default', []); }; package.json { "name": "example", "version": "0.0.1", "private": true, "devdependencies": { "grunt": "latest", "grunt-cli": "^0.1.13" } } i had problem found making sure have correctly named grunt file gruntfile.js fixed problem, silly can overlooked.

regex to replace one word in url - 301 Redirect using URL Rewrite IIS asp.net -

i want set 301 redirect mysite.com/banana mysite.com/fruit mysite.com/banana/yellow mysite.com/fruit/yellow mysite.com/banana/yellow/sale mysite.com/fruit/yellow/sale (the words "yellow" , "sale" replaced anything, variables in route.) this works first case, not others: <rule name="banana" stopprocessing="true"> <match url="banana" /> <action type="redirect" url="fruit" /> </rule> based on question: replace underscore dash using url rewrite module of iis this works third case only: <rule name="banana" stopprocessing="true"> <match url="(mysite.com.*/[^/]*?)banana/([^/_]*)/([^/_]*)$" /> <action type="redirect" url="{r:1}fruit/{r:2}/{r:3}" /> </rule> what need regex returns {r:1} mysite.com/ {r:2} /yellow/sale or {r:1} mysite.com/ {r:2} why not ke

Move and Rename file using Java -

i want move , rename file using java. tried code fails rename: please, thank you public class moveandrenamefile { public moveandrenamefile(){ //current date , time dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); date date = new date(); { file file = new file("c:\\foldera\\client.pdf"); file newfile = new file(("c:\\folderb\\clientx.pdf")); if(file.renameto(newfile)+dateformat.format(date)){ system.out.println("file rename success");; }else{ system.out.println("file rename failed"); } } the file i/o api changed , improved considerably java 7. 1 of problems legacy (pre java 7) file api that: • rename method didn't work consistently across platforms the nio.2 api (file api introduced java 7) way of renaming files using files.move : files.move(file, newfile, standardcopyoption.replace_existing); the

ios - Swift Xcode 6 developer baseball counter -

this question has answer here: swift xcode 6 baseball counter 1 answer at end of code i'm trying make when 3 strikes outs go one. i'm getting error @ bottom if statement. says expected declaration // // viewcontroller.swift // helloworddemo // // created developer on 6/8/14. // copyright (c) 2014 aecapps. rights reserved. // import uikit class viewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @iboutlet var labeldispaly : uilabel = nil // dispaly strikes var counter = 1 @ibaction func buttonpressed(sender : anyobject) { labeldispaly.text = "strikes \(counter++)" } //button add strikes @iboutlet var outsdispaly :

Jquery slider in reverse order -

this code of jquery image slider http://jsfiddle.net/6plg5/ $(".slider > div:gt(0)").hide(); function slideloop() { $('.slider > div:first') .next() .show() .end() .appendto('.slider'); } slideloop(); setinterval(slideloop, 3000); $('.right').click( slideloop ) i'm making control buttons. slide right works. how make slide left function? thanks in advance. try this... html code <div id="img-grp-wrap"> <div class="img-wrap"> <img src="http://www.pictures-of-cats.org/images/ragdoll-cat-small-pictures-of-cats.jpg" /> <img src="http://0.tqn.com/d/paganwiccan/1/g/t/1/-/-/blackcat.jpg" /> <img src="http://2.bp.blogspot.com/-h_ityn3qqok/tfp5ak2vi5i/aaaaaaaaabm/qm45bnom4hy/s1600/cat-claw.jpg" /> <img src="http://www.pictures-of-cats.org/images/pixiebob-cat-list-of-cat-breeds-pictures-of-

c# - Creating cookie when using odata and web api 2 -

how set cookie when using web api 2 , odata. new api , traditionally used context.response not seem avaliable here. this part of controller code: public async task<ihttpactionresult> post(order order) { if (!modelstate.isvalid) { return badrequest(modelstate); } context.orders.add(order); await context.savechangesasync(); return created(order); } you can write own delegatinghandler add cookie need response. check part "example: set , retrieve cookies in message handler": http://www.asp.net/web-api/overview/working-with-http/http-cookies for how insert message handler, check this:"per-route message handlers" http://www.asp.net/web-api/overview/working-with-http/http-message-handlers