Skip to content

Instantly share code, notes, and snippets.

View gknapp's full-sized avatar

Greg Knapp gknapp

View GitHub Profile
@gknapp
gknapp / fail.ts
Created December 11, 2020 17:25
Ambient type declaration for JSON file
/// <reference path="./renderer/abstract.ts" />
declare module "defaults.json" {
type ConfigFile = import("./renderer/abstract").ConfigFile
export default ConfigFile
}
@gknapp
gknapp / postcommit.ps1
Last active February 15, 2018 17:07
Post commit hook to run a Jenkins build
# Powershell post-commit hook. Can be used with Tortoise SVN as a
# client side hook using:
# powershell.exe C:\path\to\postcommit.ps1 <JenkinsJob> <AuthToken> <JenkinsUser> <APIToken>
#
# You may need to bypass the Execution Policy (default is Restricted):
#
# powershell.exe -ExecutionPolicy Bypass C:\path\to\postcommit.ps1 ...
#
# JenkinsJob is the job name
# AuthToken is set in job Build Triggers
@gknapp
gknapp / queue.cljs
Last active August 29, 2015 14:13
ack / nack rabbitmq msg
;; ACK/NACK a rabbitmq message.
;; Construct a frame as per the STOMP 1.1 spec:
;; https://stomp.github.io/stomp-specification-1.1.html#ACK
;;
;; Used for reference:
;; https://github.com/easternbloc/node-stomp-client/blob/master/lib/client.js
(ns cljs-node-stomp.queue
(:require [cljs.nodejs :as node]))
@gknapp
gknapp / argparse.hy
Last active August 29, 2015 14:12
Instantiate with constructor args
(import argparse)
(defn my-func
[]
(let [[desc "My App"]
[parser ((. argparse ArgumentParser) :description desc)]]
(. parser parse-args)))
@gknapp
gknapp / wsse.php
Last active March 12, 2022 19:17
Add WSSE support to PHP's soapclient
<?php
class WsseHeader
{
const NS_WSSE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
const NS_WSSEPSWD = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText';
public function build($username, $password)
{
$header = sprintf(
@gknapp
gknapp / request.xml
Created July 26, 2012 15:08
PHP SoapClient request
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xxx" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns3="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
<SOAP-ENV:Header>
<ns2:Security SOAP-ENV:mustUnderstand="1">
<ns2:UsernameToken>
<ns2:Username>username</ns2:Username>
<ns3:Password>password</ns3:Password>
</ns2:UsernameToken>
</ns2:Security>
</SOAP-ENV:Header>
@gknapp
gknapp / bug55317_test.php
Created February 25, 2012 20:10
PHP bug #55317 test
<?php
$url = 'http://chalk.coas.unf.edu/eureka/files/templates/tmpl_chm.xml';
$xml = file_get_contents($url);
echo "---- Expected ----" . PHP_EOL;
echo $xml . PHP_EOL;
echo "Length: " . strlen($xml) . PHP_EOL;
$simpleXml = simplexml_load_file($url);
$sXml = $simpleXml->asXML();
@gknapp
gknapp / slurp twitter
Created May 24, 2011 19:14
Backup your tweets with PHP
<?php
/**
* Not my most graceful code, in fact this doesn't represent
* my coding style at all really but it serves a purpose and
* enabled me to backup 62 pages of tweets (1,223).
*
* Don't forget to change the username before you back up my
* feed by mistake :)
*/