Skip to content

Instantly share code, notes, and snippets.

View aral's full-sized avatar

Aral Balkan aral

View GitHub Profile
@aral
aral / gist:8122688
Created December 25, 2013 12:08
Using nginx for dev is much faster than grunt-contrib-connect (especially with a livereload workflow) but grunt-nginx doesn’t automatically shut down the server when exiting (e.g., on CTRL-C when watching, or if there is an exception). This little snippet will detect and shut down the server.
# e.g. set up nginx task
module.exports = (grunt) ->
grunt.initConfig
nginx:
options:
config: '/usr/local/etc/nginx/nginx.conf'
# …
# Make sure we shut down the nginx server in case it’s running.
@aral
aral / gist:8150400
Created December 27, 2013 17:56
If you are having trouble building Camlistore on OS X (Mavericks, but also perhaps earlier versions), try this.
If the error you are getting when you type:
go run make.go
is along the lines of:
camlistore.org/third_party/code.google.com/p/rsc/fuse
# camlistore.org/third_party/code.google.com/p/rsc/fuse
clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types'
Error building main binaries: exit status 2
@aral
aral / LEDPong.ino
Created March 30, 2014 20:11
1D LED Pong inspired by Jason Hotchkiss’s 1D Pong
//
// 1D LED PONG
// Copyright (c) 2014 Aral Balkan. Released under the MIT License.
//
// Inspired by Jason Hotchkiss’s 1D Pong (hat-tip Seb Lee-Delisle)
//
// Video of working result: https://twitter.com/aral/status/450334281953722369
//
// With knowledge gleamed from the Build Brighton Introduction to Arduino Workshop on 29th March, 2014.
// http://buildbrighton.com
@aral
aral / gist:273110ea2965219dce97
Last active August 30, 2016 17:49
A quick hack with a div overlay to stop Mapbox iframe map from breaking the scroll of the page
/*
<iframe id='map' width='100%' height='500px' frameBorder='0' src='https://a.tiles.mapbox.com/v3/laurakalbag.ie85aj18/attribution,zoompan,geocoder,share.html'></iframe>
<!-- This overlay is used to prevent Mapbox from breaking the scroll of the page on touch-enabled devices. -->
<div id="overlay" class="overlay" style="position: relative; width: 100%; height: 511px; margin-top:-511px;">
<img src="" width: 100% height: 500px>
</div>
*/
//
@aral
aral / transcript.coffee
Last active September 4, 2020 15:44
Quick and dirty regexp that we use to format video transcripts (CoffeeScript)
#!/usr/bin/env coffee
fs = require 'fs'
# Get the file name that’s passed as the first argument
nameOfFile = process.argv.slice(2)[0]
# Read the file and convert it from bytes to a string
file = fs.readFileSync(nameOfFile).toString()
@aral
aral / gist:183b3bd303df237ed6d9
Created October 29, 2014 23:29
Add a new SSH key to Dokku after initial install (e.g., email starts with aral@…)
cat .ssh/authorized_keys | grep aral@ | sshcommand acl-add dokku aral
@aral
aral / gist:f208f7408e56b6db19d7
Created October 30, 2014 00:17
Hash Sieve in CoffeeScript
#
# Implementation of hash sieve algorithm that I read
# about at http://www.shamasis.net/2009/09/fast-algorithm-to-find-unique-items-in-javascript-array/
# in CoffeeScript with slightly more literate code :)
#
Array.prototype.unique = ->
hashSieve = {}
arrayOfUniqueValues = [];
@aral
aral / MainWindowController.swift
Last active August 29, 2015 14:14
Applying CATransitions — won’t work with vibrancy
//
// MainWindowController.swift
// Heartbeat
//
// Created by Aral Balkan on 07/02/2015.
// Copyright (c) 2015 Ind.ie.
// Released under the MIT license.
//
import Cocoa
@aral
aral / ugly-swift
Created February 17, 2015 21:42
Please, make it stop!
let cgContext:CGContextRef = CGBitmapContextCreate(nil, UInt(resolutionForExport.width), UInt(resolutionForExport.height), 8, 4*UInt(resolutionForExport.width), colorSpace, CGBitmapInfo.ByteOrderDefault|CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue))
@aral
aral / gist:f65d30da4aff818af3c4
Last active August 29, 2015 14:17
AnyObject? to unwrapped value
let a = NSDictionary(object: NSNumber(bool: true), forKey: "boolKey")
let b: AnyObject? = a.objectForKey("boolKey")
if let b:AnyObject = b, c:NSNumber = (b as? NSNumber) where c.boolValue == true
{
println("It’s true.")
}