Skip to content

Instantly share code, notes, and snippets.

@axelav
axelav / .gitignore
Created May 11, 2014 01:32
node .gitignore
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
operator infix ** {}
@infix func ** (left: String, right: Int) -> String {
var repeatedString = ""
for _ in 0..right {
repeatedString += left
}
return repeatedString
}
"Hello " ** 3 // Hello Hello Hello
import SpriteKit
class GameScene: SKScene, SKPhysicsContactDelegate
{
// Our main scene. Everything is added to this for the playable game
var moving: SKNode!
// Our running man! Defaults to a stand still position
var hero: SKSpriteNode! = SKSpriteNode(imageNamed: "runningman1")
@stevenjshelby
stevenjshelby / cleanbranches
Last active August 29, 2015 14:04
Clean local Git branches
#!/bin/bash
#Change these to whatever input you want to use for keeping/deleting branches
KEEP='1'
DELETE='2'
#show `git branch` output in beginning
git branch
for branch in $(git for-each-ref --format='%(refname)' refs/heads/); do
@venj
venj / UIColorExtra.swift
Last active August 29, 2015 14:04
A UIColor Extension to parse Hex string(for CSS and for KML) to color. Code works for Xcode 6 Beta 5. Based on https://github.com/yeahdongcn/UIColor-Hex-Swift/blob/master/UIColorExtension.swift
import UIKit
extension UIColor {
convenience init(kmlColorString:String) {
var scanner = NSScanner(string:kmlColorString)
var color:UInt32 = 0;
scanner.scanHexInt(&color)
let mask:UInt32 = 0x000000FF
var a = color >> 24 & mask
let pathString = "foo/bar/baz"
let path = split(pathString, {(c:Character) -> Bool in return c == "/"}, maxSplit: 90, allowEmptySlices: false)
println("path: \(path)") // [foo, bar, baz]
<?php
$needles = array(
'/fizz/buzz'
);
$haystack = '/var/tmp/fizz/buzz';
$fileMatched = array_reduce(
$needles,
function($carry, $needle) use ($haystack) {
@revathskumar
revathskumar / remote.sh
Created September 18, 2014 05:46
hub get repository
git remote -v | awk -F: {'print $2'} | awk -F. {'print $1'}
RegExp.email = /\b([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,})\b/i;
// /\b
// (?:
// https?:\/\/| # URL protocol and colon
// www\d{0,3}[.]| # or www.
// [a-z0-9.\-]+[.][a-z]{2,}\/ # or url like thing followed by a slash
// )
// (?:
// [^\s()<>]+| # Run of non-space, non-()<>{}[]

js dom techniques

via weaning yourself off jquery

selecting elements

// get a single element
document.querySelector('.foo .bar')
element.querySelector('.bar')