Skip to content

Instantly share code, notes, and snippets.

View hryk's full-sized avatar
🏠
Working from home

Hiroyuki Nakamura hryk

🏠
Working from home
View GitHub Profile
@micahbrich
micahbrich / generate_and_deploy_assets.rb
Created November 16, 2009 15:25 — forked from aeden/generate_and_deploy_assets.rb
capistrano recipe for moving public files to s3
desc "Generate and deploy assets"
task :deploy_assets, :roles => :app do
# get the previous timestamp
old_timestamp = File.read("config/deploy_timestamp").to_i rescue 0
# generate timestamp into config/deploy_timestamp
timestamp = Time.now.to_i
File.open("config/deploy_timestamp", 'w') do |f|
f.write(timestamp)
end
@endolith
endolith / peakdet.m
Last active July 27, 2024 19:48
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@mirakui
mirakui / auto_growlnotify.sh
Created May 11, 2010 03:58
Pops up a growl notification when a command spends over 5 seconds
# source: http://d.hatena.ne.jp/umezo/20100508/1273332857
local COMMAND=""
local COMMAND_TIME=""
function precmd() {
if [ "$COMMAND_TIME" -ne "0" ] ; then
local d=`date +%s`
d=`expr $d - $COMMAND_TIME`
if [ "$d" -ge "5" ] ; then
COMMAND="$COMMAND "
module RSpec
module Core
module Formatters
class ProgressFormatter
alias _example_failed example_failed
def example_failed(example)
_example_failed(example)
system 'say "failed" &'
system 'growlnotify -p 1 -t "spec failed" -m "failed" &'
system 'glitch'
@scottlowe
scottlowe / .bashrc
Created September 1, 2010 22:33
Part of a recipe for fronting Glassfish with Nginx
# ~/.bashrc: executed by bash(1) for non-login shells.
# If not running interactively, don't do anything
#[ -z "$PS1" ] && return
if [[ -n "$PS1" ]] ; then
# don't put duplicate lines in the history. See bash(1) for more options
#export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&')
.replace(/>/g,'>')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
~$
\.DS_Store$
# This file is a kind of Ruby port of JPGEncoder.as
# <https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/JPGEncoder.as>
# Copyright (c) 2008, Adobe Systems Incorporated
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
@mlc
mlc / test-client.rb
Created December 20, 2010 19:45
Demonstrating using XREP/XREQ to talk to a specific client. An abuse of ØMQ?
#!/usr/bin/env ruby
require 'rubygems'
require 'ffi-rzmq'
unless ARGV.size == 1
$stderr.puts "please provide your client identifier on the command-line."
exit 1
end
@stackng
stackng / rails content_for caching
Created March 29, 2011 06:30
make action and fragment caching of rails3 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?