Skip to content

Instantly share code, notes, and snippets.

View allen-munsch's full-sized avatar
⁉️

James allen-munsch

⁉️
View GitHub Profile
@StuartGordonReid
StuartGordonReid / RiskAdjustedReturnMetrics.py
Last active June 13, 2023 06:40
Measured of Risk-adjusted Return
import math
import numpy
import numpy.random as nrand
"""
Note - for some of the metrics the absolute value is returns. This is because if the risk (loss) is higher we want to
discount the expected excess return from the portfolio by a higher amount. Therefore risk should be positive.
"""
@smoser
smoser / cloud-to-lxd
Last active January 10, 2019 16:07
lxc tools. Random tools around lxc.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
UC_PREP="/usr/share/lxc/hooks/ubuntu-cloud-prep"
error() { echo "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
Usage() {
@Bouke
Bouke / gist:10454272
Last active September 22, 2023 17:23
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

@soarez
soarez / ca.md
Last active May 3, 2024 00:04
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@gustavohenrique
gustavohenrique / soap-curl-shell
Created June 11, 2013 19:24
SOAP request using curl
# request.xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wst="http://sensedia.com/repository/wstoolkit">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>system</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">manager</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">DWk64SMfJ6RxHAKgPRGtPA==</wsse:Nonce>
<wsu:Created>2013-04-17T18:36:54.013Z</wsu:Created>
</wsse:UsernameToken>
@craSH
craSH / iptables-sol.sh
Last active September 4, 2018 18:23
Masquerade/redirect incoming TCP connections on all ports (1:65535) to $dst_ip port $dst_port.Great for creating a proxy/jump box that lets you SSH to your server, in cases when you're on strange/(poorly) restrictive networks and need to tunnel out.
#!/bin/bash
#
# Masquerade/redirect incoming TCP connections on all ports (1:65535) to $dst_ip port $dst_port
# Call with -f to force update, even if IP cache exists and shows no changes.
# Make sure this isn't a CNAME! Otherwise the below dig command won't follow it and return an IP.
dst_host="neg9.org"
target_ns="google-public-dns-a.google.com"
dst_port=22
@dmytro
dmytro / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 21, 2024 00:52
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@indiejoseph
indiejoseph / gist:3047593
Created July 4, 2012 14:13
UserScript - XHR Interceptor
function Interceptor(nativeOpenWrapper, nativeSendWrapper) {
XMLHttpRequest.prototype.open = function () {
// Code here to intercept XHR
return nativeOpenWrapper.apply(this, arguments);
}
XMLHttpRequest.prototype.send = function () {
this.onloadend = function() {
if(this.capture) {
console.log(this.responseText);