Skip to content

Instantly share code, notes, and snippets.

View paranlee's full-sized avatar
🐧
Run RISC-V run!

Paran Lee paranlee

🐧
Run RISC-V run!
View GitHub Profile
@prashants
prashants / lwnfs.c
Created August 28, 2012 10:07
Updated lwnfs
/*
* Demonstrate a trivial filesystem using libfs.
*
* Copyright 2002, 2003 Jonathan Corbet <[email protected]>
* This file may be redistributed under the terms of the GNU GPL.
*
* Chances are that this code will crash your system, delete your
* nethack high scores, and set your disk drives on fire. You have
* been warned.
*/
@alexliang1975
alexliang1975 / download.py
Created September 11, 2012 16:34
download source code which powered by Trac's Browse source
#!/usr/env python
import urllib2
from HTMLParser import HTMLParser
import os
def downloadFile(url, filename):
u = urllib2.urlopen(url+'?format=txt')
localFile = open(filename, 'w')
@mbostock
mbostock / .block
Last active October 9, 2024 15:14
Collapsible Tree
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-collapsible-tree
@dradtke
dradtke / dbus-daemon.c
Last active July 11, 2024 03:31
An example Linux daemon using DBus.
/*
* This is an example Linux daemon that communicates via dbus.
* When run, it will daemonize and print to standard output two lines:
*
* 1. The PID of the daemon process, which can be used to kill it later with `kill -s SIGINT <pid>'
* 2. The unique D-Bus address it will be listening to
*/
#include <signal.h>
#include <stdio.h>
@danieldk
danieldk / gist:5700533
Created June 3, 2013 19:12
Berkeley DB 4.8 patch for compilers that have __atomic_compare_exchange.
Binary files dbxml-2.5.16.orig/db-4.8.26/dbinc/.atomic.h.un~ and dbxml-2.5.16/db-4.8.26/dbinc/.atomic.h.un~ differ
diff -ruN dbxml-2.5.16.orig/db-4.8.26/dbinc/atomic.h dbxml-2.5.16/db-4.8.26/dbinc/atomic.h
--- dbxml-2.5.16.orig/db-4.8.26/dbinc/atomic.h 2013-06-03 21:04:07.000000000 +0200
+++ dbxml-2.5.16/db-4.8.26/dbinc/atomic.h 2013-06-03 21:10:53.000000000 +0200
@@ -144,7 +144,7 @@
#define atomic_inc(env, p) __atomic_inc(p)
#define atomic_dec(env, p) __atomic_dec(p)
#define atomic_compare_exchange(env, p, o, n) \
- __atomic_compare_exchange((p), (o), (n))
+ __atomic_compare_exchange_db((p), (o), (n))
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active April 1, 2025 08:06
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@keiya
keiya / http-server.c
Created July 24, 2013 10:41
[ a simple http server ] feature: directory listing, high-throughput mmap io
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* exit() */
#include <sys/types.h> /* socket(), wait4() */
#include <sys/socket.h> /* socket() */
#include <netinet/in.h> /* struct sockaddr_in */
#include <sys/resource.h> /* wait4() */
#include <sys/wait.h> /* wait4() */
#include <pthread.h> /* pthread_create */
#include <netdb.h> /* getnameinfo() */
#include <string.h> /* strlen() */
@Gnurou
Gnurou / Kexec for ARM
Created October 28, 2013 03:34
Cross-compiling Kexec for ARM, how-to.
./bootstrap
LDFLAGS=-static ./configure --host=arm-none-linux-gnueabi --without-zlib --without-lzma
make
-> static binary in build/sbin/kexec
@jvns
jvns / examples.md
Last active June 12, 2022 11:10
Rust examples

Strings

The std::str documentation is also quite good.

// Create a string from a literal
let hello: &'static str = "Hello!";
let hello2: &str = "Hello!";
@Mamahaha
Mamahaha / file1.txt
Created December 17, 2013 05:39
rest api
#!/usr/bin/env python
"""
restapi.py Learn REST API with Python script
Usage: restapi.py [options]
Options:
-e --exer <number> exercise number
-h this help
Mail bug reports and suggestion to : Larry Cai <larry.caiyu AT gmail.com>