Skip to content

Instantly share code, notes, and snippets.

View rshk's full-sized avatar
😎
Being awesome

Samuele Santi rshk

😎
Being awesome
  • Tampa, Florida
View GitHub Profile
@rshk
rshk / bookmark-cck.php
Created November 7, 2012 19:09
Drupal Link Sharer
/*******************************************************************************
(C)2010 Samuele ~redShadow~ Santi - http://www.hackzine.org
Under GPL v3
*******************************************************************************/
$content['type'] = array (
'name' => 'Bookmark',
'type' => 'bookmark_link',
@rshk
rshk / svg-tiler.sh
Created November 7, 2012 19:53
SVG Tiler
#!/bin/bash
#
# SVG Image Tiler - transform SVG images into PNG tiles
# Copyright (C) 2009 Samuele ~redShadow~ Santi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@rshk
rshk / gist:4038697
Created November 8, 2012 13:06
File parsing performance comparison
$ time python parse.py
real 0m0.065s
user 0m0.060s
sys 0m0.000s
$ md5sum out*
f43b4dd719f7d0c11012061b50dd96a8 out1.txt
169344f96bf67ce3dcd585802f116c05 out2.txt
@rshk
rshk / generate_sine_table.py
Created December 19, 2012 16:54
Sine table generation using Python
#!/usr/bin/env python
## Generate sine table
import math
def rescale(X,A,B,C,D,force_float=False):
retval = ((float(X - A) / (B - A)) * (D - C)) + C
if not force_float and all(map(lambda x: type(x) == int, [X,A,B,C,D])):
return int(round(retval))
@rshk
rshk / slight_random_yield.py
Created December 19, 2012 16:56
Generating "slightly" random values in Python
#!/usr/bin/env python
from random import randint,choice
def slrgen(start=None,mindelta=0,maxdelta=5,minval=0,maxval=1000):
if start is not None:
s = int(start)
else:
s = randint(minval,maxval)
while True:
"""
Nicely format tables for CLI output
:author: Samuele Santi <[email protected]>
:created: 2012-05-09
"""
import os
import textwrap
def have_color_support():
#!/usr/bin/env python
import sys
try:
text = sys.argv[1]
except:
print "Usage: rot13 <text>"
sys.exit(1)
#!/bin/bash
##----------------------------------------------------------------------
## Keep the temperature down, for Thinkpads
##
## Useful for people that prefer the computer noisy than
## red hot.
## When a MAX temperature is reached, the fan speed is raised
## to its maximum power until the temperature drops below
## another MIN thresold.
"""
Fade IN/OUT some text..
"""
import sys
import time
import pygame
## Show some text fade in/out
"""
Fade IN/OUT some text..
"""
import sys
import time
import pygame
## Show some text fade in/out