This file contains 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
class ApiLogger < Grape::Middleware::Base | |
def before | |
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" + | |
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}" | |
end | |
private | |
def request_log_data |
This file contains 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
#!/bin/bash | |
DROPBOX_USERS="root" | |
DAEMON=.dropbox-dist/dropboxd | |
start() { | |
echo "Starting dropbox..." | |
for dbuser in $DROPBOX_USERS; do | |
HOMEDIR=`getent passwd $dbuser | cut -d: -f6` |
This file contains 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
git branch --merged | grep -v master | xargs git branch -d | |
git branch -r --merged | awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' | xargs git push origin --delete |
This file contains 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
#!/bin/bash | |
set -e | |
echo "Backing up MongoDB databases to Dropbox ..." | |
dt=$(date +"%Y-%m-%d") | |
echo " today is $dt" |
This file contains 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 ApiPageHelper | |
PAGINATE_OPTIONS = { | |
:default_page_size => 10 | |
} | |
PAGINATE_PARAMS = [ "page", "offset", "size" ] | |
def paginate(coll, options = {}) | |
options = PAGINATE_OPTIONS.merge(options) | |
if params[:page] | |
page = params[:page].to_i | |
size = (params[:size] || options[:default_page_size]).to_i |
This file contains 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
class App | |
def initialize(options) | |
@try = ['', *options.delete(:try)] | |
@static = ::Rack::Static.new( | |
lambda { [404, {}, []] }, | |
options) | |
end | |
def call(env) |
This file contains 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
/* | |
Create Element: | |
$Rainb.el('div',{'attribute':"value",style:{"color":"red"}},[ (childnodes) ]) | |
becomes: <div attribute="value" style="color: red;"></div> | |
Append Element | |
$Rainb.add(element,elementToAppend) | |
Get Element By Id | |
$Rainb.id(id); | |
Create TextNode | |
$Rainb.tn(text); |
This file contains 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
// | |
// from http://waffle.codeplex.com/workitem/10034 | |
// | |
package waffle.servlet.spi; | |
import java.io.IOException; | |
import java.security.Principal; | |
import java.util.Date; | |
import java.util.Enumeration; |
This file contains 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
# inspired by https://github.com/rspec/rspec-core/pull/596 | |
require 'rspec/core/formatters/base_formatter' | |
module RSpec | |
module Core | |
module Formatters | |
class FailuresFormatter < BaseFormatter | |
def dump_failures | |
return if failed_examples.empty? |
This file contains 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
# Rails 4 | |
require 'action_view/helpers/asset_url_helper' | |
module ActionView | |
module Helpers | |
module AssetUrlHelper | |
def accept_encoding?(encoding) | |
request = self.request if respond_to?(:request) | |
return false unless request |