Skip to content

Instantly share code, notes, and snippets.

@fornwall
fornwall / keybase.md
Created September 7, 2018 05:38
keybase.md

Keybase proof

I hereby claim:

  • I am fornwall on github.
  • I am fornwall (https://keybase.io/fornwall) on keybase.
  • I have a public key whose fingerprint is 2218 893D 3F67 9BEF C421 FD97 6700 B77E 6D8D 0AE7

To claim this, I am signing this object:

@fornwall
fornwall / Risk.java
Created July 12, 2011 11:02
Calculating chances in the game of Risk
import java.util.Arrays;
public class Risk {
public static void main(String[] args) {
long defenderLoosesTwo = 0;
long eachLoosesOne = 0;
long attackerLoosesTwo = 0;
int[] attackerDices = new int[3];
@fornwall
fornwall / http_top_server.py
Created December 21, 2010 18:11
A simple python http server writing out load average and number of cpu:s.
#!/usr/bin/env python
import BaseHTTPServer, os, multiprocessing
class TopHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(str(os.getloadavg()[0]) + "," + str(multiprocessing.cpu_count()))
#!/usr/bin/env python
import BaseHTTPServer, os
class TopHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
# the load may be comma-separated depending on locale, so replace comma with dot
#!/usr/bin/env python
# attach-android-source.py - script to attach android source to a SDK folder using symlinks
# See http://mobilepearls.com/labs/viewing-android-source-code-in-eclipse/
#
# Use as:
# python attach-android-src.py $PATH_TO_SRC $PATH_TO_SDK_PLATFORM
# where $PATH_TO_SRC is the path to an android source checkout (the folder you run "repo init" in if
# you follow the instructions on http://source.android.com/source/download.html) and
# $PATH_TO_SDK_PLATFORM is to a platform folder inside the android sdk folder
@fornwall
fornwall / CreatingANotification.java
Created September 16, 2010 20:29
Snippets about android notifications
int icon = R.drawable.notification_icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MyActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
@fornwall
fornwall / asset_manager.h
Last active September 15, 2018 05:48
The NDK API
struct AAssetManager;
struct AAssetDir;
struct AAsset;
/* Available modes for opening assets */
enum {
AASSET_MODE_UNKNOWN = 0,
AASSET_MODE_RANDOM = 1,
@fornwall
fornwall / .project
Created June 4, 2010 23:14
EclipseScript examples (see http://eclipsescript.org)
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eclipsescript-examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>