Skip to content

Instantly share code, notes, and snippets.

@McPolemic
McPolemic / SSLRedirect.html
Created December 20, 2011 16:07
A redirect page for IIS in order to enforce HTTPS
<script language="JavaScript">
<!-- begin hide
// Originally from http://raoulpop.com/2007/08/07/automatic-redirect-from-http-to-https/
function SSLRedirect()
{
if (window.location.protocol = "http:")
{
var oldURL = window.location.hostname + window.location.pathname;
var newURL = "https://" + oldURL;
window.location = newURL;
@McPolemic
McPolemic / gist:1633379
Created January 18, 2012 14:59
Fix for Wikipedia's SOPA blackout.
javascript:$("div").show();$("#mw-sopaOverlay").hide();
@McPolemic
McPolemic / gist:1721703
Created February 2, 2012 05:30
pseudo code for state reporting
for teacher in teachers:
for course in courses:
if teacher.spec_ed_cert:
print course
else:
if course.student_set.spec_ed:
print course
print course.spec_ed
else:
print course
@McPolemic
McPolemic / flatfile.py
Created June 21, 2012 05:05
Convert C-style flat-file structs to python dicts
import struct
def parse(my_struct, my_string):
"""Takes a large string such as the following:
char record1[2];
char record2[10];
char record3[15];
char record4[12];
and a target string that represents the struct's data, and returns a
dict with the struct entries as keys and the unpacked data as values."""
@McPolemic
McPolemic / gist:3004483
Created June 27, 2012 14:40
Modify by reference example
#include <stdio.h>
void modify_short(short *value)
{
*value = 3;
}
int main(int argc, char *argv[]) {
short temp = 2;
modify_short(&temp);
@McPolemic
McPolemic / textExpanderDate.ahk
Created January 18, 2013 15:23
An AutoHotKey script for handling today's date.
#Creates a date with the format 12/25/2012
:*?:;dt::
FormatTime, CurrentDate,, MM/dd/yyyy
SendInput %CurrentDate%
return
#Creates a date with the format 20121225
:*?:;idt::
FormatTime, CurrentDate,, yyyyMMdd
SendInput %CurrentDate%
@McPolemic
McPolemic / gist:4693282
Last active December 12, 2015 01:48
Oracle Singleton working in Ruby
[1] pry(main)> require './detpd270'
Warning: NLS_LANG is not set. fallback to US7ASCII.
=> true
[2] pry(main)> c = Connection.instance.conn
=> #<OCI8:LUKENAX>
[3] pry(main)> c.exec('select * from dual') { |results| puts results }
X
=> 1
[4] pry(main)> c.exec("select sysdate, to_char(sysdate, 'YYYYMMDD') from dual") { |results| puts results }
2013-02-01 12:50:06 -0500
@McPolemic
McPolemic / Vagrantfile
Last active December 16, 2015 13:39
Setting up a Vagrant cluster for testing out Apache Hadoop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "base-hadoop"
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "base-hadoop.pp"
drafts://x-callback-url/create?text={{!Things}}%0A[[draft]]&action=List%20in%20Reminders&x-success=things://inbox
@McPolemic
McPolemic / EmbedPDF.txt
Last active December 13, 2020 17:59
Open embedded PDF bookmarklet
javascript:(function(){var objects=document.getElementsByTagName("object");for(i=0;i<objects.length;i++){data=objects[i].getAttribute("data");if(data.indexOf("pdf")!=-1)document.location=data;}})();