This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Blee | |
| def self.classmeth | |
| puts 'calling classmeth' | |
| end | |
| def instmeth | |
| puts 'calling instmeth' | |
| end | |
| end | |
| Blee.singleton_class.class_eval do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ModuleWithSelf | |
| def self.===(obj) | |
| obj === "blah" | |
| end | |
| end | |
| module ModuleNoSelf | |
| def ===(obj) | |
| obj === "blah" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| klass = Class.new | |
| # a random, anonymous class name | |
| puts klass | |
| MyName = klass | |
| OtherName = klass | |
| # now the anonymous class is named MyName | |
| puts klass | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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 |