Skip to content

Instantly share code, notes, and snippets.

View st3fan's full-sized avatar

Stefan Arentz st3fan

View GitHub Profile
uint32_t* p = NULL;
int err = posix_memalign((void**) &p, PAGE_SIZE, PAGE_SIZE);
if (err == 0 && p != NULL)
{
// Inject code
p[0] = 0xe2800001;
p[1] = 0xe12fff1e;
err = mprotect(p, PAGE_SIZE, PROT_READ | PROT_EXEC);
if (err == 0)
@st3fan
st3fan / gist:3024317
Created June 30, 2012 15:51
PIC32 Reading a TI TMP102
#include <p32xxxx.h>
#include <plib.h>
#pragma config FNOSC = FRCPLL // Internal Fast RC oscillator (8 MHz) w/ PLL
#pragma config FPLLIDIV = DIV_2 // Divide FRC before PLL (now 4 MHz)
#pragma config FPLLMUL = MUL_20 // PLL Multiply (now 80 MHz)
#pragma config FPLLODIV = DIV_2 // Divide After PLL (now 40 MHz)
#pragma config FWDTEN = OFF // Watchdog Timer Disabled
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
#pragma config JTAGEN = OFF // Disable JTAG
#include <p32xxxx.h>
#include <plib.h>
#pragma config FNOSC = FRCPLL // Internal Fast RC oscillator (8 MHz) w/ PLL
#pragma config FPLLIDIV = DIV_2 // Divide FRC before PLL (now 4 MHz)
#pragma config FPLLMUL = MUL_20 // PLL Multiply (now 80 MHz)
#pragma config FPLLODIV = DIV_2 // Divide After PLL (now 40 MHz)
#pragma config FWDTEN = OFF // Watchdog Timer Disabled
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <curl/curl.h>
static const char* BING_URL = "https://api.datamarket.azure.com/Bing/Search/Composite?%24top=8&Sources=%27web%2Bimage%2BRelatedSearch%27&%24format=json&Adult=%27Strict%27&Query=%27cheese%27&Options=%27EnableHighlighting%27&Market=%27en-US%27";
static const char* BING_KEY = "";
struct Timer {
@st3fan
st3fan / gist:3230488
Created August 1, 2012 20:34
Grab items from Hacker News
#!/usr/bin/python2.7
import urllib
import MySQLdb as mysql
from bs4 import BeautifulSoup
# <td class="title">
# <a href="http://evilbrainjono.net/blog?showcomments=true&amp;permalink=1094" rel="nofollow">
# Everybody Hates Firefox Updates
mysql> select title from items where title like '%mozilla%';
+---------------------------------------------------------------------------------+
| title |
+---------------------------------------------------------------------------------+
| Mozilla Halts Developing Thunderbird |
| The State of Servo; a Mozilla experiment in browser design, implemented in Rust |
| Mozilla Firefox OS: 10 things you need to know |
| Mozilla shoots down Thunderbird, hatches new release model |
| Mozilla giving Thunderbird the (effective) axe |
| Not Getting It - Mozilla’s struggle between private and public |
<html>
<head>
<title></title>
</head>
<body>
<div id="heap_allign"></div>
<div id="table_div"></div>
<div></div>
#!/usr/bin/env python
from twisted.internet import reactor
from twisted.internet.protocol import Protocol
from twisted.internet.defer import Deferred
from twisted.web.client import Agent
from twisted.web.http_headers import Headers
from twisted.web.iweb import IBodyProducer
class BodyProtocol(Protocol):
% strings - ActiveGS_Karateka | grep Olivier | sort
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common.iphone/
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common.osx/
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common.osx/../Common/../kegs/src/StdString.h
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common.osx/../Common/CEmulatorCtrl.h
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common/
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common/../kegs/Src/StdString.h
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common/../kegs/src/StdString.h
/Users/Olivier/Code/ActiveGS/ActiveGS_Karateka/../Common/3rdpartylib/
@st3fan
st3fan / fruit.clj
Last active December 18, 2015 00:09
(def dataset [{:weight 303, :color 3, :type "banana"},
{:weight 370, :color 1, :type "apple"},
{:weight 298, :color 3, :type "banana"},
{:weight 277, :color 3, :type "banana"},
{:weight 377, :color 4, :type "apple"},
{:weight 299, :color 3, :type "banana"},
{:weight 382, :color 1, :type "apple"},
{:weight 374, :color 4, :type "apple"},
{:weight 303, :color 4, :type "banana"},
{:weight 309, :color 3, :type "banana"},