Skip to content

Instantly share code, notes, and snippets.

@mrkplt
mrkplt / signal_trapping_example.rb
Created December 16, 2013 19:52
A lil script for playing with signal trapping on *nix machines.
hello = 'Hello'
puts Process.pid
while true
Signal.trap('USR1'){
hello = 'HALLO!'
}
Signal.trap('USR2'){
hello = 'Hello'
}
@mrkplt
mrkplt / do-___-end.sublime-snippet
Created December 5, 2013 16:48
doe <tab> creates a do end block in Sublime Text 2. Put this file in ~/Library/Application Support/Sublime Text 2/Packages/Ruby/
<snippet>
<content><![CDATA[
do
${1}
end]]></content>
<description>do...end block</description>
<tabTrigger>doe</tabTrigger>
<scope>source.ruby</scope>
</snippet>
@mrkplt
mrkplt / ldap_auth.rb
Created July 31, 2013 22:12
Ruby script using Net::LDAP (net/ldap) to authenticate a users account name against an ldap server. This is tested against an AD domain. user@example.com is not the user_name our domain expected. Your milage may vary. Credit to a bunch of tutorials for getting this to work (whose tabs I sadly closed). This shoudl enable you with the right creden…
require 'net/ldap'
require 'io/console'
class LDAPUser
def connect(user_name, password)
ldap = Net::LDAP.new(:host => 'example.com', :port => 389)
ldap.auth("CN=#{user_name},OU=Users,DC=example,DC=com", password)
begin
@mrkplt
mrkplt / unicorn_example.sh
Created June 21, 2012 23:15 — forked from tualatrix/unicorn_example.sh
An example of unicorn init script for Ubuntu
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@mrkplt
mrkplt / gist:2715219
Created May 17, 2012 00:39
Rails App init with test framework
$ rails new <app_name> --skip-test-unit
$ cd <app_name>/
$ git init
$ git add .
$ git commit -m 'first commit'
$ git remote add origin <git repo>
$ git push -u origin master
$ mate .
/**
@mrkplt
mrkplt / com.mrkplt.sockfix.plist
Created October 19, 2011 03:51
Startup script that allows you to use the built in mysql server with Snow Leopard Server and Liip PHP (http://php-osx.liip.ch/) by symlinking the mysql.sock location to where php expects it to be. Goes in /Library/LaunchDaemons. Restart the server.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mrkplt.sockfix</string>
<key>Program</key>
<string>/bin/ln</string>
<key>ProgramArguments</key>
<array>