This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Attempts to regenerate HTML and Markdown files from RAML upon component | |
# file changes. | |
# | |
# NOTE: Requires `fswatch` | |
FSWATCH=$(which fswatch) | |
RAML2HTML=$(which raml2html) | |
RAML2MD=$(which raml2md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Many novices, looking to get started with web programming, fall into the trap | |
# of learning Rails before achieving a solid grasp of the Ruby language. To | |
# understand Rails, one should have a basic understanding of programming | |
# fundamentals, especially Objects and Inheritance. | |
# | |
# Additionally, there are many Rails-specific methods patched into the Object | |
# class. While this is incredibly convenient, it makes learning Ruby as | |
# a language somewhat obtuse. For an example, consider the following snippet: | |
foo = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: the majority of these commands should be run as root | |
# install dependency packages | |
yum install -y gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap autoconf automake | |
mkdir -p $HOME/src | |
cd $HOME/src | |
# download/extract the latest source tarball | |
wget https://github.com/s3fs-fuse/s3fs-fuse/archive/master.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NEW_REMOTE="[email protected]:your/repo.git" | |
# Rename the old origin | |
# Add the new origin | |
# Push all local branches to new origin and set respective tracking branches | |
git remote rename origin old_origin | |
git remote add origin $NEW_REMOTE | |
git remote push --all -u origin | |
# NOTE: Could benefit from refactor to use a "git clone --mirror" flow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by iptables-save v1.4.21 on Fri Mar 6 01:19:41 2015 | |
*filter | |
:INPUT ACCEPT [5321:859636] | |
:FORWARD ACCEPT [0:0] | |
:OUTPUT ACCEPT [4300:2722225] | |
:LOGDROP - [0:0] | |
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 --name DEFAULT --mask 255.255.255.255 --rsource -j LOGDROP | |
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name DEFAULT --mask 255.255.255.255 --rsource | |
-A LOGDROP -j LOG | |
-A LOGDROP -j DROP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cache_key_for_foo | |
cache_key_prefix_from_method | |
end | |
def cache_key_prefix_from_method | |
calling_method = ::Kernel.caller[0][/`.*'/][1..-2] | |
calling_method[14..-1] # length of "cache_key_for_" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Collection | |
extend ActiveSupport::Concern | |
included do | |
def cache_key(updated_at_field = :updated_at) | |
class_name = self.class.to_s.demodulize.downcase | |
count = self.count | |
max_updated_at = self.maximum(updated_at_field).try(:utc).try(:to_s, :number) | |
"#{class_name}/#{count}/#{max_updated_at}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def traverse_and_rename(dir) | |
Dir.entries(dir).each do |entry| | |
next if %w(. ..).include?(entry) || !File.directory?(entry) | |
if entry[/[A-Z]/] | |
File.rename(entry, entry.downcase) | |
else | |
Dir.chdir(entry) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync | |
def build_spinner | |
chars = %w(๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐).cycle | |
Thread.new do | |
loop do | |
print chars.next + ' ' | |
sleep(0.1) | |
print "\b\b\b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Example for batch CSV updates | |
Convert a given CSV file to a JSON object | |
""" | |
import sys | |
import csv |
NewerOlder