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 / 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 / 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 / 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 / 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 / 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