Skip to content

Instantly share code, notes, and snippets.

@arsane
arsane / spell.c
Created July 22, 2010 04:15
spell checkers written in pyton/c
/*
* spell.c --- spell corrector
*
* Copyright (C) 2007 Marcelo Toledo <marcelo@marcelotoledo.org>
*
* Version: 1.0
* Keywords: spell corrector
* Author: Marcelo Toledo <marcelo@marcelotoledo.org>
* Maintainer: Marcelo Toledo <marcelo@marcelotoledo.org>
* URL: http://www.marcelotoledo.org
@arsane
arsane / splitpdfpage.py
Created August 9, 2010 09:13
a small script used to split each scanned pdf page into two images, and generate one pdf file.
#!/usr/bin/python
# for scanned page, this simple script
# split and dump each page into two png files.
#
# then these pages can be combined into one pdf
# file again.
#
# To merge png files into one pdf, I prefer to
# load pngs files with f-spot, and print the images
@arsane
arsane / gist:668647
Created November 9, 2010 03:28
dwm bootup
#!/bin/bash
DIR=${HOME}/.dwm
if [ -f "${DIR}"/dwmrc ]; then
/bin/sh "${DIR}"/dwmrc &
else
while true; do
xsetroot -name "`date`"
sleep 1
done &
fi
@arsane
arsane / .vimrc
Last active March 2, 2016 02:27
vim config file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Theme/Colors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" in putty client, set the configuration:
" Connection -> Data -> Terminal-type string to "xterm-color"
" set term=sun-color
syntax on
set nu
"colorscheme vibrantink
@arsane
arsane / pic32mx.cfg
Created August 24, 2012 04:05
openocd pic32mx configuration file.
debug_level 0
#log_output flash.log
# Daemon configuration
telnet_port 0
tcl_port 0
gdb_port 0
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True)
httpd.serve_forever()
@arsane
arsane / rsa.py
Created November 25, 2013 06:37
use python to do rsa calculation.
# Simple python script to check each steps of RSA calculation.
# Keys.
n = 0xAA9DE43925350CD9C0F1F98017FFD882BCFE524122212E764C6D529989B4192169B30559BDFA0F6F3037C3FDF54E18D2A36028E1940BEF14A472D50814A1089861B541491E2CA61652012FBC9E381CD744860F22EB4DD4274AF5C87EF5D05BD5040D8BA550A0FA59C1AFF7B354DF565B531B4ECF4DE731F5998F651BE25146E7
ns = 'AA9DE43925350CD9C0F1F98017FFD882BCFE524122212E764C6D529989B4192169B30559BDFA0F6F3037C3FDF54E18D2A36028E1940BEF14A472D50814A1089861B541491E2CA61652012FBC9E381CD744860F22EB4DD4274AF5C87EF5D05BD5040D8BA550A0FA59C1AFF7B354DF565B531B4ECF4DE731F5998F651BE25146E7'
e = 0xEDBE77C1
p = 0xE091BB42189DEA18CF8EE01A2407A6F0DF154C026948CBBE2857584885D60C08E1CD91FB47C35D07E337FF162201BEF10E6D9CBAE975AA086A0E6C6ABD85DE65
q = 0xC27F0DB3D6B798AD36340B56A402467476433A9034953DE611062ECEE87E2A2A46EEFA4900DE013B13191CD0FC84ABFB4CAE01AD22E6F19D4C97AB76CA02455B
@arsane
arsane / callgraph.py
Created December 3, 2013 04:14
retrieve the call graph from elf binary.
#!/usr/bin/python
# powerpc-gekko-objdump -d example.elf | python cg.py | dot -Tpng > cg.png && eog cg.png
import re, sys
f_re = re.compile('^[0-9a-f]* <([a-zA-Z0-9_]*)>:$')
c_re = re.compile('\tbl *[0-9a-f]* <([a-zA-Z0-9_]*)>')
_blacklist = set(['sys_init', 'SYS_ResetSystem', 'puts', 'getButtons',
@arsane
arsane / hgfolderdiff.py
Last active August 29, 2015 14:05
export mercurial revision changes in folders.
# This script is used to export changes between two commits
# into two folders for people don't have hg to review code.
#
# Usage:
# python hgfolderdiff.py rev1 rev2 diffs.zip
#
# export change files in two revisions into two directories,
# and then archive to zip file.
#
import os, subprocess, sys
@arsane
arsane / chinese-count.py
Created August 24, 2014 13:36
count chinese characters.
#!/usr/bin/python3
import sys
def MyCount(string):
tmpStr = ""
for c in string:
if ord(c)>=255 and (c not in ",。!¥()《》【】『』、?~·:“”‘’;"): tmpStr += c
return len(tmpStr)
if __name__=="__main__":