Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vayn's full-sized avatar

Vayne Tsai vayn

View GitHub Profile
/* Smoke system for pipe --------------------------------------------------------*/
var NUM_PARTICLES = 100
var EMITTER_X = 155
var EMITTER_Y = 120
var MIN_SIZE = 0.1
var MAX_SIZE = 0.3
var MIN_VELOCITY_Y = 0.2
var MAX_VELOCITY_Y = 0.8
var VELOCITY_X = 0
function textToHTML(text) {
return ((text || "") + "") // make sure it's a string;
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/\t/g, " ")
.replace(/ /g, "&#8203;&nbsp;&#8203;")
.replace(/\r\n|\r|\n/g, "<br />");
}
######################################
# Format Options
######################################
# The date_format variable followed by a space, specifies
# the log format date containing any combination of regular
# characters and special format specifiers. They all begin with a
# percentage (%) sign. See `man strftime`
#
#Any Apache log date format
from sys import stdout
from time import sleep
for i in range(1,20):
stdout.write("\r%d" % i)
stdout.flush()
sleep(1)
stdout.write("\n") # move the cursor to the next line
import sys
import subprocess
from time import sleep
cmd = ['top', '-l 0']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
@vayn
vayn / flask_static_files_cache_invalidator.py
Last active August 30, 2015 07:03 — forked from iximiuz/flask_static_files_cache_invalidator.py
Flask: add static file's cache invalidator param to URLs generated by url_for(). Blueprints aware.
""" Inspired by http://flask.pocoo.org/snippets/40/ """
app = Flask(__name__)
@app.url_defaults
def hashed_url_for_static_file(endpoint, values):
if 'static' == endpoint or endpoint.endswith('.static'):
filename = values.get('filename')
if filename:
if '.' in endpoint: # has higher priority
@vayn
vayn / prime_number_2.php
Created May 22, 2010 08:33
Prime_Number_2
<?php
$sum = 2;
for ($i = 3; $i < 10000; $i+=2) {
$flag = TRUE;
for ($j = 2; $j <= sqrt($i); $j++) {
if ($i % $j == 0) {
$flag = FALSE;
@vayn
vayn / prime_number.php
Created May 22, 2010 05:55
Prime Number
<?php
$sum = 2;
for ($i = 3; $i <= 10000; $i++) {
$k = 1;
for ($j = 2; $j < $i; $j++) {
if ($i % $j == 0) {
$k = 0;
@vayn
vayn / array_filter.php
Created May 22, 2010 14:40
array_filter
<?php
function odd($var) {
return($var & 1);
}
function even($var) {
return(!($var & 1));
}
@vayn
vayn / oldschool.css
Created May 22, 2010 12:50
oldschool css
/* Design done by Arthur Steiner (c), the rest by Anne van Kesteren (c) */
@font-face { font-family:anneisawesome; src:url(/fonts/big-noodle-titling) }
html { margin:20px 30px; font:1em/1.5 Verdana, sans-serif; background:#46016a }
body { position:relative; margin:0 0 0 160px; padding:0 1em; border-left:10px solid #7e7a4c; min-width:200px; background:#c2c152 }
h1 { position:absolute; top:5px; left:-155px; margin:0; height:107px; width:282px; z-index:1; content:url(/img/logo) "Weblog 4.2"; font:2.6em/0.4 anneisawesome, Impact, sans-serif; text-indent:-4px }
p#tagline { margin:0; padding-top:5em; font-size:1.2em }
form#search { position:absolute; top:10px; right:20px; z-index:1 }
form#search input[type=search] { border:thin solid #000; vertical-align:top }
form#search input[type=search]:focus { outline:thick solid #000 }
form#search input[type=submit] { margin:2px 0 0; padding:0; border:none; float:right; display:block; content:url(/img/find); width:30px; cursor:pointer }