Skip to content

Instantly share code, notes, and snippets.

0xfDaD8863fE73bC3E22343B95922B7247f612569b
@startswithaj
startswithaj / ts-jest.sh
Created December 1, 2016 02:48 — forked from simon-lang/ts-jest.sh
typescript, jest
yarn init
yarn add typescript jest ts-jest
tsc --init
typings install dt~jasmine --save --global
jest
@startswithaj
startswithaj / project-init.sh
Created December 1, 2016 02:48 — forked from simon-lang/project-init.sh
project-init.sh
# project init
mkdir project-name
cd project-name
touch README.md
mkdir src dist
echo "console.log('hello world')" > src/entry.js
echo '<script src="bundle.js"></script>' > dist/index.html
Athlete = require './athlete'
module.exports = class AthleteList
@fromArray: (data, entryClass = Athlete) -> new @ data, entryClass
constructor: (data, @entryClass = Athlete) -> @updateFromArray data
updateFromArray: (data) ->
@members ?= {}
ps = angular.element('ui-view').scope()
ms = angular.element('.modal-window > *:eq(0)').scope()
s = ms || ps
c = s.lCtrl || s.mcCtrl || s.luCtrl || s.ipCtrl || s.viewContestCtrl || s.myLineupsCtrl || s.llCtrl || s.aCtrl
vm = c.vm
// optional:
console.clear()
console.log('vm', vm)
if (t = vm.contests || vm.athletes) console.table(t)
@startswithaj
startswithaj / gist:c57387366e688e071f97
Created April 8, 2015 04:45
Jade Syntax highlighting angular bindings and controllerAs
<!-- Changese on line: 899 and line 1176 -->
<!-- ?&lt;=\{\{)(.+)(?=\}\}) matches inside {{}} binding -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>jade</string>
</array>
@startswithaj
startswithaj / RegexMultiReplace
Last active August 29, 2015 14:02
Multiple Replace
characters =
'á': 'a'
'é': 'e'
'í': 'i'
'ó': 'o'
'ñ': 'n'
reg = new RegExp '[' + _.keys(x).join("") + ']', 'g'
str.replace reg , (chr) ->
return characters[chr];
@startswithaj
startswithaj / gist:a5c7289da0590a480a3b
Created June 3, 2014 00:59
Generate ssl cert for localhost use with express
Commands:
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
>>>>>Common Name (eg, YOUR name) []:localhost
openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt
Express:
privateKey = fs.readFileSync('/Users/jake/webclient/server.key').toString();
certificate = fs.readFileSync('/Users/jake/webclient/server.crt').toString();
@startswithaj
startswithaj / gist:9182441
Created February 24, 2014 05:30
overscroll
#uses document because document will be topmost level in bubbling
$(document).on "touchmove", (e) ->
e.preventDefault()
#uses body because jquery on events are called off of the element they are
#added to, so bubbling would not work if we used document instead.
$("body").on "touchstart", ".mobile-scrolling", (e) ->
if e.currentTarget.scrollTop is 0
e.currentTarget.scrollTop = 1
@startswithaj
startswithaj / gist:8816698
Created February 5, 2014 02:51
NPM fixes
# force update npm globally
npm update -gf
# fix brew symlinks
brew unlink node && brew link --overwrite node
# give current user permissions to npm config and install global install directory
sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` ~/.npm