Skip to content

Instantly share code, notes, and snippets.

View norpol's full-sized avatar

Phileas Lebada norpol

View GitHub Profile
@snim2
snim2 / camerastream.py
Created December 13, 2009 00:00
Display the output of a webcam using Python and Pygame
import pygame
import pygame.camera
from pygame.locals import *
DEVICE = '/dev/video0'
SIZE = (640, 480)
FILENAME = 'capture.png'
def camstream():
pygame.init()
@dbb
dbb / fancy_urxvt
Created January 18, 2011 23:07
urxvt with transparency, blur, Xft font, etc
urxvt.perl-ext-common: default,tabbed,matcher,searchable-scrollback
urxvt*cutchars: "()*,<>[]{}|'
urxvt*termName: rxvt-unicode
urxvt*urlLauncher: iceweasel
urxvt*matcher.button: 1
urxvt*keysym.S-Prior: ^[[5;2~
urxvt*keysym.S-Next: ^[[6;2~
urxvt*geometry: 100x30
urxvt*highlightSelection: true
@alexbowe
alexbowe / streams.py
Created April 23, 2011 19:03
Lazy functional style streams for Python
null_stream = (None, None)
def map(f, stream):
if stream is null_stream: return null_stream
return (f(head(stream)), lambda: map(f, tail(stream)))
def reduce(f, result, stream):
if stream is null_stream: return result
return reduce(f, f(result, head(stream)), tail(stream))
@ei-grad
ei-grad / .Xdefaults
Created August 14, 2012 01:47
My urxvt config.
!! Appearance
urxvt.termName: rxvt-unicode
urxvt.scrollBar: false
urxvt.background: black
urxvt.foreground: gray
!! Font prefferenes
urxvt.font: xft:DejaVu Sans Mono:pixelsize=13
urxvt.boldFont: xft:DejaVu Sans Mono:pixelsize=13:weight=bold
urxvt.letterSpace: -1
!! Larger history limit
@nikolaplejic
nikolaplejic / gist:3654637
Created September 6, 2012 10:36
How to copy/paste your password in PayPal's change password form
PayPal blocks copy/paste actions in their "change password" form,
citing some irrelevant security issues as the reason. That's a
load of crap, and they know it -- disabling copy/paste makes it a
lot harder to use a decent password generator and a lot easier to
screw up your pwd when retyping, especially if it's a long one
(as it should be!).
So, here's the quick'n'dirty way to use an externally generated
password in your PayPal account:
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@pbyrne
pbyrne / ruby-1.9.3.markdown
Last active March 16, 2020 22:39
Comparison of our core Rails app using Webrick, Puma, and Unicorn. Almost no effort was made to optimize either application server. Tests were performed on a MacBook Air using `siege` to hit the application homepage.

TL;DR

Unicorn was by far the best performing (5.94 trans/sec over the 1-minute test, 352 total). Puma (3.95 trans/sec, 235 total) appeared to perform no better than Webrick, despite the default behavior of using up to 16 threads. Perhaps increasing its worker count to the number of cores will improve its performance.

I've tried to run multiple Puma workers with the workers directive (per their sample documentaiton), but I receive errors about undefined method 'workers' for #<Puma::Configuration::DSL:0x007ffca4bde798>).

Webrick

Server

$ bundle exec rails server

@omadjoudj
omadjoudj / sandboxed-firefox
Created August 8, 2013 04:14
Configure and run firefox inside SELinux sandbox with the previous profile
sudo yum install policycoreutils-sandbox
sudo semodule -e sandbox
sandbox -t sandbox_web_t -X -i ~/.mozilla/ -i ~/.gtkrc-2.0 firefox
@hadess
hadess / tmp.c
Created October 5, 2013 23:19
Hack to control the keyboard backlight level on a Thinkpad Lenovo X1 Carbon Touch
/* gcc -o tmp `pkg-config --libs --cflags glib-2.0` tmp.c
*
* # modprobe ec_sys
*
* # watch -n 0.1 hexdump -C /sys/kernel/debug/ec/ec0/io
*
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 03 00 10 |..........G.....|
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 43 00 10 |..........G..C..|
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 83 00 10 |..........G.....|
@jeremija
jeremija / thinklight-led.sh
Last active December 26, 2015 08:09
Scripts for blinking of the power LED on a Thinkpad X230. You can use the `thinklight-led.sh "0 blink"` in any application which can execute a command on an event.
#!/bin/sh
#
# Place this file in /usr/local/bin folder.
# You might want to edit the /etc/sudoers file and add a line like this:
# $user ALL=NOPASSWD: /usr/local/bin/thinklight-led.sh
#
# Replace the $user variable with your username.
#
# author: www.github.com/jeremija