Skip to content

Instantly share code, notes, and snippets.

import urllib.request
from html.parser import HTMLParser
class DilbertParser(HTMLParser):
def handle_starttag(self, tag, attrs):
if tag == "img":
comic = False
src = None
for attr in attrs:
name, value = attr
@de-wim
de-wim / limited.dylan
Created April 21, 2016 07:34
Some limited dylan snippet code.
module: limited
define class <some-thing> (<object>)
slot foo :: <integer>, init-keyword: foo:;
end class;
define method limited-instance? (obj :: <some-thing>, limited-type :: subclass(limited(<some-thing>)))
=> (result :: <boolean>)
format-out("limited-instance?(%=, %=)\n", obj, limited-type);
force-output(*standard-output*);
@de-wim
de-wim / Promoted_tweet_blocker.user.js
Created August 25, 2015 15:25
Hide promoted tweets greasemonkeyscript
// ==UserScript==
// @name Promoted tweet blocker
// @namespace org.fixnum.tweetblock
// @include https://twitter.com/
// @version 1
// @grant none
// ==/UserScript==
var tweets = document.getElementsByClassName("tweet");
for(tweetIdx = 0; tweetIdx < tweets.length; tweetIdx++) {
@de-wim
de-wim / minimum-int.dylan
Created February 13, 2015 08:08
Minimum integer bug
module: main
define function main() => ()
format-out("In main()\n");
let val :: <integer> = floor/($minimum-integer + 1, 10);
format-out("(min+1)/10: ");
format-out(integer-to-string(val));
format-out("\n");
set tabpagemax=12
set showtabline=2
map <F1> <ESC>:tabn 1<CR>
map <F2> <ESC>:tabn 2<CR>
map <F3> <ESC>:tabn 3<CR>
map <F4> <ESC>:tabn 4<CR>
map <F5> <ESC>:tabn 5<CR>
map <F6> <ESC>:tabn 6<CR>
map <F7> <ESC>:tabn 7<CR>
@de-wim
de-wim / if_cascade.c
Created June 20, 2013 11:59
If-cascade I saw on HN. A, B and C can be bulky expressions, such as method calls or several conditions grouped together with ||. The second example has a number of advantages: (A) It offers a clearer split between conditions, so you don't have to squint your eyes and match parentheses. (B) It allows you to debug with much more ease: if somethin…
if( A && B && C )
{
...
}
//=========================//
if( A )
if( B )
if( C )
@de-wim
de-wim / ImageWallpaper.java
Created January 21, 2013 12:56
Crashes on line 31, EGL_BAD_ALLOC
private boolean initGL(SurfaceHolder surfaceHolder) {
mEgl = (EGL10) EGLContext.getEGL();
mEglDisplay = mEgl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (mEglDisplay == EGL_NO_DISPLAY) {
throw new RuntimeException("eglGetDisplay failed " +
GLUtils.getEGLErrorString(mEgl.eglGetError()));
}
int[] version = new int[2];
#!/bin/bash
ADB_DEVICE_COUNT=`adb devices | wc -l`
ADB_DEVICE_COUNT=`expr $ADB_DEVICE_COUNT - 2`
if [ $ADB_DEVICE_COUNT -gt 0 ]
then
echo rebooting into fastboot
adb reboot bootloader
fi
@de-wim
de-wim / gist:3901511
Created October 16, 2012 19:43
PS1 etc
export PATH=~/Apps/bin:~/bin:$PATH:
export PS1='$(if [[ $? == 0 ]]; then echo -e "\[\033[0;32m\]\xE2\x9C\x94"; else echo -e "\[\033[0;31m\]\xE2\x9C\x95"; fi )\[\033[0m\] $(date +%R) \[\033[1;34m\]$(date +"%g%V.%u")\[\033[0;31m\] \w\[\033[0m\]\$ '"\033]0;$WINDOWTITLE\007"
@de-wim
de-wim / gist:3038553
Created July 3, 2012 08:43
Dump memory from gdb
unsigned int ReadWord(unsigned int *address)
{
return *address;
}
int DumpMemory(char *fileName, void* address, size_t size)
{
int file;
int ret = 0;