Skip to content

Instantly share code, notes, and snippets.

View shentonfreude's full-sized avatar

Chris Shenton shentonfreude

View GitHub Profile
-- Alter tables exported from Serena/PVCS Tracker to have primary key.
-- Then we can use SqlAlchemy's SQLsoup to work with it.
-- Use like:
-- sqlplus $USERNAME/$PASSWORD@$HOST_FQDN_OR_IP/xe < add_primary_key.sql
ALTER TABLE TRKASSOC add primary key (associd);
ALTER TABLE TRKCH add primary key (chid);
ALTER TABLE TRKCHG add primary key (chgid);
-- Nonstandard: ALTER TABLE TRKCTL add primary key (CTLid);
ALTER TABLE TRKCTL add primary key (ctltableid);
@shentonfreude
shentonfreude / trac-tickets-to-gh.py
Created June 30, 2011 18:47 — forked from dittos/trac-tickets-to-gh.py
Trac tickets to GitHub issues
import sys; reload(sys); sys.setdefaultencoding('utf-8')
import sqlite3
import urllib2
import urllib
import simplejson
login = 'your github id'
token = 'your github api key'
repo = 'username/reponame'
@shentonfreude
shentonfreude / gist:1202829
Created September 8, 2011 07:06
Chameleon template to alternate class="odd" or "even"
<tbody>
<tal:block repeat="ur url_recs">
<tr tal:define="odd repeat.ur.odd"
tal:attributes="class python: odd and 'odd' or 'even'">
<td>${ur.datetime}</td>
<td>...</td>
</tr>
</tal:block>
</tbody>
@shentonfreude
shentonfreude / curl-redmine-issue.sh
Created March 15, 2013 22:45
Curl command to create new issue in RedMine for a specific project with some pre-created custom fields. Since the CSV importers all seem ancient, perhaps we can do this with a REST POST for each line in a CSV ourselves.
#!/bin/sh
# You have to enable the Custom Field for the tracker you're targetting: bug, feature, whatever.
# cf without 'id' doesn't set anything
# cf with 'id' and no 'name' sets that attr
#
# Upon creation we get a record back with custom fields filled in, with id:
#
# "custom_fields":[{"id":1, "name":"Operating System", "value":"FeedBSD"},
# {"id":7, "name":"Operating System Version", "value":""},
# {"id":2, "name":"Database", "value":""},
!/bin/sh
# 2013-11-21 Chris Shenton <[email protected]>
# Send an Oracle TNS 'ping' to the host and port specified.
# If it's Oracle, we should get a response like:
# C"7(DESCRIPTION=(TMP=)(VSNNUM=0)(ERR=0)(ALIAS=l_ORCL_001))
# String from base64 encoding packet sent by:
# http://www.jammed.com/~jwa/hacks/security/tnscmd/tnscmd
tnsstr="AFcAAAEAAAABNgEsAAAIAH//fwgAAAABAB0AOgAAAAAAAAAAAAAAAAAAAAA05gAAAAEAAAAAAAAAAChDT05ORUNUX0RBVEE9KENPTU1BTkQ9cGluZykp"
echo $tnsstr | base64 --decode | nc $1 $2
[buildout]
extensions = mr.developer
parts =
gae_sdk
gae_tools
app_lib
local_appserver_deps
nosetests
# order matters so that this python overwrites the one generated by gae_tools
# until they publish the fix https://github.com/prmtl/appfy.recipe.gae/pull/9
@shentonfreude
shentonfreude / gist:299c476d5b7e17552de3
Created August 20, 2014 00:46
Golang channel drunks
package main
import (
"fmt"
"strconv"
"time"
)
var i int
#!/usr/bin/env python
import sys
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config
from pyramid.view import view_defaults
@shentonfreude
shentonfreude / s3-sns-sqs.json
Last active March 28, 2018 19:35
S3 bucket with Notification to SNS which sends email and injects a message into SQS
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Apply policy to NEW bucket",
"Resources": {
"Queue": {
"Type": "AWS::SQS::Queue",
"Properties": {
"QueueName": "cshenton-tropo-queue"
#!/usr/bin/env python3
# Get file path from sys.argv and upload as a presigned URL
import os
import sys
import boto3
import requests
asset_path = sys.argv[1]
_, asset_fname = os.path.split(asset_path)