A Pen by Thibaut Nguyen on CodePen.
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
const fnWrapper = (...args) => () => args.forEach(f => f()); | |
const method1 = document.write.bind(document, ['hello']); | |
const method2 = document.write.bind(document, ['world']); | |
const wrapped = fnWrapper(method1, method2); | |
wrapped(); |
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
appDirectives.directive 'stickyScroll', -> | |
return { | |
restrict: 'A' | |
link: (scope, element, attr) -> | |
unregisterWatch = scope.$watch( | |
-> return element[0].scrollHeight, | |
-> | |
element[0].scrollTop = element[0].scrollHeight | |
) |
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
#map |
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
#!/bin/bash | |
read -e -p "Project path: " pathName | |
mkdir -p $pathName && cd $pathName | |
npm init -f | |
npm install --save babel babelify body-parser browserify cookie-parser express grunt grunt-browserify grunt-cli jade minifyify react reflux | |
dirArray=(data public react views) | |
for dir in ${dirArray[*]} | |
do | |
mkdir $dir |
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
{ | |
"caret_extra_width": 2, | |
"color_scheme": "Packages/Theme - Afterglow/Afterglow.tmTheme", | |
"font_size": 14, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"tabs_medium": true, | |
"theme": "Afterglow.sublime-theme", |
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 event = new CustomEvent('newMsg', { detail: 'Hello people' }); | |
window.addEventListener('newMsg', function handler(e){ console.log(e.detail) }, false); | |
window.dispatchEvent(event); |
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
{"BE":"Belgium"}, {"IT":"Italia"} | |
to | |
[{ "code": "BE", "name": "Belgium"}, { "code": "IT", "name": "Italia"}] | |
replace this ([^{},:]*):([^{},:]*) | |
with this : { "code":$1, "name": $2 } |
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
# This service is a wrapper for the Notification API | |
# It ensures only one notification is shown at a time | |
angular.module('acmeServices').factory 'notificationService', ($window, $timeout, userPrefsService) -> | |
ALREADY_PROMPTED_UP_KEY = 'notifAlreadyPrompted' | |
LAST_NOTIF_TIME_UP_KEY = 'lastNotifTime' | |
NOTIF_GRANTED_STATE = 'granted' | |
NOTIF_DENIED_STATE = 'denied' | |
NOTIF_TIMEOUT_MS = 20000 |
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
angular.factory 'userPrefsService', (localStorageService) -> | |
STORAGE_KEY = 'userPrefs' | |
userPrefs = localStorageService.get(STORAGE_KEY) || {} | |
return { | |
set: (key, obj) -> | |
if !key? || key.length == 0 | |
throw new Error('A key is required to store a value in the store') | |
if obj == null | |
delete userPrefs[key] |