This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn of all lights when your PC goes to sleep | |
# | |
# If {Webhooks receive a web request} then {Philips Hue turn off lights} | |
# https://ifttt.com | |
# Change $hook, $from and $to of your preference. | |
$hook = 'https://maker.ifttt.com/trigger/{event}/with/key/{key}' | |
$from = '00:00' | |
$to = '06:00' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>RxJs+Cycle-React</title> | |
</head> | |
<body> | |
<div id='root'> | |
</div> | |
</body> | |
<script src="/index.js"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cycle, {Rx, h} from 'cyclejs'; | |
Cycle.registerCustomElement('TodoList', (rootElem$, props) => { | |
let vtree$ = props.get('items$').map(items => | |
h('div', h('ul', items.map((itemText, index) => | |
h('li', { key: index + itemText }, itemText))))); | |
rootElem$.inject(vtree$); | |
}); | |
let vtree$ = Cycle.createStream(function (interaction$) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cycle, {Rx, h} from 'cyclejs'; | |
Cycle.registerCustomElement('x-element', function (rootElem$, props) { | |
let vtree$ = props.get('list$').map((list) => | |
h('div', null, [ | |
h('ol', list.map((value) => h('li', null, value))) | |
])); | |
rootElem$.inject(vtree$); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function imageSizeGetter(image: HTMLImageElement, callback: (size:[number, number]) => any): void { | |
if (image.width > 0 && image.height > 0) { | |
callback([image.width, image.height]); | |
} else { | |
var observer = new MutationObserver(function (record) { | |
observer.disconnect(); | |
callback([image.width, image.height]); | |
}); | |
observer.observe(image, { | |
attributes: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gestureObservable = Rx.Observable.createWithDisposable(function (observer) { | |
var gesture = new MSGesture(); | |
gesture.target = gestureTarget; | |
var pointerSub = Rx.Observable.fromEvent(gestureTarget, "pointerdown") | |
.subscribe((ev: any) => gesture.addPointer(ev.pointerId)); | |
var gestureSub = Rx.Observable.fromEvent(gestureTarget, "MSGestureTap") | |
.subscribe((ev: MSGestureEvent) => observer.onNext(ev)); | |
return new Rx.CompositeDisposable( | |
pointerSub, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_all_user_emails : function ( count, next ){ | |
var i = Math.ceil( count / 10000 ); | |
var skip = 0; | |
var promises = []; | |
for( ; i-- ; ){ | |
promises.push( User. | |
find({ is_verified : true }) | |
lean(). | |
select( 'email' ). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build_assets : function ( config, promise, type, tmp_dir ){ | |
var self = this; | |
var path = config.path[ type ]; | |
var assets = config[ type ]; | |
return promise.all( Object.keys( assets ).map( function ( group ){ | |
var input = assets[ group ].site ? assets[ group ].site.map( function ( asset ){ | |
return self.pub_dir + path + '/' + asset + '.' + type; | |
}) : []; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require( 'q' ); | |
var overwrite_array = function ( source, array ){ | |
var result = source.slice( 0 ); | |
Array.prototype.splice.apply( result, [ 0, array.length ].concat( array )); | |
return result; | |
}; | |
var xyz = [ 5, 6, 7 ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require( 'q' ); | |
var xyz = { x : 5, y : 6, z : 7 }; | |
Q.all([ | |
// simulates a time consuming io operation | |
Q.delay( 200 ).then( function (){ | |
console.log( 'first task ---------------' ); | |
console.log( 'x : ' + xyz.x ); |
NewerOlder