Skip to content

Instantly share code, notes, and snippets.

@sgricci
sgricci / luhn_validator.php
Created March 3, 2010 04:23
Luhn Validation in PHP
<?php
/*
* This function will check a number (Credit Card, IMEI, etc.) versus the luhn
* algorithm. (Both mod 10 and mod5)
*
* More information on the luhn algorigthm: http://en.wikipedia.org/wiki/Luhn_algorithm
*
* From the Wikipedia entry:
* As an illustration, if the account number is 49927398716, it will be validated as follows:
1. Double every second digit, from the rightmost: (1×2) = 2, (8×2) = 16, (3×2) = 6, (2×2) = 4, (9×2) = 18
@sgricci
sgricci / check_image_support.php
Created May 16, 2011 04:55
Check Image Support in PHP
<?php
function check_image_support()
{
echo 'Checking Image Support: '."\n";
//IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM
if (imagetypes() & IMG_GIF)
echo "GIF: \tYes";
else
echo "GIF: \tNo";
@sgricci
sgricci / configure.sh
Created November 26, 2012 17:09
Configure for PHP 5.4.7 on Mountain Lion
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \
@sgricci
sgricci / synaptics.conf
Last active January 3, 2016 14:49
Synaptics configuration for Samsung Series 7 laptop
Section "InputClass"
Identifier "np900x3b clickpad"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Option "ClickPad" "1"
Option "ClickFinger1" "1"
Option "ClickFinger2" "3"
Option "ClickFinger3" "2"
Option "PalmDetect" "1"
Option "PalmMinWidth" "5"
#!/usr/bin/env python
import pygal
import requests
import simplejson as json
from timelib import strtodatetime
import datetime
url = 'http://api.whatpulse.org/pulses.php?user=sgricci&format=json'
if __name__ == "__main__":
res = requests.get(url)