Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Christopher Michael midwire

🏠
Working from home
Block or report user

Report or block midwire

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@midwire
midwire / git commands.md
Created Sep 10, 2018 — forked from scootcho/git commands.md
git commands #git #commands
View git commands.md

initialize git depository in the current directory

git init .

display the git remote/origin

cat .git/config
@midwire
midwire / rbenv-install-system-wide.sh
Created Jun 7, 2018 — forked from cblackburn-ajla/rbenv-install-system-wide.sh
CentOS: rbenv install and system wide install
View rbenv-install-system-wide.sh
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
View Rails Standards and Conventions.md

Rails naming conventions

General Ruby conventions

  • Class names are CamelCase.
  • Methods and variables are snake_case.
  • Methods with a ? suffix will return a boolean, and are called predicates.
  • Methods with a ! suffix mean one of two things: either the method changes the state of the object instance in some fashion, or it will raise and exception instead of failing (such as Rails models' #save! vs. #save).
  • In documentation, ::method_name denotes a class method, while #method_name denotes a instance method.
@midwire
midwire / git-merged-branches.rb
Created Oct 24, 2017 — forked from cblackburn-ajla/git-merged-branches.rb
Determine orphaned branches that have been merged into another branch.
View git-merged-branches.rb
#!/usr/bin/env ruby
#
# Get a list of merged branches
#
# You need to checkout the target remote branch before running. In other words,
# if your target branch is 'master', you have to have it checked out before you
# run this script, otherwise you will get an error like: `fatal: malformed
# object name master`. Git needs to have the branch checked out and pulled in
# order to find the branches that have/have-not been merged into it.
#
@midwire
midwire / .pryrc
Last active May 13, 2019
[My .pryrc] It's awesome! #ruby
View .pryrc
require 'irb/completion'
begin
require 'awesome_print'
Pry.config.print = proc { |output, value| output.puts value.ai }
rescue LoadError => err
puts "no awesome_print :("
end
Pry.commands.alias_command 'wh', 'whereami'
@midwire
midwire / database_state_loader.rb
Created Jul 6, 2017 — forked from keithpitt/database_state_loader.rb
Note that this code only works with PostgreSQL, but it wouldn’t be too hard to adapt our approach for other relational databases.
View database_state_loader.rb
# Add to `spec/support/database_state_loader.rb`
class DatabaseStateLoader
class EnvironmentError < RuntimeError; end
def self.load(path)
new(path).load
end
def initialize(path)
@midwire
midwire / gist:bd9aceb83cac086ac90862d30f968a37
Created Apr 12, 2017 — forked from trcarden/gist:3295935
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
View gist:bd9aceb83cac086ac90862d30f968a37
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@midwire
midwire / sierra-virtualbox-install.md
Created Mar 27, 2017 — forked from arobb/sierra-virtualbox-install.md
Install macOS Sierra in VirtualBox on macOS host
View sierra-virtualbox-install.md

https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
@midwire
midwire / secure_sierra.sh
Last active Jun 11, 2017 — forked from pwnsdx/disable.sh
Disable bunch of #$!@ in Sierra
View secure_sierra.sh
#!/bin/bash
# This is a draft but it works
# FIRST (I don't even know if it works but we'll assume yes)
# sudo launchctl list
# sudo launchctl disable system/netbiosd
# sudo launchctl disable system/parsecd
# sudo launchctl disable system/parentalcontrols.check
# sudo launchctl disable system/airportd
@midwire
midwire / ruby-gc-tuning.md
Last active Sep 1, 2016 — forked from jjb/gist:7389552
Ruby 2.1 memory configuration
View ruby-gc-tuning.md

This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted.

All the relevant code is in https://github.com/ruby/ruby/blob/trunk/gc.c

RUBY_HEAP_MIN_SLOTS

default: 10000

The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps).

(todo: figure out how big a slot is. i think the answer can be infered from this code.)

You can’t perform that action at this time.