Skip to content

Instantly share code, notes, and snippets.

View hiulit's full-sized avatar
💻
Working

hiulit

💻
Working
View GitHub Profile
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@darrenclark
darrenclark / progress-bar.sh
Created November 25, 2011 05:02
Shell Progress Bar
# After wondering how commands like curl showed a progress bar, with the very big help of
# Google, I decided to write a shell script to show a progress bar
#
# Having not done much shell scripting, I learned a few (very likely quite obvious) things:
# * It looks much nicer to create the string to echo in a variable, then echo it. If I echo'ed
# each part of the string instead of concatenating it with the rest of the string, the cursor
# jumped around quite a bit.
# * 'let x=x+1' is a lot faster than 'x=`expr $x + 1`' (I have a feeling this is probably because
# let is implemented directly in bash, instead of a separate command)
@victorsollozzo
victorsollozzo / gist:4134793
Created November 23, 2012 09:44
recursively find all files in a directory with given extension in node.js
var path = require('path')
var fs = require('fs')
function recFindByExt(base,ext,files,result)
{
files = files || fs.readdirSync(base)
result = result || []
files.forEach(
function (file) {
@rc1
rc1 / rpidipreader.sh
Last active August 11, 2022 15:30
Reading a DIP switch on the RPI
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
# use P1 header pin numbering convention
GPIO.setmode(GPIO.BOARD)
# Config
pins = [3,5,7,8,10,11,12]
@coderofsalvation
coderofsalvation / is_array.bash
Created January 11, 2014 21:44
check if variable is array, returns 0 on success, 1 otherwise
# check if variable is array, returns 0 on success, 1 otherwise
# @param mixed
is_array()
{ #detect if arg is an array, returns 0 on sucess, 1 otherwise
[ -z "$1" ] && return 1
if [ -n "$BASH" ]; then
declare -p ${1} 2> /dev/null | grep 'declare \-a' >/dev/null && return 0
fi
return 1
@LukeChannings
LukeChannings / handlebars-select-helper.js
Last active March 29, 2023 12:45
A select helper for handlebars
Handlebars.registerHelper("select", function(value, options) {
return options.fn(this)
.split('\n')
.map(function(v) {
var t = 'value="' + value + '"'
return ! RegExp(t).test(v) ? v : v.replace(t, t + ' selected="selected"')
})
.join('\n')
})
@tokland
tokland / video-resize.sh
Last active December 25, 2017 22:31
Resize videos to a fixed size with avconv
#!/bin/sh
#
# Resize videos to a given size.
# Depedencies: libav
debug() {
echo "$@" >&2
}
to_num() { local NUM_STRING=$1
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@savetheclocktower
savetheclocktower / README.md
Last active February 16, 2024 15:22
Poor-man's LEDBlinky with RetroPie and Pac-Drive

NOTE: This Gist was an early write-up of this blog post, part of what became an eleven-part series on my arcade cabinet. I'd suggest you read that post instead of this, but some of the comments on this Gist contain updates and field reports that you might find useful.

RetroPie, LED control, and you

I wanted LEDBlinky-style functionality out of my RetroPie cabinet. But I didn't need RGB control or magical frontend integration or anything like that. I had buttons with simple single-color LEDs.

I've got a simple control panel with six buttons per player. All I wanted was this:

  • When I launch Street Fighter 2, all twelve buttons should light up.
  • When I launch The Simpsons, only the first two buttons for each player should light up.