Skip to content

Instantly share code, notes, and snippets.

View berryp's full-sized avatar
😎

Berry Phillips berryp

😎
  • Seoul, Korea
  • 16:17 (UTC +09:00)
View GitHub Profile
@berryp
berryp / gist:1217500
Created September 14, 2011 19:17
NGINX config to control access based on HTTP method
if ($request_method = POST ) {
return 405;
}
@berryp
berryp / gist:1453225
Created December 9, 2011 20:44
bsddb stub
class DB(object):
def __init__(self, dbenv, *args, **kwargs):
pass
def __len__(self):
return 0
def __getitem__(self, arg):
@berryp
berryp / brew-services.rb
Created March 2, 2012 19:51 — forked from bryanveloso/brew-services.rb
External script for homebrew to simplify starting services via launchctl, out of the box support for any formula which implements #startup_plist. (This version fixes the deprecation warning raised on Formula.resolve_alias.)
#!/usr/bin/env ruby -w
# brew-services(1) - Easily start and stop formulas via launchctl
# ===============================================================
#
# ## SYNOPSIS
#
# [<sudo>] `brew services` `list`<br>
# [<sudo>] `brew services` `restart` <formula><br>
# [<sudo>] `brew services` `start` <formula> [<plist>]<br>
@berryp
berryp / 04_jshint.rake
Created September 17, 2012 18:05 — forked from jamesarosen/04_jshint.rake
Javascript Loves CI: Jenkins + Jasmine + PhantomJS + JSHint
namespace :jshint do
task :require do
sh "which jshint" do |ok, res|
fail 'Cannot find jshint on $PATH' unless ok
end
end
task :check => 'jshint:require' do
project_root = File.expand_path('../../', File.dirname(__FILE__))
config_file = File.join(project_root, 'config', 'jshint.json')
{
"auto_complete": false,
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"find_selected_text": true,
"fold_buttons": true,
"font_options":
[
"subpixel_antialias"
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
# ~/.osx — http://mths.be/osx
# root check
if [[ $EUID -ne 0 ]]; then
echo "################################";
echo "## YOU ARE NOT RUNNING AS ROOT #";
echo "################################";
echo "#";
echo "# USAGE: sudo $0";
exit;
#!/bin/sh
# this file should be marked as executable and placed on .git/hooks/
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ] && [ "$BRANCH_NAME" != "(nobranch)" ]; then
echo "#$BRANCH_NAME $(cat $1)" > $1
fi
@berryp
berryp / greplog.sh
Last active December 23, 2015 13:59
Grep output starting at column n.
# Strip the host and path information from the output.
tail -f /var/log/myservices.log | awk '/myproc/{ print substr($0, 82) }'
@berryp
berryp / isonscreen.js
Created September 21, 2013 20:49
jQuery method to test if any part of a given element is visible in the viewport.
/**
* jQuery method to test if any part of a given element is visible in the viewport.
* Source: http://upshots.org/javascript/jquery-test-if-element-is-in-viewport-visible-on-screen
**/
$.fn.isOnScreen = function () {
var win = $(window);
var viewport = {
top: win.scrollTop(),