Skip to content

Instantly share code, notes, and snippets.

View alchemycs's full-sized avatar

alchemycs

View GitHub Profile
@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 / 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 / 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 / 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 / googleAdsDomain.xml
Created June 28, 2011 03:00
AWS Route 53 Change Resource Record Sets Request for pointing domains to google adsense domains. Now includes setting up google apps.
<?xml version="1.0" encoding="UTF-8"?>
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2010-10-01/">
<ChangeBatch>
<Comment>
<!-- Change this comment if you like. Don't forget to fill in your own domain and publisher id below! -->
Establish DNS records for Google Ads for Domains
</Comment>
<Changes>
<Change>
<Action>CREATE</Action>
@alchemycs
alchemycs / blogFeed.php
Created June 21, 2011 04:58
Sample blog feed
<?php
/*
* This class pulls and caches a blog feed from a remote site and displays the content locally.
*
*/
/**
* @author Michael McHugh
* @version 1.0 2009-10-14 - Initial code
* @version 2.0 2011-06-22 - Updated to allow 0-indexed article offset and standalone display
@alchemycs
alchemycs / paperpage.css
Created June 20, 2011 23:24
CSS To Simulate a Paper Page
/*
This code is taken from the forrst post: http://forrst.com/posts/CSS_to_simulate_a_paper_page-zwj
*/
section.page {
overflow: hidden;
margin: 50px auto;
width: 600px;
padding: 20px;
@alchemycs
alchemycs / CSFReferrer.class.php
Created April 7, 2011 03:45
Generates signed referrer links for auto-authentication into CompliSpace Fundamentals Sites
<?php
/**
* Generates signatures for referred logins to CompliSpace Fundamentals sites.
*
* Example: CSFReferrer::generate('http://xyz.complispace.com.au', 'bob',
* 'sampleAccessKeyId', 'sampleSecretAccessKey', 1320969600);
*
* @see Development Blog <http://complispace.github.com/>
* @see GitHub Repository <https://github.com/CompliSpace>
@alchemycs
alchemycs / forms.css
Created January 17, 2011 04:41
Provides structured layout to forms
/*
Basic form layouts using fieldset/legend for form sections. Group elements such as
radio and check boxes are implemented with nested fieldsets where the legend of the nested fieldset is the question label and
labels inside the ol->li blocks label the input elements.
I'll update this gist later with better examples or a reference to examples
In the meantime email alchemist {at} alchemycs {dot} net {dot} au for examples.
*/
fieldset
{
border: 1px solid gray;
@alchemycs
alchemycs / delete_duplicates.sql
Created January 11, 2011 23:59
Delete duplicate tuples from an entity that uses a pseudo primary key (eg, sequence/auto increment) instead of true keys
--Make a temporary table for unneeded PKs
create temporary table dirty_identifier (pseudo_key integer);
-- Get the PKs we don't need
insert into dirty_identifier (
select dt1.pseudo_pk from dirty_table as dt1, dirty_table as dt2 where
dt1.true_pk_1 = dt2.true_pk_1
-- and dt1.true_pk_2 = dt2.true_pk_3
-- and ... keep repeating for however many attributes make your real key
and dt1.pseudo_pk > dt2.pseudo_pk
);