Skip to content

Instantly share code, notes, and snippets.

View cantonic's full-sized avatar

Can Edremitoglu cantonic

  • Berlin / Germany
View GitHub Profile
@cantonic
cantonic / autocommit.sh
Created July 19, 2016 19:50 — forked from trcook/autocommit.sh
auto commit git. use fswatch to setup a file to auto-commit a git repo on file change
#!/bin/bash
# requires fswatch
fswatch -o . -e "\\.git.*"| xargs -n1 -I{} git commit -am "snapshot from autocommit_script.sh"
@cantonic
cantonic / backup.sh
Created July 18, 2016 21:02
Backup multiple dokku postgres instances and upload them to a bucket in S3
#!/bin/bash
S3KEY="CHANGE_ME"
S3SECRET="CHANGE_ME"
bucket='CHANGE_ME'
region='CHANGE_ME'
declare -a apps=("app1" "app2")
echo "Starting to backup - $(date)"
@cantonic
cantonic / bring_back_windows
Last active August 29, 2015 14:26 — forked from allfro/bring_back_windows
Bring all out of bounds Mac windows back in bounds
on run {input, parameters}
tell application "Finder"
set _bounds to get bounds of window of desktop
end tell
tell application "System Events"
set ids to (unix id of processes whose name is equal to "java")
repeat with _id in ids
tell (first process whose unix id is equal to _id)
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
#Sort the Ruby files in your project by number of has_many
ack " has_many " -c | awk -F ":" '{print $2,$1}' | grep -v "0" | sort -rn
# place the contents of this file in, e.g., spec/re_run_friendly_formatter.rb
#
# and in .rspec:
#
# --format ReRunFriendlyFormatter
require "rspec/core/formatters/progress_formatter"
class ReRunFriendlyFormatter < RSpec::Core::Formatters::ProgressFormatter
RSpec::Core::Formatters.register self, :dump_summary
#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@cantonic
cantonic / spec_helper.rb
Created November 19, 2012 05:56 — forked from parndt/gist:3506525
RefineryCMS spec_helper
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') unless defined?(ENGINE_RAILS_ROOT)
def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'