via weaning yourself off jquery
// get a single element
document.querySelector('.foo .bar')
element.querySelector('.bar')
# 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") | |
#!/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 |
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) { |
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-()<>{}[] |
via weaning yourself off jquery
// get a single element
document.querySelector('.foo .bar')
element.querySelector('.bar')