Skip to content

Instantly share code, notes, and snippets.

@ryanobjc
ryanobjc / shr-table.el
Created March 23, 2019 03:14
example of parsing shr tables
(defun shr-table-to-list (str)
"Turns a chunk of text with 'shr-indentation properties (from the
simple html renderer of tables) into a list of the table data cells"
(let ((pos 0)
(nextpos 0)
(results '())
(strlen (length str)))
(while (and nextpos (< pos strlen))
(setq nextpos (next-single-property-change (1+ pos) 'shr-indentation str))
(if nextpos
@ryanobjc
ryanobjc / docker session
Created September 30, 2014 23:06
docker crash when denied network connection via boot2docker and little snitch (OS X)
$ docker pull centos:centos7
Pulling repository centos
a5fd0258f31c: Pulling fs layer
511136ea3c5a: Download complete
0b2c58b208cf: Download complete
2014/09/30 16:03:13 unexpected EOF
The code snippet:
Bootstrap b2 = new Bootstrap();
b2.group(childGroup)
.option(ChannelOption.TCP_NODELAY, true)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("stringEncoder", new StringEncoder(BufType.BYTE, CharsetUtil.UTF_8));
@ryanobjc
ryanobjc / gist:4008937
Created November 3, 2012 21:37
C vs C++/Java
With languages like Java, or especially C++,” Bornstein says, “abstractions can be convenient, but there
are a lot of implicit operations that happen, such as when copy constructors are invoked, or destructors
or assignment operators, or if you have any sort of operator overloading. Those implicit sort of function
calls, unless you’re an absolute expert in the code base and know exactly how everything was designed,
can actually create real problems when reasoning about a piece of code.
http://dl.acm.org/citation.cfm?doid=2366316.2366321
@ryanobjc
ryanobjc / postinst.sh
Created September 6, 2012 23:16
postinst
#!/bin/sh
if [ -x `which update-rc.d` ] ; then
update-rc.d carbon-cache defaults
else
chkconfig --add carbon-cache
fi
rm /etc/apache2/sites-enables/000-default
ln -sf /opt/graphite/examples/example-graphite-vhost.conf /etc/apache2/sites-enabled/graphite-vhost.conf
@ryanobjc
ryanobjc / pkg-graphite.sh
Created September 6, 2012 21:05
package up graphite using fpm
#!/bin/bash
VER=0.9.10
HERE=`pwd`
apt-get install python-setuptools python-django-tagging python-pysqlite2 python-memcache python-ldap python-django python-cairo-dev
wget https://launchpad.net/graphite/0.9/${VER}/+download/graphite-web-${VER}.tar.gz
wget https://launchpad.net/graphite/0.9/${VER}/+download/carbon-${VER}.tar.gz
#!/bin/sh
VERS=$1
cat > java-remove.sh <<EOF
#!/bin/sh
set -e
for i in java javac jps jstack jmap ; do
update-alternatives --remove \$i /usr/lib/jvm/$VERS/bin/\$i
#!/bin/sh
VERS=$1
cat > java-post.sh <<EOF
#!/bin/sh
set -e
for i in java javac jps jstack jmap ; do
update-alternatives --install /usr/bin/\$i \$i /usr/lib/jvm/$VERS/bin/\$i 1
#!/bin/bash
JAVAPATH=$1
BN=`basename $JAVAPATH`
if [ ${BN:0:3} != 'jdk' ] ; then
echo "Error, path $JAVAPATH doesnt seem to be a JDK path, which normally starts with 'jdk'"
exit 1
fi
#!/bin/sh
HOSTS="a b c d e"
echo `hostname`
for i in $HOSTS ; do
host $i
done