This file contains 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
import asyncore | |
import smtpd | |
MY_ADDRESS = '[email protected]' | |
class RedirectingProxy(smtpd.PureProxy): | |
def _deliver(self, mailfrom, rcpttos, data): | |
smtpd.PureProxy._deliver(self, mailfrom, [MY_ADDRESS], data) | |
if __name__ == '__main__': |
This file contains 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
import java.net.*; | |
class Sender { | |
public static void main(String[] args) throws Throwable { | |
MulticastSocket socket = new MulticastSocket(new InetSocketAddress(InetAddress.getByName("10.42.0.3"), 9999)); | |
InetAddress groupAddress = InetAddress.getByName("239.192.0.1"); | |
socket.send(new DatagramPacket(new byte[0], 0, groupAddress, 9999)); | |
} | |
} |
This file contains 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
<?php | |
var_dump(json_encode(array(1, 2, 3))); | |
var_dump(json_encode(array(0=>1, 1=>2, 2=>3))); | |
var_dump(json_encode(array(1=>1, 2=>2, 3=>3))); | |
$a = array(1, 2, 3); | |
var_dump(json_encode($a)); | |
unset($a[1]); | |
var_dump(json_encode($a)); |
This file contains 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
#!/usr/bin/env python | |
# | |
# Looks up a Mac's friendly model name. | |
# | |
# Based on http://apple.stackexchange.com/a/98089/21050 | |
# | |
from subprocess import check_output | |
from urllib import urlopen | |
import xml.etree.ElementTree as ET |
This file contains 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
#!/usr/bin/python | |
import time | |
def new_d(): | |
return { | |
1: 2, 3: 4, 5: 6, 7: 8, 9: 10, | |
11: 12, 13: 14, 15: 16, 17: 18, 19: 20 | |
} |
This file contains 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
# In CentOS 5, mod_wsgi can be installed from EPEL | |
# <http://fedoraproject.org/wiki/EPEL>. I use mod_wsgi to run several | |
# independent WSGI services, each of which is contained in its own | |
# RPM. | |
# | |
# In addition to the LoadModule statement covering mod_wsgi itself, | |
# each service carries its own .conf file that is installed to | |
# /etc/httpd/conf.d. Because they are associated with different | |
# subsystems, they must be run under appropriate accounts. Determining | |
# how to do so took some poring over the documentation. |
This file contains 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 {'asterisk': | |
configs => false, | |
} | |
file {'/etc/asterisk': | |
require => Class['asterisk'], | |
ensure => link, | |
target => '/vagrant/etc/asterisk', | |
force => true, | |
} |
This file contains 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
megaweapon:tmp matt$ mkdir -p foo/baz | |
megaweapon:tmp matt$ cd foo | |
megaweapon:foo matt$ PATH=/tmp/foo/baz:/tmp/foo:$PATH | |
megaweapon:foo matt$ cat >bar | |
#!/bin/sh | |
echo "this isn't the bar you're looking for" | |
megaweapon:foo matt$ chmod +x bar | |
megaweapon:foo matt$ bar | |
this isn't the bar you're looking for | |
megaweapon:foo matt$ cat >baz/bar |
This file contains 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
megaweapon:foo matt$ # an encore to https://gist.github.com/zigg/7548324 | |
megaweapon:foo matt$ rm baz/bar | |
megaweapon:foo matt$ bar | |
-bash: /tmp/foo/baz/bar: No such file or directory | |
megaweapon:foo matt$ which bar | |
/tmp/foo/bar | |
megaweapon:foo matt$ hash -r | |
megaweapon:foo matt$ bar | |
this isn't the bar you're looking for |
This file contains 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
#!/usr/bin/env python | |
# | |
# Works for Python 2.4. Newer versions of Python changed xmlrpclib, a lot... | |
# | |
import httplib | |
import socket | |
import xmlrpclib |
OlderNewer