Skip to content

Instantly share code, notes, and snippets.

@nbrew
nbrew / chef_knife_dl.sh
Created August 28, 2014 00:04
Chef knife download and untar cookbook function
function knife_dl() {
local packages="$@"
cd /root/chef-repo/cookbooks
for c in ${packages}; do
knife cookbook site download ${c};
tar zxf ${c}*.tar.gz;
rm ${c}-*.tar.gz;
done
}
@nbrew
nbrew / switch_network.sh
Created July 9, 2014 01:50
Hackish sed scripts to change network interfaces from DHCP to Static IP on a CubieTruck
#!/bin/bash
# SETUP:
# * Replace '#iface eth0 inet<some-char>dhcp' with '# iface eth0 inet dhcp'
net="${1}"
function usage() {
echo "USAGE: ${0} (dhcp|static)"
echo
@nbrew
nbrew / toggle_power_profiles.bat
Created May 23, 2014 00:49
Batch file to toggle between two POWERCFG schemes.
@ECHO OFF
'
' SETUP:
' To get the GUIDs required, in Windows Powershell, run:
'
' POWERCFG -L
'
' Then select and right-click a GUID to copy.
'
@nbrew
nbrew / headbobber.cs
Created May 8, 2014 21:45
Unity Headbobber.js to C#
using UnityEngine;
using System.Collections;
public class Headbobber : MonoBehaviour {
private float timer = 0.0f;
public float bobbingSpeed = 0.18f;
public float bobbingAmount = 0.2f;
public float midpoint = 2.0f;
@nbrew
nbrew / touchEvents.js
Created April 10, 2014 18:42
Deal with touch events on a list. (Touch duration, swipe.)
var timeout,
longtouch,
xDown,
yDown;
$("#myList li").bind('touchstart', function() {
timeout = setTimeout(function() {
longtouch = true;
}, 300);
}).bind('touchend', function() {
@nbrew
nbrew / delayed_job_init.sh
Last active March 13, 2018 18:55 — forked from stuzart/gist:3169625
Simple init script for starting group of delayed_job workers.
#!/bin/sh
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
APP_PATH="/srv/rails/seek"
APP_NAME="Seek"
APP_USER="www-data"
NUM_WORKERS="1"
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@nbrew
nbrew / Mavericks Update Notes.md
Created February 28, 2014 23:02
Reload all installed homebrew formulas. (I found this useful after updating from OS X 10.8.x to 10.9.)
  • Download the Command Line Tools (OS X Mavericks) from https://developer.apple.com/downloads

  • From the Terminal:

    sudo xcode-select --reset sudo xcode-select --switch /Library/Develop/CommandLineTools

  • Install openssl with homebrew:

    brew remove openssl brew install openssl

@nbrew
nbrew / .git-prompt.sh
Last active August 26, 2019 15:24
My latest bash prompt customization. Colored Git bash prompt.
#!/bin/bash
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# If you don't already have git-completion installed:
#
# cd ~/
# curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
# mv ~/git.completion.bash ~/.git-completion.bash
@nbrew
nbrew / gist:7713188
Last active December 29, 2015 18:49
SO #20294398
<?php
//error_reporting(0);
include("_models.header.php");
$model= $_GET["modelname"];
$timestamp= date("Y-m-d h:i:s");
mysql_query("UPDATE groupshows SET showended='".$timestamp."' WHERE model='".$model."' AND showended='0'");
mysql_query("UPDATE groupshows SET ended='1', started='0' WHERE model='".$model."' AND customer='0'");
//udregn show cost
$result=mysql_query("SELECT * FROM groupshows where model ='".$model."' AND customer='0'");