A Pen by Thibaut Nguyen on CodePen.
This file contains 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
employees = [{ id : 1, name : "tib" }, { id : 2, name : "dude" }] | |
search = (input, id) -> | |
for i in [0..input.length - 1] | |
if (input[i].id == id) | |
return input[i]; | |
return null |
This file contains 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
git reset HEAD~1 --soft |
This file contains 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] |
This file contains 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 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 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 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 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 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 |
OlderNewer