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
#!/usr/bin/env ruby | |
# This script is a backup tool for mongodb. | |
# | |
# The main purpose is to dump files from gridfs to filesystem, | |
# to take advantage of backup solutions based on tools like | |
# rsync. | |
# Developed against mongo 1.6.0 |
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
var mapping = { | |
'last_lp_brand' : 'SEAT' | |
} ; | |
window.addEventListener('message', event => { | |
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') { | |
console.log(">> Form is ready!"); | |
Object.keys( mapping).forEach(function(key) { |
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
var mapping = { | |
'last_lp_brand' : 'SEAT' | |
} ; | |
window.addEventListener('message', event => { | |
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') { | |
console.log(">> Form is ready!"); | |
Object.keys( mapping).forEach(function(key) { |
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
## color bash | |
PS1='\e[33;1m\u@\h: \e[31m\W\e[0m\$ ' | |
## Git lg | |
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
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
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
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 AddPrivacyToSubscription < ActiveRecord::Migration | |
def change | |
add_column :subscriptions, :privacy, :boolean, :default => false, :null => false | |
change_column_default(:subscriptions, :privacy, nil) | |
end | |
end |
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
function last-commit() { | |
git log --format=%H -n 1 | |
} | |
function last-file-change() { | |
git rev-list --max-parents=1 --max-count=1 --format=oneline HEAD -- $1 | cut -d " " -f 1 | |
} | |
function annotate-file() { |
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
namespace :deploy do | |
task :load_schema, :roles => :db, :only => { :primary => true } do | |
rake = fetch(:rake, "rake") | |
rails_env = fetch(:rails_env, "production") | |
migrate_env = fetch(:migrate_env, "") | |
migrate_target = fetch(:migrate_target, :latest) | |
directory = case migrate_target.to_sym | |
when :current then current_path | |
when :latest then latest_release |
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
after_fork do |server, worker| | |
log_path = Rails.root.join('log',"#{Rails.env}.#{worker.nr}.log") | |
new_logger = Logger.new(log_path) | |
new_logger.level = Logger::INFO | |
Rails.logger.flush | |
Rails.logger.close | |
Rails.logger = Rails.application.config.logger = ActiveSupport::TaggedLogging.new(new_logger) |
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 | |
startline() { | |
echo "" | |
echo "" | |
echo "---------- $1 -------------------------" | |
echo "" | |
} | |
startline "CPU" |
NewerOlder