Skip to content

Instantly share code, notes, and snippets.

@bradj
bradj / gist:4179157
Created November 30, 2012 22:28
CC jsonp fyi
$.ajax({
url: that.config.mapserver + '?f=json',
dataType: 'jsonp',
}).done(function(evt, status) {
console.log(evt);
console.log(status);
}).error(function(evt) {
console.log(evt);
});
@bradj
bradj / Haar1d
Created October 22, 2013 03:30
Haar Wavelet Transform
class Haar1D(object):
def transform(self, data, L):
ls = []
level = 0
length = len(data)
while level < L:
elements = length * pow(2, -level)
data = self.getsequence(data, elements)
@bradj
bradj / Irssi SNS
Created October 22, 2013 21:20
Publishes to SNS topic with associated message on regex match.
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '1.00';
%IRSSI = (
authors => 'Brad Janke',
contact => 'brad.janke@gmail.com',
name => 'Irssns',
description => 'Sends SNS On Regex',
@bradj
bradj / base64_encode.js
Created July 19, 2016 15:51
Encode file to base64 and outputs in console.
const fs = require('fs');
const f = process.argv[2];
fs.access(f, fs.R_OK, (err) => {
if (err) {
kill(`Cannot acces ${f}`);
}
readFile();

Keybase proof

I hereby claim:

  • I am bradj on github.
  • I am bradj (https://keybase.io/bradj) on keybase.
  • I have a public key whose fingerprint is E2C4 9CF4 3939 F853 8275 A042 F8E3 C606 D3D1 D359

To claim this, I am signing this object:

@bradj
bradj / webserver.py
Last active October 25, 2018 18:59
Simple test stdlib webserver in py3.6
import time
from http.server import HTTPServer, BaseHTTPRequestHandler
HOST_NAME = ''
PORT_NUMBER = 8000
HTML_CONTENT = '''
<html><head><title>Title goes here.</title></head>
<body><p>This is a test.</p>
<p>You accessed path: %s</p>
@bradj
bradj / node-aws-dynamodb
Created December 19, 2012 07:41
Node.js AWS DynamoDB scan example
var express = require('express');
var aws = require('aws-sdk');
var config = require('./config.js');
aws.config.update({accessKeyId: config.key, secretAccessKey: config.secret});
aws.config.update({region: 'us-east-1'});
var app = express();
app.configure(function(){
###
### All VLANs
###
Cisco24#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Gi3/0/3, Gi3/0/4, Gi3/0/5
Gi3/0/6, Gi3/0/7, Gi3/0/8
Gi3/0/9, Gi3/0/10, Gi3/0/11