Skip to content

Instantly share code, notes, and snippets.

View alchemycs's full-sized avatar

alchemycs

View GitHub Profile
@alchemycs
alchemycs / spotlight.css
Created June 30, 2011 02:31
Add a spotlight sheen to a background
.spotlight {
background:-webkit-gradient(radial, 250 50,0,250 50,800,
from(rgba(255,255,255,.4)),to(transparent)) transparent;
background: -moz-radial-gradient(250px 50px,
rgba(255,255,255,.4), transparent) transparent;
}
/*
Found this nice little snippet on Forrst.com at http://forrst.com/posts/Add_a_spotlight_sheen_to_your_backgrounds_with-zWQ
*/
@alchemycs
alchemycs / validate_assertion.php
Created November 24, 2011 03:16
Server side validation of browser id assertions
<?php
/**
* Server side validation of browser id assertions
*
* @author @AlchemyCS <https://github.com/alchemycs>
* @see GitHub <https://gist.github.com/alchemycs>
* @see Mozilla Browser ID <https://browserid.org>
*
*/
@alchemycs
alchemycs / destination_list.txt
Created February 6, 2012 00:17
CLI to copy a template file to multiple stub files in a list
destfile1.md.sample
destfile2.md.sample
destfile3.md.sample
@alchemycs
alchemycs / referrer.conf
Created February 15, 2012 00:03
Apache config for restricting images based on referrer
# This stops others from using simple links to your media on their site. See comments at end of GIST for limitations
# Prevents sites you don't own placing simple embeds on those sites. eg <img src="http://example.com/images/sample-image.png"/>
RewriteCond %{REQUEST_URI} ^/images/.*
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC]
RewriteRule .* - [F]
# Your bandwidth is precious and others shouldn't poach your bandwidth.
# - If someone wants to use media you have on the internet they can get it one way or another
# - Does not protect against spoofed headers
# - Doesn't stop people from right-click > download image/file (etc)
@alchemycs
alchemycs / dateextension.js
Created April 17, 2012 13:28
A dead easy way to get unix style timestamp from any javascript Date object
/*
Extends the Date object to get number of seconds since UNIX epoch
instead of milliseconds as with .getTime()
*/
Date.prototype.getTimestamp = function() {
return Math.round(this.getTime()/1000);
}
@alchemycs
alchemycs / uuid-v4.js
Created April 26, 2012 23:22
Generate RFC 4122 Version 4 Compliant UUID
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
@alchemycs
alchemycs / ls2csv.sh
Created May 10, 2012 04:18
List files in a directory terminated by comma (,) and enclosed by quotes (")
# Useful if you need a list of files in CSV or for pasting into a dictionary
ls |sed 's/\(.*\)/"\1",/'
@alchemycs
alchemycs / create-drop-database-sql.sh
Created September 16, 2012 11:22
Create an SQL file that will drop all non-system databases
# Create an SQL file that will drop all non-system databases
mysql -u root -p -e "show databases" | grep -v Database | grep -v mysql| grep -v information_schema| grep -v test | grep -v OLD |gawk '{print "drop database " $1 ";select sleep(0.1);"}' > drop_all_databases.sql
@alchemycs
alchemycs / gist:4222258
Created December 6, 2012 06:42
Additions to boards.txt to use the Freetronics Leostick effectively with the Arduino IDE
##############################################################
leostick12.name=Freetronics LeoStick V1.2
leostick12.upload.protocol=arduino
leostick12.upload.maximum_size=28672
leostick12.upload.speed=1200
leostick12.bootloader.low_fuses=0xde
leostick12.bootloader.high_fuses=0xd8
leostick12.bootloader.extended_fuses=0xcb
leostick12.bootloader.path=diskloader
leostick12.bootloader.file=DiskLoader-LeoStick.hex
@alchemycs
alchemycs / arduino.mk
Created December 6, 2012 07:12
Makefile for CLI compilation on arduino code modified for default ArduinoIDE install on a Mac. Make sure you set BOARD as appropriate.
#_______________________________________________________________________________
#
# edam's Arduino makefile
#_______________________________________________________________________________
# version 0.4
#
# Copyright (C) 2011, 2012 Tim Marston <[email protected]>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal