Skip to content

Instantly share code, notes, and snippets.

View iainelder's full-sized avatar

Iain Samuel McLean Elder iainelder

View GitHub Profile
@andyoakley
andyoakley / gist:1651859
Created January 21, 2012 07:10
Simple PivotTable in Powershell
# Rotates a vertical set similar to an Excel PivotTable
#
# Given $data in the format:
#
# Category Activity Duration
# ------------ ------------ --------
# Management Email 1
# Management Slides 4
# Project A Email 2
# Project A Research 1
@glennblock
glennblock / fork forced sync
Created March 4, 2012 19:27
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
@mdengler
mdengler / html2csv.py
Created June 21, 2012 04:45
html2csv.py
#!/bin/env python
# -*- coding: utf-8 -*-
"""
Examples:
%(progname)s http://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics
This is essentially this logic, done up
@Kurt-P
Kurt-P / GropuAndSum.ps1
Created August 20, 2013 20:54
Group and sum a set of data with powershell
$gdata = $printsLogs | Group-Object -Property userId
$test = @()
$test += foreach($item in $gdata){
$item.Group | Select -Unique userId,
@{Name = 'PageTotal';Expression = {(($item.Group) | measure -Property pages -sum).Sum}}
}
@rectangletangle
rectangletangle / gist:0a0d5a2e84dd3178d348
Last active January 29, 2022 17:32
Python 3 Monkeypatch Context Manager
""" This is a convenient way to monkeypatch a method or attribute of a Python
object. This is great for situations where you want to modify a global
object within a limited scope, i.e., your typical class or module when
testing. This was tested and works with Python 2.7 and 3.4. """
import contextlib
@contextlib.contextmanager
def monkeypatched(object, name, patch):
""" Temporarily monkeypatches an object. """
@quiver
quiver / retrieve-EC2-region-information-from-metadata.md
Last active March 14, 2024 16:42
retrieve EC2's region from instance metadata

Sometimes you want to retrieve EC2 insntances' region information.

You can query that information through instance metadata(169.254.169.254).

$ curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "privateIp" : "172.31.2.15",
  "instanceId" : "i-12341ee8",
  "billingProducts" : null,
 "instanceType" : "t2.small",
@graste
graste / strace.md
Last active May 31, 2024 09:06
strace process for network and memory and other syscalls

File activity

strace -e trace=file -fp PID (file) or strace -e trace=desc -fp PID (file descriptors)

Common calls:

  • access
  • close – close file handle
  • fchmod – change file permissions
  • fchown – change file ownership
@Treer
Treer / gist:c7d7e33289b725dfb9d07718f6153a9d
Created December 11, 2016 13:18
Find most active fork of a github project
http://forked.yannick.io/
@weavenet
weavenet / console.py
Last active August 5, 2023 17:57
Python script to assume STS role and generate AWS console URL.
#!/usr/bin/env python
import getpass
import json
import requests
import sys
import urllib
import boto3
@pkazi
pkazi / cloudTrailEventNames.list
Last active March 23, 2024 09:37
List of values for parameter EventName in AWS Cloudtrail events
AbortDocumentVersionUpload
AbortEnvironmentUpdate
AbortMultipartUpload
AbortVaultLock
AcceptAccountMapping
AcceptCertificateTransfer
AcceptDelegate
AcceptDirectConnectGatewayAssociationProposal
AcceptFxPaymentCurrencyTermsAndConditions
AcceptHandshake