Skip to content

Instantly share code, notes, and snippets.

@wvdschel
wvdschel / gist:2901919
Created June 9, 2012 17:43
Drawing some land
package ;
import nme.display.Bitmap;
import nme.display.BitmapData;
import nme.display.Sprite;
import nme.display.StageAlign;
import nme.display.StageScaleMode;
import nme.display.Graphics;
import nme.events.Event;
import nme.Assets;
@wvdschel
wvdschel / flush.sh
Created June 21, 2012 14:44
Cache flush implementations
root@PLF-CPU:~# ./cacheflush_mips
Cached memory writes: 90000 ticks
Uncached memory writes: 300000 ticks
Userspace flush: block=1, 1100000 ticks, 0.00% errors
Userspace flush: block=2, 530000 ticks, 0.00% errors
Userspace flush: block=4, 450000 ticks, 0.00% errors
Userspace flush: block=8, 380000 ticks, 0.00% errors
Userspace flush: block=16, 340000 ticks, 0.00% errors
Userspace flush: block=32, 310000 ticks, 0.00% errors
Userspace flush: block=64, 310000 ticks, 0.00% errors
@wvdschel
wvdschel / 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;
@wvdschel
wvdschel / 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"
#!/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
@wvdschel
wvdschel / 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];
@wvdschel
wvdschel / 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 )
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>
@wvdschel
wvdschel / 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");
@wvdschel
wvdschel / 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++) {