Skip to content

Instantly share code, notes, and snippets.

View konung's full-sized avatar
💭
💙💛

Nick Gorbikoff konung

💭
💙💛
View GitHub Profile
@konung
konung / Rakefile
Last active August 29, 2015 14:18 — forked from robhurring/Rakefile
task :environment do
require './dj-sinatra'
end
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end
class CreateContactAttempts < ActiveRecord::Migration
def self.up
create_table :contact_attempts do |t|
t.string :first_name
t.string :last_name
t.string :email
t.string :url
t.string :company
t.text :message_body
@konung
konung / README.md
Created February 3, 2012 04:32 — forked from fnichol/README.md
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

# Update, upgrade and install development tools:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@konung
konung / gist:5923387
Last active December 19, 2015 08:09
Find most recently modified ( last modified) file or directory using Ruby's FileUtils. Extends FileUtils
module FileUtils
def sorted_by_modified_files(path='.',extension_filter = "")
Dir.open(path).entries.map do |f|
[f,File.mtime(File.join(path,f))]
end.sort_by do |a|
a[1]
end.delete_if do |a|
File.stat(File.join(path,a[0])).directory? or
a[0] == '.' or a[0] == '..' or a[0].match(/#{extension_filter}$/).nil?
end
class ApplicationController < ActionController::Base
include Trailblazer::Operation::Controller
respond_to :html, :json, :xml
#....
end
# app/concepts/layout/cell.rb
class Layout::Cell < Cell::App
def show
render
@konung
konung / ubuntu-install-ruby-1.8.7.sh
Created February 2, 2017 15:34 — forked from murphyslaw/ubuntu-install-ruby-1.8.7.sh
Install Ruby 1.8.7 with rbenv on Ubuntu
# Install system libraries.
sudo apt-get install zlib1g-dev openssl libssl-dev libreadline-dev git-core
# Install rbenv.
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Setup bash.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
@konung
konung / ree-1.8.7-2011.03
Last active February 2, 2017 16:40 — forked from fgrehm/ree-1.8.7-2011.03
ruby-build REE definitions for Ubuntu 12.04
build_package_patched() {
# These three patches are included when RVM builds REE
cd source
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/tcmalloc.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/stdout-rouge-fix.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/no_sslv2.diff'
patch -p1 < tcmalloc.patch
patch -p1 < stdout-rouge-fix.patch
patch -p1 < no_sslv2.diff
cd ..
# ## Docs setup
# ### On Github
# Fork api-docs repo on github to your account.
# Any change you make you should push to your repo first ( into a branch preferably) and then create a pull-request to trailblazer
#
# ## Locally
# Create a local folder like ~/projects/trailblazer/docs ( or whatever)
# Where you are going to keep local copies of the gems.
#
# cd into the said directory
@konung
konung / how-to-squash-commits-in-git.md
Created February 8, 2018 18:01 — forked from patik/how-to-squash-commits-in-git.md
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date: