Skip to content

Instantly share code, notes, and snippets.

View russau's full-sized avatar

Russ Sayers russau

View GitHub Profile
@russau
russau / readme
Created March 4, 2012 12:34
marketplace reviews bookmarklet
javascript: (function() {
if (!($ = window.jQuery)) { // typeof jQuery=='undefined' works too
script = document.createElement('script');
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
script.onload = releasetheKraken;
document.body.appendChild(script);
}
else {
releasetheKraken();
}
@russau
russau / WebForm1.aspx
Created May 15, 2012 21:28
Evil viewstate crash
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="DynamicControls.WebForm1" %>
<%@ Register src="WebUserControl1.ascx" tagname="WebUserControl1" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
@russau
russau / gist:3076039
Created July 9, 2012 11:54
Wake on LAN
byte[] packet = new byte[17*6];
for(int i = 0; i < 6; i++)
packet[i] = 0xff;
@russau
russau / gist:3655520
Created September 6, 2012 12:04
De-Mojibake
byte[] badBytes = new byte[] { 0x44, 0x6f, 0x72, 0x66, 0x73, 0x74, 0x72, 0x61, 0xc3, 0x83, 0xc5, 0xb8, 0x65 }; //Dorfstraße
string utf8 = System.Text.Encoding.UTF8.GetString(badBytes);
byte[] fixedBytes = System.Text.Encoding.GetEncoding(1252).GetBytes(utf8);
string allGood = System.Text.Encoding.UTF8.GetString(fixedBytes); //Dorfstraße
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%
System.Net.IPHostEntry host;
string hostname = "rsmazdb.copiliunddin.us-west-2.rds.amazonaws.com";
host = System.Net.Dns.GetHostEntry(hostname);
foreach (System.Net.IPAddress ip in host.AddressList)
{
@russau
russau / s3_hitter.py
Created December 5, 2014 23:03
s3 redirect diagnose
import urllib2
import datetime
import time
import socket
domain = "201412051453-oregon-cats.s3.amazonaws.com"
# http://stackoverflow.com/questions/17202364/urllib2-urlopen-adding-host-header
while 1:
@russau
russau / Program.cs
Created January 14, 2015 20:47
Introduction to KMS
using Amazon;
using Amazon.KeyManagementService;
using Amazon.KeyManagementService.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@russau
russau / demo.js
Created February 16, 2015 02:38
Lambda function for ElasticTranscoder
console.log('Loading event');
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
console.log('Received event:');
console.log(JSON.stringify(event, null, ' '));
// Get the object from the event and show its content type
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var output = Math.random().toString(36).substring(7) + ".webm";
{
"Metrics": [
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-aaaaaaaa"
}
],
{
"Metrics": [
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-aaaaaaaa"
}
],