Posts

Showing posts from June, 2010

reactjs - Integrating React to a build flow with module transpilation with Babel -

i having trouble module transpilation babel. when transpiling code amd modules babel, can make work in browser including requirejs library. when try introduce react equation experiencing troubles, react not play nice amd. having mismatch errors ( http://requirejs.org/docs/errors.html#mismatch ) cause react loaded synchronously in vendor.js file. if tried other way around, using commonjs default module spec babel uses, have no idea how make work in browser. without library requirejs in former example, browser giving errors "exports not defined". tried include stuff es6-module-loader or babel browerser polyfill, without success. ps: build flow using broccolijs. it seems answer in webpack. after using babel transpile code es5 in broccoli, used broccoli webpack plugin make transpiled code browser ready.

javascript - How to show a single combination from matrix of values and hide others -

edit: edited question, because classes index based, in real scenario not.. lets have markup, more or less <div class="container"> <div class="room_special"> <div class="aaaa"></div> <div class="bbbb"></div> <div class="cccc"></div> </div> <div class="room_junior"> <div class="xyz"></div> <div class="ztx"></div> <div class="tda"></div> </div> <div class="room3"> <div class="xxxx"></div> <div class="board3"></div> <div class="zzzzz"></div> </div> </div> and want make visible (the rest, hidden) room2 - board 3, , change when user clicks on elements (not those..) and have 2 vars, wich read user

javascript - Velocity JS Lag -

i have been using parallax time , have been using css animations , transforms , etc in order results want. after reading stuff velocity , thought giving try. the problem animations having kind of delay. because i'm not applying velocity correctly, have researched , seems i'm doing correct. $ability.velocity({ translatex: '-50px', opacity: '0' }); $(document).on('scroll', function(){ var wscroll = $(this).scrolltop(); if(wscroll > $('.ability-self').offset().top - $(window).height()/1.2){ $ability.velocity({ translatex: "0", opacity: '1' }); } else{ $ability.velocity({ translatex: '-70px', opacity: 0 }); } the problem animation happens 1 or 2 seconds after scroll after element. have checked if css attribute might interfering, didn't find relevant one. is js bad? assuming use of velocity correct, code causing lot of stress browser. should first cache layout values

See full stack trace on gulp exception -

a gulp watch task keeps throwing exception stack trace limited 10 frames, can't tell it's originating. i'm guessing must configurable somewhere can't determine where. looked in gulp.config.js , in gulp.util.js. read this report think must easier that. who knows how this? this might work gulp.on('err', function(e) { console.log(e.err.stack); });

node.js - NodeJS/Mongoose: exports.function and module.exports incompatibility -

this user.js var mongoose = require('mongoose'); var bcrypt = require('bcrypt-nodejs'); var userschema = mongoose.schema({ email: { type: string, unique: true }, password: string, }); var user = mongoose.model('user', userschema); function createdefaultusers() { user.find({}).exec(function (err, collection) { if (collection.length === 0) { user.create({ email: 'name@eemail.com', password: 'password0', }); } exports.createdefaultusers = createdefaultusers; module.exports = mongoose.model('user', userschema); i call createdefaultusers in file create initial users. but when gives me following error: usermodel.createdefaultusers(); ^ typeerror: object function model(doc, fields, skipid) { if (!(this instanceof model))

angularjs - Service singleton across all controllers -

if have following : <div ng-controller="mainctrl"> {{vm.name_from_service}} </div> .... <div ng-controller="mainctrl"> {{vm.name_from_service}} </div> lets both pull name_from_service value factory/service , correct assume same service singleton being used across both mainctrl controller instances ? note mainctrl used twice. controller code snippet : $scope.vm.name_from_service = someservice.getname(); snippet #2 : both ng-view , immediate div below use same service retrieve name_from_service, name_from_service update in 1 place. <div ng-controller="mainctrl"> section 1 {{vm.name_from_service}} </div> <div id="ngviewcontainer" ng-view=""></div> also not using asynchronous ajax calls retrieve name_from_service angular should aware of changes. i've tried using $timeout , $apply() . no dice . i refactored , separated out unrelated

javascript - hide/display filter for tablesorter -

i d able hide/display filters while using tablesorter. using table sorter went fine when added button execute : function display_hide_filter() { var filters = document.getelementsbyclassname('tablesorter-filter-row'); (var = 0; < filters.length; i++) { var filter = filters[i]; if (filter.style.display == 'none') { filter.style.display='inline'; } else { filter.style.display='none'; } } } i weird answer. hiding filter fine re displaying turn having filter cells under first header cell. since got poor english , css/js skills, hope didnt miss in documentation tried trough thousant times no success. thanks help there filter_hidefilters option minimizes filter row until user hovers on it. accessible friendly in user can use tab key gain access filter inputs ( demo ). if want hide/show filter row, basic code work ( demo ): html <button type="button&

python - Volume Overlay with Pandas -

Image
i see in context of matplotlib , open-high-low-close, i'm wondering if can add volume overlay within pandas framework. final graph want close first 1 here: ( matplotlib - finance volume overlay ) say have dataframe such: num rolling_30 rolling_10 rolling_60 volume date 2015-06-23 0.000219 0.000149 0.000168 0.000183 2 2015-06-25 0.000489 0.000162 0.000200 0.000188 3 2015-07-01 0.000164 0.000163 0.000190 0.000186 1 2015-07-02 0.000190 0.000166 0.000190 0.000187 1 2015-07-03 0.000269 0.000171 0.000198 0.000180 1 2015-07-04 0.000935 0.000196 0.000282 0.000193 2 2015-07-08 0.000154 0.000196 0.000288 0.000188 1 2015-07-11 0.000274 0.000202 0.000305 0.000190 1 2015-07-13 0.000872 0.000228 0.000380 0.000201 9 how can ['num','rolling_30','

vb.net - Auto-save attachments in Outlook 2010 -

my goal able save attachments specific email address folder locally. have created vb script reason doesn't work. public sub saveattachtodisk (itm outlook.mailitem) dim objatt outlook.attachment dim savefolder string dim dateformat dateformat = format(now, "dd-mm-yyyy h-mm") savefolder = "c:\temp\" each objatt in itm.attachments objatt.saveasfile savefolder & "\" & dateformate & objatt.displayname set objatt = nothing next end sub i've tried created new module , new rule run script when message arrives specific address. have tried put script in "thisoutlooksession" nothing works. did try run script manually under debugger? try choose drive. c: drive requires admin privileges writing. you may find getting started vba in outlook 2010 article helpful.

html - Display label (span) no mouse hover -

i creating bar icons content on side: http://plnkr.co/edit/g6boxcskihewdwp7zrrw?p=preview when mouse on icon want name appear in front of icon , on content. showing under icon. how can fix this? markup <div class="wrapper"> <div class="navigation"> <ul> <li> <a href="#"> <i class="fa fa-home"></i> <span>one</span> </a> </li> <li> <a href="#"> <i class="fa fa-book"></i> <span>two</span> </a> </li> </ul> </div> <div class="content"> content</br> span of icon should on content when mouse on </div> </div> css .wrapper { border: 1px solid red; padding: 0; margin: 0; overflow: hidden; } .navigation { float: left; width: 4

ruby - Chef, File does not exists after force the creation -

i have following logic in recipe creates file if it's missing , tries insert lines in it. file "/root/myfile" owner 'root' group 'root' mode '400' action :create_if_missing end file = chef::util::fileedit.new('/root/myfile') data_bag('my_databag').each |user| # ... lines using chef resources user, group, etc. if node.chef_environment != "my_env" line = "something write in myfile" chef::log.info("-----> #{line}") file.insert_line_if_no_match(/#{line}/, line) end end file.write_file the recipe fails in case myfile doesn't exist despite i'm forcing creation of file before instruction causes exception. here error: argumenterror ------------- file '/root/.testfile' not exist relevant file content: ---------------------- 18: 19>> file = chef::util::fileedit.new('/root/.testfile') 20: can me understand why doesn't work? on a

c - Trying to exploit int overflow -

here source code using: (the full code can found here: http://pastebin.com/apfj4jyb #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <signal.h> #include <netinet/in.h> #include <sys/wait.h> #define alarm_timeout_sec (1200) #define password_length (100) #define brute_force_timeout (1) int is_correct(char * given_password_hex) { char b2h[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0-9 */ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a-f */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a-f */

How do you add a generator task to resourceGenerators in a SBT autoplugin? -

i writing autoplugin in sbt. plugin should generate files resourcemanaged . code below (work in progress), not seeing fooo output when run compile see when invoke task directly yamlgen , makes me think reason task isn't added resource generator. checked bunch of other generator plugins , pretty this. whats problem here? import sbt._ import keys._ object sampleplugin extends autoplugin { override def trigger = allrequirements val yamlsourcefolder = settingkey[file]( "yaml-source-folder", "description" ) val yamlsources = settingkey[seq[file]]( "yaml-sources", "description" ) val outputfolder = settingkey[file]( "output-folder", "description" ) val yamlgen = taskkey[seq[file]]( "yaml-gen", "description" ) def yamlsettings(conf: configuration): seq[setting[_]] = inconfig(conf)(seq( yamlsourcefolder <<= (sourcedirectory in compile)

c++ - Disallow function template instantiation with iterator parameter -

i have function template takes templated parameter: template <class r> reft<r> make_ref(r& res) { return reft<r>(&res); } i either want prevent r being kind of iterator, or, if easier, want have overload compiler prefer use iterators calls make_ref again iterator dereferenced. best approach combining two, compiler prefers using iterator specific overload, , refuses use non-specific version. i consumers of code able call make_ref(something) without having think whether something iterator or not - need different if is, , if that's not possible, give useful error message consumer. first traits (you may have tweak requirements): template <typename t> auto is_iterator_impl(t* it) -> decltype(**it, ++(*it), (*it) == (*it), std::true_type()); template <typename t> auto is_iterator_impl(...) -> std::false_type; template <typename t> using is_an_iterator = decltype(is_iterator_impl<t>(0)); note: using

c# - Visual Studio cannot recognize a change in environment variable -

i using environment variable in program , setting variable value outside visual studio. when try below line of code, returns variable value if value set before opening current instance of vs. changes done later not have effect. var variablevalue = environment.getenvironmentvariable("env_var"); to receive new value set, way out restart vs. looks vs caches these values on startup , doesn't consider new changes. however, question whether there way refresh current vs session such can read changed environment variable value & therefore need not go on restart again? it possible per-machine environment variable. changes reflected in running process. environment.getenvironmentvariable("env_var", environmentvariabletarget.machine) if feasible use machine-wide variable depends on scenario, however.

java - Bidirectional OneToMany @LazyCollection(LazyCollectionOption.EXTRA) -

i have problem lazycollection. guy on site lazy collection tutorial says hibernate not materialize collection elements when accessing collection , inserting collection (at least in example of winery , wine onetomany relationship mapping) but doesn't working me. here entities: import javax.persistence.*; import javax.persistence.entity; import javax.persistence.table; import java.util.arraylist; import java.util.date; import java.util.list; @entity @table(name="document_generated") public class documentdomaintogenerateimpl extends domainobjectimpl<documentdomaintogenerate, integer> implements documentdomaintogenerate{ /** * */ private static final long serialversionuid = -1297116626347796196l; private string identificationkey; private identification identification; private string documentgroup; private string documenttype; private server server; private int statusorder = 2; private int numberofattempt; private auditdata auditdata; private date

How to frame linq query with COUNT, GROUP BY and select statement? -

i have form linq query select, count , select statement my table looks date name 2015-04-25 xxy 2015-04-25 pap 2015-04-25 sms 2014-07-12 bljoe 2014-07-12 olk i want result similar date count 2015-04-25 3 2014-07-12 2 my sql query : select t.date, count(k.name) table t group t.date but dont know how linq query should : i tried this. returned exception var result = (from ka in _db.table group t new {t.date} g select new { date = g.key, count = g.firstordefault().name.count() }).tolist();

java - Within object B, how to access an object A that has created object B? -

my code of form below: public class outer { protected int data; protected inner inner; protected void run() { inner = new inner(); } } public class inner extends outer { protected getouterdata() { ... } } an inner object created within method of class outer . within inner object, there way access data of instance of class outer has created inner object? edit: realise can pass outer object inner object via constructor wondering if there way? edit2: passing object via constructor ok i'm doing. public class outer { protected int data; protected inner inner; protected void run() { inner = new inner(this); } } public class inner extends outer { private outer parent; inner(outer parent) { this.parent = parent } protected getouterdata() { return parent; } }

winforms - Adding a list item to a form from another CPP file [ C++/CLI] -

i've been given project , i've been stuck 2 days trying figure out. i have cpp file (base_station.cpp) reads , writes port. want display information on form's listbox (actionlogbox) created. line want add item has(base_station.cpp): actionlogbox->addstring("attempting pin"); base_staion.cpp /********************* * base_station.cpp * base_station.cpp holds implementation each individual * function applies base station. better understanding * of each function, please, see reference desired function. *********************/ #pragma once #include "mainform.h" #include "stdafx.h" /* base station functionality */ #include "base_station.h" /* used serial (comm) port functionality */ #include "serial.h" /*********************** * bs_ping * bs_ping attempts ping base station attached given * port handle, hport. * command format * length: 1 byte * byte 1: 0x01 * response:

Next business day of given date in PHP -

does have php snippet calculate next business day given date? how does, example, yyyy-mm-dd need converted find out next business day? example: 03.04.2011 (dd-mm-yyyy) next business day 04.04.2011. 08.04.2011 next business day 11.04.2011. this variable containing date need know next business day for $cubetime['time']; variable contains: 2011-04-01 result of snippet should be: 2011-04-04 next weekday this finds next weekday specific date (not including saturday or sunday): echo date('y-m-d', strtotime('2011-04-05 +1 weekday')); you date variable of course: $mydate = '2011-04-05'; echo date('y-m-d', strtotime($mydate . ' +1 weekday')); want skip holidays?: although original poster mentioned "i don't need consider holidays", if happen want ignore holidays, remember - "holidays" array of whatever dates don't want include , differs country, region, company, person...etc. simply

ios - How do i correctly handle context.rollback() with an NSFetchResultsController -

i have nsfetchresultscontroller provides data uitableview. have add button in navigation bar lets user add new entity in next view. in next view create new entity , insert context. user can save change. however, if user decides not keep new entity, can hit cancel , call context.rollback() rid of new entity. causes fetchresultscontroller throw exception: terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid update: invalid number of rows in section 0. number of rows contained in existing section after update (2) must equal number of rows contained in section before update (2), plus or minus number of rows inserted or deleted section (0 inserted, 1 deleted) , plus or minus number of rows moved or out of section (0 moved in, 0 moved out). this error shown when have 2 entities, , create third 1 , hit cancel. the exception thrown right perform rollback, on other view. perform insert following code: let entity = nsentitydesc

c++ - What is better: return std::string by value or by constant reference? -

this question has answer here: are days of passing const std::string & parameter over? 11 answers here class 2 getters different return type: class { std::string m_test { "test" }; public: std::string test_by_value { return m_test; } const std::string& test_by_const_ref() { return m_test; } }; // ... which better? std::string, not built-in types. s.t.l. says in https://channel9.msdn.com/events/goingnative/2013/don-t-help-the-compiler better return value, because multiple copies optimized? or incorrectly understanded him? by value. i encountered similar code in wild: a foo(); std::string const& x = foo().test_by_const_ref(); boom, x dangling reference. that not happen returns value.

python - How to persist scheduled jobs using APScheduler until they finish completely? -

i'm using apscheduler python 2.7.6. i'm using blockingscheduler store scheduled jobs , sqlalchemy persistent database. i want schedule jobs , guarantee finish (function reach last line). working fine, see when job started, it's removed database, when job did not finish entire method. note: obviously, developed jobs not have state , can re-executed in next program executions. should not issue discussed in question. what best way persist job until complete function/method executed using apscheduler? i had similar problem, , able resolve using background scheduler instead of blocking scheduler.

html - javascript/angularjs cut string to fit in a div -

in angularjs/ionic mobile application have implemented list of messages. want modify it, if message text wider div container should cut string , adds 3 dots. my message list looks this: <ion-list ng-repeat="message in messages"> <ion-item can-swipe="true" class="item-icon-left item-icon-right"> <i class="icon ion-email-unread"></i> <div class="row"> <span class="col col-50"> <h2>{{message.title}}</h2> </span> <span class="col col-50 content-right text-small"> {{message.datestring}} </span> </div> <div class="row"> <span class="col text-small"> {{message.text}} </span> </div> <i class="icon ion-chevron-rig

excel - VBA: Search email in non default outlook inbox? -

i using following vba code checks emails specific subject heading. the problem checks default outlook inbox folder when need check inbox of other email account. can please show me how this? sub macro1() set olapp = createobject("outlook.application") dim olns outlook.namespace dim fldr outlook.mapifolder dim myitem outlook.mailitem dim myattachment outlook.attachment dim long dim olmail variant set olapp = new outlook.application set olns = olapp.getnamespace("mapi") set fldr = olns.getdefaultfolder(olfolderinbox) set mytasks = fldr.items set olmail = mytasks.find("[subject] = ""new supplier request: ticket""") if not (olmail nothing) each myitem in mytasks if myitem.attachments.count <> 0 each myattachment in myitem.attachments if instr(myattachment.displayname, ".txt")

web services - Create simple SOAP to File communication -

i'm new in wso2 , want create simple communication between client (e.g. soap ui) , server (e.g. axis2) wso2-esb (soap file scenario). i'm total beginner , don't know, how start. thank :) why not start running few samples? https://docs.wso2.com/display/esb481/samples

python - Check if points lies inside a convex hull -

i making convex hull using scipy.spatial package http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.convexhull.html#scipy.spatial.convexhull i've tried searching, have yet know if there easy way find if point (latitude/longitude) lies inside convex hull. suggestions? the method i've used before using path class matplotlib . has contains_point method that. contains_points allows query array of points. to use do from scipy.spatial import convexhull matplotlib.path import path hull = convexhull( points ) hull_path = path( points[hull.vertices] ) print hull_path.contains_point((1,2)) # (1,2) in convex hull?

Multidimensional array sort and unique by key- PHP -

this question has answer here: how can sort arrays , data in php? 7 answers $mp = array( array('url'=>'www.abc.com','time'=>'1433551154','referral_url'=>'www.pqr.com'), array('url'=>'www.xyz.com','time'=>'1433551150','referral_url'=>'www.stu.com'), array('url'=>'www.lmn.com','time'=>'1433551190','referral_url'=>'www.jhi.com'), array('url'=>'www.rst.com','time'=>'1433551170','referral_url'=>'www.pqr.com') ); the above input array, need output sort time , unique referral_url. resultant be- $mp = array( array('url'=>'www.lmn.com','time'=>'1433551190','referral_url'=>'www.jhi.com'), ar

ios - Apple - In app purchase: How to make sure the user is authorised to use Free trial subscription only one time? -

i have auto renewable subscription free trial. happens if user cancels subscription during trial period, , after day or week or month, buys subscription again. did trial period? if so, how can prevent it. how avoid abuse? in apple's papers - have not seen clear reference this. validate receipt either app or server: https://developer.apple.com/library/ios/releasenotes/general/validateappstorereceipt/introduction.html it tell if subscription has been cancelled.

PHP file is not refreshed after fwrite and fclose -

i doing following: $configurationfile = fopen($configurationfilepath, 'w'); $result = fwrite($configurationfile, $newfilecontent); fflush($configurationfile); fclose($configurationfile); if ($result) { echo '<pre>'; var_dump(require('file.php')); die(); ... and old data shown, though in editor or after page refresh can see new content. how force php see new file content right after fclose ? thanks @engvrdr hint. problem opcache extension , ended 2 ways: disable opcache: ini_set('opcache.enable', '0'); i wrote @ beginning of index file can tuned particular cases make script run longer means of sleep() (pretty rough solution)

php - ICONV encoding differs between localhost and remote server -

i have problem encoding on localhosot , remote server. example when choose russian langueage on localhost show me "вторник 14.07.15"(correct answer) on remote server "Вторник 14.07.15". in lang.ru.php utf-8 encoding , file looks this: setlocale(lc_all, 'ru_ru.utf-8', 'ru_ru', 'ru', 'rus', 'russian', 'ru_ru.iso_8859-5', 'russian_russia.1251'); $lang = array(); $lang['code'] = "ru"; $lang['page_title'] = 'hello'; in index.php show date: echo "<span class='daydatetime'>" . iconv('windows-1250', 'utf-8//translit',strftime("%a <br> %d.%m.%y", strtotime("+ 1 days"))) . "</span>"; why in localhost right , in remote server broken encoding? grateful if me. best regards. from php's setlocale page: if locale array or followed additional parameters each array element o

java - Max User Connections exception for mysql -

i using mysql server database , tomcat 7.0.57 on mochahost server. maximum 25 connections given me. now, getting max_user connection exception. searched everywhere didnt solution. tried connection pooling webste running very though im not getting exception.

ng-show not working properly in angularjs -

i want show element based on value of property inside controller. ereaderbook.directive("controltools", function () { return { replace : true, restrict : "e", templateurl : "assets/directives/controlstools.html", controller : function ($scope) { $scope.visible = false; }, link : function (scope, el, attr) { el.bind("mouseover",function() { console.log(scope.visible) scope.visible = true; }); el.bind("mouseout",function() { console.log(scope.visible) scope.visible = false; }) } }; }); <div class="menuitem"><span class="glyphicon glyphicon-search"></span><span ng-show="visible" class="menutext">toc</span></div> inside directive have controller defined $scope.visible = false . works fine on page load. want change state $scop

html - How to make header like that in css? -

Image
my site code usual <div class="header"></div> <div class="site-inner"></div> <div class="footer"></div> how can make header background on image? whole site content have position absolute , margin-top:-500px ? is case it? i assume mean overlap. negative margin 1 way. .header { height: 50px; background: lightblue; } .site-inner { width: 80%; margin: auto; height: 50px; background: lightgrey; margin-top: -30px; box-shadow: 0 -2px 2px black; } <div class="header"></div> <div class="site-inner"></div>

SQLite upsert for android -

i have create next table: final string sql_create_table_news_tape = "create table " + newstapeentry.table_name + " (" + newstapeentry.news_id + " integer primary key, " + newstapeentry.user_id + " integer not null, " + newstapeentry.content + " text, " + newstapeentry.created_at + " text, " + " foreign key (" + newstapeentry.news_id + ") references " + newstapeentry.table_name + " (" + newstapeentry.news_id + "), " + " unique (" + newstapeentry.news_id + ") on conflict update);"; but if make update mynews, every time insert each row in table... , need next result: when updating - firs check if current id exist, if true - update current row in table, if false - make insert! there small point, must done: if id exist, , row updating, must not overwrite

java - Arquillian wildfly8.2 embedded : JBAS014670: Failed initializing module org.jboss.as.logging -

i'm trying set project uses arquillian kind of integration testing. went through tutorials can't test running. exception is: cannot not load jboss logmanager. logmanager has been accessed prior initialization. jul 14, 2015 10:30:37 org.jboss.msc.service.servicecontainerimpl <clinit> info: jboss msc version 1.2.2.final jul 14, 2015 10:30:37 org.jboss.as.server.applicationserverservice start info: jbas015899: wildfly 8.2.0.final "tweek" starting jul 14, 2015 10:30:38 org.jboss.as.controller.abstractoperationcontext executestep error: jbas014612: operation ("parallel-extension-add") failed - address: ([]) java.lang.runtimeexception: jbas014670: failed initializing module org.jboss.as.logging @ org.jboss.as.controller.extension.parallelextensionaddhandler$1.execute(parallelextensionaddhandler.java:111) @ org.jboss.as.controller.abstractoperationcontext.executestep(abstractoperationcontext.java:660) @ org.jboss.as.controller.abstractoperat