Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@mackhowell
mackhowell / sicp.scm
Created February 4, 2015 05:02
SICP - ex 1.1 - 1.5
#lang racket
; -- 1.1 --
; (define a 3)
; (define b (+ a 1))
; (+ a b (* a b))
; (if (and (> b a) (< b (* a b)))
; b
@mackhowell
mackhowell / .vimrc
Last active August 29, 2015 14:15
.vimrc
set nocompatible
filetype off " required for vundle
set rtp+=~/.vim/bundle/Vundle.vim
set runtimepath^=~/.vim/bundle/ctrlp.vim
call vundle#begin()
execute pathogen#infect()
Plugin 'gmarik/Vundle.vim'
@mackhowell
mackhowell / swift-book
Created June 24, 2015 20:09
swift-book
import UIKit
// operator overloading
func + (left: [Double], right: [Double]) -> [Double] {
var sum: [Double] = []
for (n, m) in zip(left, right) {
sum.append(n + m)
}
return sum
@mackhowell
mackhowell / tuples.swift
Created September 23, 2015 21:14
tuples
//: Playground - noun: a place where people can play
import UIKit
// ARRAYS
// many ways to mak arrays
var array1: Array<String>
var array2: [String]
var array3 = ["apple", "pear"]
@mackhowell
mackhowell / sample_publish.swift
Last active September 11, 2018 18:33
pubnub status "Bad Request"
func updateSongInformationForListener(currentTrack: Track, channelID: String) {
let song = currentTrack.dictionaryValue()
client.publish(song, toChannel: channelID, compressed: true) { (status) -> Void in
if status.error {
print("*** pubnub publish error: \(status.category), \(status.error.description)")
print(status.debugDescription)
// Request can be resent using: status.retry()
}
}
}
@mackhowell
mackhowell / vibrate.swift
Created December 7, 2017 00:04
home button "pop" forever
import AudioToolbox
func vibrateForever() {
let k_PeakSoundID: UInt32 = 1519
while true {
AudioServicesPlaySystemSound(k_PeakSoundID)
}
}
@mackhowell
mackhowell / OutlineModifier.fragment
Created May 2, 2018 14:51
Swift / iOS silhouette shader modifier
// Fragment Shader Modifier
// Implicit struct to use:
/*
struct SCNShaderOutput {
vec4 color;
} _output;
*/
varying vec3 varyingNormal;