Skip to content

Instantly share code, notes, and snippets.

View alkalinecoffee's full-sized avatar

Joe Martin alkalinecoffee

  • Comcast
  • Philadelphia, PA
View GitHub Profile
@alkalinecoffee
alkalinecoffee / apache_unicorn_whitelist.apacheconf
Last active December 20, 2015 23:39
Apache vhost config for Unicorn with whitelisted IPs
<VirtualHost *:80>
ServerName localhost
# ServerAlias www.localhost.com
DocumentRoot /var/www/myrailsapp/current/public
RewriteEngine On
# Redirect all non-static requests to unicorn
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
@alkalinecoffee
alkalinecoffee / ffi_hba_dll.rb
Last active December 20, 2015 23:39
Using FFI to read from fibre channel HBA dll on a Windows box
require 'ffi'
class Fixnum
def hex(numchars=16)
self.to_s(numchars).upcase
end
end
module FFI
class Struct
@alkalinecoffee
alkalinecoffee / rails_unicorn_initd.sh
Last active December 21, 2015 00:39
An init.d startup script for a Rails app running Unicorn. This setup uses a system-wide Ruby installation and deployments are handled by Capistrano.
#!/bin/bash
# chkconfig: 2345 90 10
# description: init.d script for starting a Rails app running Unicorn.
set -e
USER=rails_deployer
APP_NAME=rails_test
APP_ROOT=/var/www/$APP_NAME
@alkalinecoffee
alkalinecoffee / clean_strings_extension.rb
Created January 24, 2014 22:17
Rails: Clean (strip) all String attributes before saving
# lib/core_ext/active_record_extensions.rb
module ActiveRecordExtensions
extend ActiveSupport::Concern
def clean_strings!
self.attributes.select{|key, val| val.class == String}.each {|key, val| val.strip!}
end
included do
@alkalinecoffee
alkalinecoffee / gist:9081031
Last active September 30, 2016 15:50
Simple Web Requests in PowerShell
# Ignore any SSL certificate errors
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
(New-Object System.Net.WebClient).DownloadFile("http://example.com/myfile.txt", "C:\myfile.txt")
@alkalinecoffee
alkalinecoffee / gist:5f36973ba83c8860168d
Last active December 27, 2016 18:43
sublimetext config
{
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"copy_with_empty_selection": false,
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns": [".svn", ".hg", "CVS"],
"ignored_packages":
[
"Vintage"
],
@alkalinecoffee
alkalinecoffee / gist:6b14706dded2b2f9833e
Last active November 23, 2016 19:19
applescript to toggle visiblity status of system/hidden files (sierra 10.12)
# for Sierra
try
set setting to (do shell script "defaults read com.apple.Finder AppleShowAllFiles")
on error line number num
set setting to 0
end try
if setting is equal to "0" then
set setting to 1
@alkalinecoffee
alkalinecoffee / .bash_profile
Last active November 23, 2016 19:30
dotfiles
# this file is loaded on every session
######################### ALIASES #############################
alias be="bundle exec"
alias bi="bundle install"
alias bu="bundle update"
alias g="bundle exec guard"
alias r="bundle exec rake"
alias rs="bundle exec rails s"
alias rc="bundle exec rails c"
@alkalinecoffee
alkalinecoffee / gist:ffa2c69ef79c1f9f1928
Created March 13, 2015 15:40
(Ruby/Rails) Phone screen/Interview questions
BACKGROUND/PERSONALITY
- Tell me about yourself
- Tell me about what your current project
- What are your responsibilities?
- Describe your workflow (how are requirements/issues submitted and handled?)
- Describe the infrastructure for your current project
- Why were these technologies chosen?
- What is the biggest challenge about your current project?
- Were you able to overcome it? If so, how?
- How many people are on the team?
//bool DEBUG = true;
bool DEBUG = false;
int chans[] = {9, 10, 11, 12};
int relays[] = {5, 6, 7, 8};
int relay;
int chan;
int chan_status;