Skip to content

Instantly share code, notes, and snippets.

View Seanny123's full-sized avatar
💭
>.<

Sean Aubin Seanny123

💭
>.<
View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@johnfredcee
johnfredcee / bvh_read.py
Created March 9, 2012 16:57
bvh file parser (tested w Python2.6)
import re
bvh_file = "Example1.bvh"
def identifier(scanner, token): return "IDENT", token
def operator(scanner, token): return "OPERATOR", token
def digit(scanner, token): return "DIGIT", token
def open_brace(scanner, token): return "OPEN_BRACE", token
def close_brace(scanner, token): return "CLOSE_BRACE", token
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jednano
jednano / gitcom.md
Last active May 31, 2023 08:23
Common git commands in a day-to-day workflow

Git Cheat Sheet

Initial Setup

Create an empty git repo or reinitialize an existing one

git init
@renaud
renaud / tornado_continuous_reload.py
Created April 10, 2014 08:35
Example of Tornado that autoreloads/watches all files in folder 'static'
'''
Example of Tornado that autoreloads/watches all files in folder 'static'
'''
import tornado.ioloop
import tornado.web
import tornado.autoreload
import os
''' serves index.html'''
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% University Assignment Title Page
% LaTeX Template
% Version 1.0 (27/12/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% WikiBooks (http://en.wikibooks.org/wiki/LaTeX/Title_Creation)
@seanjensengrey
seanjensengrey / rust-python-cffi.md
Last active April 3, 2024 11:55
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
@gabrieleangeletti
gabrieleangeletti / rbm_after_refactor.py
Last active July 27, 2021 14:32
Restricted Boltzmann Machine implementation in TensorFlow, before and after code refactoring. Blog post: http://blackecho.github.io/blog/programming/2016/02/21/refactoring-rbm-tensor-flow-implementation.html
import tensorflow as tf
import numpy as np
import os
import zconfig
import utils
class RBM(object):
from keras.layers import Input, Dense, Lambda
from keras.models import Model
def eucl_dist(inputs):
x, y = inputs
return ((x - y)**2).sum(axis=-1)
x = Input((32,))
y1 = Dense(8)(x)
y2 = Dense(8)(x)