Skip to content

Instantly share code, notes, and snippets.

@the-dan
the-dan / GistImportExample.ipynb
Last active August 20, 2020 16:23
Handy tools for Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@the-dan
the-dan / etree-eval.py
Created August 15, 2015 11:19
Tinkering with ElementTree encoding detection
# -*- coding: utf-8 -*-
from xml.etree import ElementTree as ET
import itertools
import StringIO
import traceback
XML=r"""<?xml version='1.0' encoding='%s'?><response><msg>АБВГДЕЖЗСКЛМНОПРСТУФХЦЧШЩЫЪЭЬЮЯ</msg></response>"""
# XXX: for some unknown reason Ё isn't supported
@the-dan
the-dan / update-alternatives.sh
Created July 29, 2013 18:41
Add Sun/Oracle java as an alternative
#!/bin/bash
# something in PATH env to lookup name in
LINK_PATH=/usr/bin
# where jdk is install to?
JDK_INSTALL_PATH=/opt/jdk1.7.0_21/bin
# alternative prefix
ALTER_PREFIX=oracle
@the-dan
the-dan / JavaURLConnection.java
Created September 9, 2012 18:52
Experimenting with URLConnection (keepalive, SSL)
import static org.junit.Assert.assertFalse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
@the-dan
the-dan / killed_fd.sh
Created November 17, 2011 18:54
Find processes holding deleted file descriptors
P=`sudo lsof | grep '(deleted)' | awk '{ print $2 }'`
for x in $P; do
cat /proc/$x/cmdline;
echo "";
done;
@the-dan
the-dan / MicroTLSTest.java
Created September 2, 2011 10:55
Validating SSL certificate using only BouncyCastle classes. Usefull for mobile phone under j2me
/**
*
* Why we shouldn't try to use just assymetric algorithm http://stackoverflow.com/questions/118463/what-is-the-performance-difference-of-pki-to-symmetric-encryption
*
*
* Bouncy Castle TlsProtocolHandler doesn't support session reuse. Check with:
*
* http://royontechnology.blogspot.com/2008/01/how-to-find-out-if-server-supports-ssl.html
*
**/
@the-dan
the-dan / Dump JS object
Created June 9, 2010 09:32
Dump JS object
function dump(o) {
var r = "[";
for (var p in o) {
r += p + " = " + o[p] + ", ";
}
r += "]";
alert(r);
}