Skip to content

Instantly share code, notes, and snippets.

View soasme's full-sized avatar
🐷
Peppa PEG v1.16.0 is released!

Ju soasme

🐷
Peppa PEG v1.16.0 is released!
View GitHub Profile
@soasme
soasme / dsl_get.rb
Last active December 16, 2015 09:09
A DSL practise of restful route
# -*- coding: utf-8 -*-
#
#
def get(url, &block)
@url ||= Hash.new do |hash, key|
hash[key] = block
end
@soasme
soasme / scrawl_my_dictionary.rb
Created June 17, 2013 02:13
This script will save http://www.shanbay.com/wordlist/23/15930/ words to my local storage.
# -*- coding: utf-8 -*-
require 'nokogiri'
require 'open-uri'
require 'sqlite3'
$db = SQLite3::Database.new "words.db"
begin
rows = $db.execute <<-SQL
create table words (
@soasme
soasme / getenv
Created July 20, 2013 04:41
man 3 getenv
/tmp % cat env.c
#include <stdlib.h>
#include <stdio.h>
int
main(int argv, char **args) {
printf("%s", getenv("PATH"));
}
/tmp % llvm-gcc -o env env.c
/tmp % ./env
FFD8FF=JPEG(jpg)
89504E47=PNG(png)
47494638=GIF(gif)
49492A00=TIFF(tif)
424D=Windows\ Bitmap(bmp)
41433130=CAD(dwg)
38425053=Adobe\ Photoshop(psd)
7B5C727466=Rich\ Text\ Format(rtf)
3C3F786D6C=XML(xml)
68746D6C3E=HTML(html)
public class a {
public static void main(String[] args){
System.out.println("polygenelubricants".hashCode()); //-2147483648
}
}
unsigned int RSHash(char* str, unsigned int len)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
unsigned int i = 0;
for(i = 0; i < len; str++, i++)
{
hash = hash * a + (*str);
a = a * b;
# -*- coding: utf-8 -*-
class Resource(object):
pass
class API(object):
pass
class V1(API):
version = 1
# -*- coding: utf-8 -*-
from flask import Flask, make_response
from flask.ext.restful import Api, Resource
import json
app = Flask(__name__)
api = Api(app)
RESOURCE = {
# -*- coding: utf-8 -*-
from flask import Flask, request
from flask.ext.restful import Resource, Api
from flask.ext.restful import reqparse
app = Flask(__name__)
api = Api(app)
class Progress(Resource):
function zle-line-init zle-keymap-select {
zle reset-prompt
}
zle -N zle-keymap-select
bindkey -v
bindkey ',l' history-incremental-search-backward