Skip to content

Instantly share code, notes, and snippets.

View mustpax's full-sized avatar

Mustafa "Moose" Paksoy mustpax

View GitHub Profile
@mustpax
mustpax / clip.sh
Created May 20, 2024 22:04
Bash script to edit contents of your clipboard with $EDITOR on macOS
#!/bin/bash
set -o errexit # Exit on error
set -o nounset # Treat unset variables as an error
set -o pipefail # Consider errors in a pipeline
default_editor=${EDITOR:-vim}
temp_file_path=$(mktemp /tmp/clip_temp.XXXXXX)
trap "rm -f $temp_file_path" EXIT
@mustpax
mustpax / group_by_column.gs
Created January 25, 2024 22:11
Google Apps Script for creating collapsible groups (assumes data is sorted, requires underscore)
function run() {
groupByColumn(0);
groupByColumn(1);
groupByColumn(2);
}
function selectRows(sheet, startRow, endRow) {
let numRows = endRow - startRow;
let startRow1Indexed = startRow + 2;
return sheet.getRange(startRow1Indexed, 1, numRows, sheet.getDataRange().getNumColumns());
const _ = require("underscore");
const fs = require("fs");
// convert hex to base64
function challenge1(hex) {
return Buffer.from(hex, "hex").toString("base64");
}
// xor two hex encoded strings, return hex
function challenge2(hex1, hex2) {
[
{
"name":"Pavel",
"surname":"Gherghel",
"gender":"male",
"region":"Romania"
},
{
"name":"Ludmila",
"surname":"Găină",
@mustpax
mustpax / graph-it-with-graphite
Created July 31, 2013 01:07
Graphite metric expressions for lightning talk
aws.cloudwatch.api.us-east-1b.HTTPCode_Backend_2XX.count
aws.cloudwatch.api.*.HTTPCode_Backend_2XX.count
sumSeries(aws.cloudwatch.api.*.HTTPCode_Backend_2XX.count)
timeShift(sumSeries(aws.cloudwatch.api.*.HTTPCode_Backend_2XX.count), '-1w')
diffSeries(timeShift(sumSeries(aws.cloudwatch.api.*.HTTPCode_Backend_2XX.count), '-1w'), sumSeries(aws.cloudwatch.api.*.HTTPCode_Backend_2XX.count))
@mustpax
mustpax / Makefile
Created September 14, 2012 00:48
coffee makefile
# Basic compilation rules for CoffeScript
run: script.js
node script.js
clean:
rm script.js
.coffee.js :
coffee -c $<
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.basic.DefaultOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
@mustpax
mustpax / tumblr.html
Created September 4, 2011 06:51
Modified Tumblr Theme
<!DOCTYPE>
<!-- Designed by Peter Vidani
Found at http://www.tumblr.com/theme/467
-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="TextMate http://macromates.com/">
@mustpax
mustpax / spiral.py
Created August 30, 2011 20:50
Spiraling two dimensional array iterator
#!/usr/bin/env python
'''I saw an Erlang solution to this problem, thought I'd give it a shot in Python.
http://erlangquicktips.heroku.com/2010/01/06/following-a-spiral/
'''
def spiral(l):
'''Take a list of lists that is assumed to be in row major order.
Return a list generated by iterating through the elements of the structure
in a spiral that moves closer to the center as you move clockwise.
@mustpax
mustpax / gist:1142545
Created August 12, 2011 17:45
TextWrangler Diff with Git
git config --global --add "difftool.twdiff.cmd" 'twdiff --wait "$LOCAL" "$REMOTE"'
git config --global diff.tool twdiff