Skip to content

Instantly share code, notes, and snippets.

@stask
stask / todoist.clj
Last active April 21, 2021 12:54
A simple babashka script to get a list of tasks from Todoist in a format that is easy to use in Roam Research.
#!/usr/bin/env bb
(ns stask.todoist
(:require
[clojure.tools.cli :as tools.cli]
[org.httpkit.client :as client]
[cheshire.core :as json]
[clojure.string :as string]))
(def cl-options
@stask
stask / mailplane.el
Created May 1, 2019 09:13
Add support for Mailplane links to org-mode
;; attempt to add mailplane support
(defcustom org-mailplane-url-protocol "mailplane"
"Protocol identifier for Mailplane links."
:group 'org-mailplane
:type 'string)
(defun org-mailplane-follow (email-id)
"Open mailplane with given EMAIL-ID."
(browse-url (concat "mailplane:" email-id)))
@stask
stask / list-al2-amis.sh
Created May 24, 2018 08:53
List AMIs for Amazon Linux 2 with creation dates and descriptions
#!/usr/bin/env bash
aws_profile=$1
aws --profile=$aws_profile ec2 describe-images --owners self amazon --filters "Name=name,Values=amzn2*gp2" | jq '.Images[] | {created: .CreatedDate, description: .Description, ami: .ImageId}'
@stask
stask / google-api.clj
Created August 6, 2017 14:27 — forked from arohner/google-api.clj
Clojure example of accessing google APIs directly
(ns example.api.google
(:require [cemerick.url :as url]
[cheshire.core :as json]
[clj-jwt.core :as jwt]
[clj-jwt.key :as key]
[clj-time.core :as time]
[clj-http.client :as http]
[clojure.string :as str])
(:import java.io.StringReader))

Keybase proof

I hereby claim:

  • I am stask on github.
  • I am stask (https://keybase.io/stask) on keybase.
  • I have a public key whose fingerprint is 40C9 5209 0FB2 536A 7168 D310 1EF8 9F4D D66B 9C88

To claim this, I am signing this object:

@stask
stask / gist:10469324
Last active December 6, 2016 10:27
PT Authentication in PHP
<?php
$api_key = ""; // here goes your api_key
$api_secret_key = ""; // here goes your api_secret_key
$timestamp = time();
$signature = md5($api_key . $api_secret_key . $timestamp);
$auth_header = "custom api_key=" . $api_key . ", signature=" . $signature . ", ts=" . $timestamp;
$ch = curl_init();
@stask
stask / upload_test_result_json.py
Last active August 29, 2015 13:56
uploading files to practitest
# You will need to install MultipartPostHandler2 via pip
# $> sudo pip install MultipartPostHandler2
import MultipartPostHandler, urllib2, md5, time
URL = "https://prod.practitest.com/api/automated_tests/upload_test_result.json"
#
# Specify your API_KEY and API_SECRET_KEY below
API_KEY = ""
API_SECRET_KEY = ""
@stask
stask / gist:7103154
Last active December 26, 2015 05:49
Downloading non-public files via REST API from S3 in Clojure
(ns agent-smith.s3
(:require [clojure.data.codec.base64 :as b64]
[clojure.string :as s]
[clojure.java.io :refer [copy file]]
[clj-http.client :as client]
[clj-time.core :as t]
[clj-time.format :as tf]))
(defn- sign [data key]
(let [mac (javax.crypto.Mac/getInstance "HmacSHA1")
@stask
stask / gist:5607341
Last active September 18, 2020 13:47
Creating new slave for large MySQL database

Creating content-dashboard-db-master new MySQL replica 2013-05-16

  • Created 6 512GB 1000 IOPS volumes in us-east-1d zone (reused 4 volumes from previous replica and added 2 new). All volumes are labeled content-dashboard-mysql-fast{0,1,2,3,4,5}.

  • Connected the volumes to content-dashboard-db-master machine on /dev/sd{f,g,h,i,j,k} (0 -> f, 1 -> g, 2 -> h, 3 -> i, 4 -> j, 5 -> k).

  • Created /dev/md1 RAID0 volume from 6 drives:

      mdadm --create -l0 -n6 /dev/md1 /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk
    
  • Create XFS filesystem on /dev/md1:

mkfs.xfs /dev/md1 -f

@stask
stask / gist:4555635
Last active December 11, 2015 05:58
Wrapper to search EC2 machines by name tag. Shows only running instances.
#!/usr/bin/env bash
if [ -z "$EC2_PRIVATE_KEY" ]; then
echo "EC2_PRIVATE_KEY is not defined"
exit 1
fi
if [ -z "$EC2_CERT" ]; then
echo "EC2_CERT is not defined"
exit 1