Skip to content

Instantly share code, notes, and snippets.

View ducksoupdev's full-sized avatar

Matt Levy ducksoupdev

View GitHub Profile
@ducksoupdev
ducksoupdev / Hero directive
Created October 13, 2014 14:08
An example AngularJS directive
"use strict";
angular.module("example.web.content")
.directive("waHero", ["$compile", function($compile) {
return {
restrict: "EAC",
scope: {
interval: "=?"
},
template: "<div class='wa-hero-container container'><div class='transcluded' ng-transclude></div></div>",
transclude: true,
description "Mailcatcher"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
pre-start script
bash << "EOF"
mkdir -p /var/log/mailcatcher
# Atom Cheatsheet.
# Project Key Bindings.
- 'cmd-shift-p': open the command palette.
- 'cmd-p' or 'cmd-t': open the fuzzy finder to find a file.
- 'cmd-b': look for a file that is already open.
- 'cmd-shift-b': search the list of files modified and untracked in your project repository.
- 'ctrl-0': open and focus the the tree view.
@ducksoupdev
ducksoupdev / Isomorphic JS
Last active August 29, 2015 14:12
Template for isomorphix (server + client) JS
(function (root, factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define(["b"], function (b) {
return (root.returnExportsGlobal = factory(b));
});
} else if (typeof exports === "object") {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
@ducksoupdev
ducksoupdev / Regex indexof
Last active August 29, 2015 14:13
Regex indexof methods
String.prototype.regexIndexOf = function(regex, startpos) {
var indexOf = this.substring(startpos || 0).search(regex);
return (indexOf >= 0) ? (indexOf + (startpos || 0)) : indexOf;
}
String.prototype.regexLastIndexOf = function(regex, startpos) {
regex = (regex.global) ? regex : new RegExp(regex.source, "g" + (regex.ignoreCase ? "i" : "") + (regex.multiLine ? "m" : ""));
if(typeof (startpos) == "undefined") {
startpos = this.length;
} else if(startpos < 0) {
@ducksoupdev
ducksoupdev / Fire onorientationchange in Chrome
Created February 19, 2015 12:50
Fire onorientationchange in Chrome
Run this in the console:
window.dispatchEvent(new Event('orientationchange'));
var _ = require('lodash'),
fs = require('fs'),
path = require('path'),
csv = require('csv'),
Sequelize = require('sequelize');
function addUser(db, filename, rolesByName, addresses) {
var parser = csv.parse({}, function (err, data) {
db.models.User.bulkCreate(
_.map(data, function (record, index) {
@ducksoupdev
ducksoupdev / modal.ts
Created November 25, 2015 14:21
Typescript bootstrap modal
export interface IModalOptions {
backdrop:boolean;
keyboard:boolean;
duration:number;
content?:string;
}
export class Modal {
private isIE:boolean;
@ducksoupdev
ducksoupdev / sha1.ts
Created December 1, 2015 09:40
Typescript SHA1
module sha1
{
var POW_2_24 = Math.pow(2, 24);
var POW_2_32 = Math.pow(2, 32);
function hex(n: number): string
{
var s = "",
@ducksoupdev
ducksoupdev / install-packages.ps1
Created December 8, 2015 13:09
Chocolatey PS installs
choco install telegram.install
choco install curl
choco install evernote
choco install opera
choco install google-chrome-x64
choco install putty
choco install filezilla
choco install python2
choco install nugetpackageexplorer