Skip to content

Instantly share code, notes, and snippets.

Luke Brooks LukeB42

Block or report user

Report or block LukeB42

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@LukeB42
LukeB42 / simpleapi.py
Last active May 12, 2016
A scaffold for rapidly developing a REST API.
View simpleapi.py
#!/usr/bin/env python3
# Implements a scaffold for rapidly developing a REST API.
import os
import sys
import pwd
import time
import optparse
from gevent.wsgi import WSGIServer
from flask import Flask
from flask.ext import restful
View simplepython.c
// gcc -c $(python2.7-config --cflags) simplepython.c
// gcc simplepython.o $(/usr/bin/python2.7-config --ldflags) -o simplepython
#include <Python.h>
int main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
@LukeB42
LukeB42 / clock_threaded.go
Last active Jan 24, 2016
A simple time server for demonstrating a mix of pthreads and goroutines
View clock_threaded.go
package main
import (
pthread "github.com/lukeb42/go-pthreads"
"fmt"
"io"
"log"
"net"
"time"
)
View .screenrc
startup_message off
autodetach on
hardstatus alwayslastline
#hardstatus string "%{= kw} %l %{.kK} %-= @%H - %LD %d %LM - %c "
hardstatus string "%{= kw} %l %{.kK}%-w%{.KW}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c "
#hardstatus alwaysignore
vbell off
#term screen-256color
caption splitonly "%{.kK}%-w%{.KW}%n %t%{-}%+w"
View emrange.py
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
#
# Usage: emrange int:start int:stop
# Examples: emrange ; Display the total number of articles
# emrange -5 ; Display the last five articles
# emrange 0 5 ; Display the first five articles
#
import sys
from emissary.models import Article
View markovnews
#!/usr/bin/env python
# Use PyMarkovChain to generate markov chains from news articles.
import sys, os
from emissary.models import Article
from pymarkovchain import MarkovChain
mc = MarkovChain(os.getenv('HOME') + os.sep + '.markovdb')
if __name__ == "__main__":
if len(sys.argv) < 3:
View rss
#!/bin/bash
#Print resident set size of a process
ps aux|grep $*|grep -v grep|grep -v bash|awk '{$6=$6/1024; print $6 "MB\t" $11 "\t" $1;}'|sort -n
@LukeB42
LukeB42 / aread.py
Last active Aug 29, 2015
Extract the text of an article and read it in the system pager
View aread.py
#!/usr/bin/env python
import sys
from goose import Goose
import requests
from subprocess import Popen, PIPE
import errno
requests.packages.urllib3.disable_warnings()
def fetch(url):
h={"User-Agent":"aread 0.01"}
@LukeB42
LukeB42 / repo.py
Created Jan 11, 2015
Search github on the command line with the github3 package
View repo.py
#!/usr/bin/env python
import sys, github3
def search_github(terms):
data = []
results = github3.api.search_repositories(' '.join(terms))
for i in results:
j = i.to_json()
item={}
item['url'] = j['git_url'].encode('ascii','ignore')
You can’t perform that action at this time.