Skip to content

Instantly share code, notes, and snippets.

View marz619's full-sized avatar
๐ŸŒŽ
Working From Earth

Ammaar Esmailjee marz619

๐ŸŒŽ
Working From Earth
View GitHub Profile
@marz619
marz619 / keybase.md
Created October 1, 2014 17:55
keybase.md

Keybase proof

I hereby claim:

  • I am marz619 on github.
  • I am ammaar (https://keybase.io/ammaar) on keybase.
  • I have a public key whose fingerprint is 3639 9955 5DB2 0D2E F4E8 E7F3 F2A1 6018 035F 7A86

To claim this, I am signing this object:

@marz619
marz619 / redis_rename_keys.sh
Last active October 22, 2025 22:44
Rename Redis Keys
#!/bin/bash
# args
prefix=$1
replace=$2
redis='redis-cli -s /var/run/redis/redis.sock'
keys=( $(redis-cli -h $host KEYS "$prefix*") )
for key in "${keys[@]}"
@marz619
marz619 / rotate_slice.go
Created December 23, 2016 21:09
Rotate a slice
package aoc
import (
"errors"
"reflect"
)
// rotate rotates the values of a slice by rotate positions, preserving the
// rotated values by wrapping them around the slice
func rotate(slice interface{}, rotate int) error {
@marz619
marz619 / threadpool.py
Last active February 23, 2018 12:13
A simple ThreadPool example in python
#!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
import time
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool
import requests
@marz619
marz619 / json_io.go
Last active April 26, 2017 17:52
simple JSON utility funcs
package json
import (
"bytes"
"encoding/json"
"io"
)
// WriteJSON tries to encode `data` in to the provided io.Writer
//
@marz619
marz619 / context_cancel.go
Last active May 25, 2017 05:02
Go (lang) context patterns
package main
import (
"context"
"flag"
"log"
"math/rand"
"os"
"os/signal"
"sync"
@marz619
marz619 / stack.go
Last active July 22, 2025 05:59
"Generic" Stack (Go-lang <pre-generics>)
package stack
import (
"reflect"
"sync"
)
// Stack implements Push & Pop
type Stack interface {
Push(interface{})
@marz619
marz619 / README.md
Last active March 26, 2020 17:41
Go build LDFlags

Using the -ldflags parameter can help set variable values at compile time.

Using the example provided here:

  1. Running make build will create a build executable. Running it will result in:
$> ./build
no version (Mon YYYY)
$>
@marz619
marz619 / dir_help.py
Created August 27, 2017 20:33
Simple help & dir extensions for python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def dird(cls):
"""
return a generator that yields all methods for `cls`
that do not start with underscore (_)
"""
cn = type(cls).__name__
@marz619
marz619 / tristate.go
Created September 14, 2017 17:12
Simple in memory Tristate (miss/yes/no) cache
package tristate
import "sync"
// State for a tristate cache
type State int
// cache State contants
const (
Miss State = iota