Skip to content

Instantly share code, notes, and snippets.

@eegrok
eegrok / classjunk.rb
Created January 16, 2012 23:10
singleton class / instance_methods stuff
class Blee
def self.classmeth
puts 'calling classmeth'
end
def instmeth
puts 'calling instmeth'
end
end
Blee.singleton_class.class_eval do
@eegrok
eegrok / threeequals.rb
Created January 16, 2012 23:10
threequals is called at the class level
module ModuleWithSelf
def self.===(obj)
obj === "blah"
end
end
module ModuleNoSelf
def ===(obj)
obj === "blah"
end
@eegrok
eegrok / named_class.rb
Created January 16, 2012 23:08
funny ruby named class weirdness
klass = Class.new
# a random, anonymous class name
puts klass
MyName = klass
OtherName = klass
# now the anonymous class is named MyName
puts klass
@eegrok
eegrok / osx-lion-samba-server-announce.txt
Created January 1, 2012 03:22
set up auto-announce of samba server on osx lion (since finder / pathfinder don't see samba servers by default atm)
from: http://macw.us/sek9nV
(for more information on creating launch daemons / agents, go to http://j.mp/uYtpsJ )
create a file in ~/Library/LaunchAgents
named something like:
com.yourdomain.smb_server.domain_announce.plist
<?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">
@eegrok
eegrok / php-apache-lion
Created December 8, 2011 22:06
set up php / apache on osx lion
#create file containing something like below -- in /etc/apache2/sites/localweb.conf
# (you may need to create the /etc/apache2/sites directory)
<VirtualHost 127.0.0.1:80>
ServerName www.localweb.com
ServerAlias *.localweb.com
DocumentRoot "/Users/kem/src/localweb"
<Directory "/Users/kem/src/localweb">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
@eegrok
eegrok / linux-bash-tips.txt
Created November 22, 2011 23:24
uncommon linux / bash commands worth using
you can pipe stuff through ssh -- e.g., concatenate your SSH key on another host.
cat ~/.ssh/id_dsa.pub | ssh me@remotebox "cat >> ~/.ssh/authorized_keys"
lsof - http://danielmiessler.com/study/lsof/
disown (detach from process so when close your terminal it doesn't get killed -- like doing nohup in advance)
xargs / parallel
sudo !! -- repeat last command with sudo prepended
!$ -- last argument to last command
!* -- all arguments to last command
@eegrok
eegrok / initial-git-config.txt
Created September 16, 2011 22:15
Initial git configuration stuff
git config --global user.name “My Name” (put in your name)
git config --global user.email “email@domain.com” (put in your email address)
git config --global branch.autosetuprebase always
git config --global core.excludesfile ~/.gitignore
@eegrok
eegrok / keyremap4macbook-fix.xml
Created August 15, 2011 21:12
KeyRemap4Macbook custom file to make broken keyboard usable again
<?xml version="1.0"?>
<root>
<item>
<name>Kems custom keybindings</name>
<list>
<item>
<name>Fix broken keyboard</name>
<list>
<item>
<name>Remap broken keys</name>
@eegrok
eegrok / no-ssh-password-mac.txt
Created June 23, 2011 21:48
disable password ssh authentication on mac os
make sure the following lines are set in /etc/sshd_config (or /etc/ssh/sshd_config on ubuntu)
(they all exist already, but are commented, some may have a value of yes)
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
then restart the ssh server (uncheck / recheck 'Remote Login' in the 'System Preferences' -> 'Sharing' panel)
@eegrok
eegrok / jconsole-vpn.txt
Created June 14, 2011 21:27
setup jconsole to work through firewall, or over vpn or tunneled ssh
//this method should mostly set up a java app to act as a jconsole server, with static ports so you can configure forwarding through a firewall or over a vpn
public static void setupJConsole(MBeanServer mbs, String hostname, Integer port1, Integer port2) {
// from http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdfvv
// note you need to set the following startup parameters:
// -Dcom.sun.management.jmxremote.authenticate=true
// -Dcom.sun.management.jmxremote.ssl=false
// and this one, if you don't want the rmi server to tell people to connect to the default ip (as is the case if using a vpn ip)
// -Djava.rmi.server.hostname=vpnhostip
// Ensure cryptographically strong random number generator used
// to choose the object number - see java.rmi.server.ObjID