Skip to content

Instantly share code, notes, and snippets.

from flask import render_template, flash, redirect, request, send_from_directory, url_for
import uuid
import os
import subprocess
import random
cwd = os.getcwd()
tmp_path = "/tmp/echo/"
serve_dir = "audio/"
docker_cmd = "docker run -m=100M --cpu-period=100000 --cpu-quota=40000 --network=none -v {path}:/share lumjjb/echo_container:latest python run.py"
import sys
from subprocess import call
import signal
import os
def handler(signum, frame):
os._exit(-1)
signal.signal(signal.SIGALRM, handler)
signal.alarm(30)
@mfridman
mfridman / osx-for-hackers.sh
Created July 1, 2017 18:13 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfridman
mfridman / Makefile
Created December 1, 2018 21:01 — forked from kwilczynski/Makefile
Makefile for my Go projects (an example).
SHELL := /bin/bash
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)
TARGET := packer-provisioner-itamae-local
VERSION := $(shell cat VERSION)
OS := darwin freebsd linux openbsd
ARCH := 386 amd64
@mfridman
mfridman / client_tls_info.go
Created March 6, 2019 04:58 — forked from husobee/client_tls_info.go
discovery of tls in go, and the handshake process
package main
import (
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net"
"net/http"
)
@mfridman
mfridman / sentry_example.go
Created July 29, 2019 02:55
capture sentry alert with error
func (a *alertWrapper) Error(err error) error {
// sentry Go SDK uses asynchronous transport, if fatal (os.Exit) or panic is called after the alert
// the event might get dropped, so we call Flush explicitly.
defer sentry.Flush(time.Second * 2)
hub := sentry.CurrentHub().Clone()
ev := sentry.NewEvent()
ev.Level = sentry.LevelError
@mfridman
mfridman / k8s.json
Created October 14, 2019 03:13
sample data
{
"id": 28265,
"language": "Go",
"fork": false,
"forks_count": 20568,
"open_issues_count": 3299,
"stargazers_count": 58727,
"watchers_count": 58727,
"archived": false,
"disabled": false,
@mfridman
mfridman / comments.md
Created November 8, 2019 04:33
top i.e., "controversial" comments from golang/go
@mfridman
mfridman / find-top.sql
Created November 8, 2019 04:40
finding top comments
WITH votes AS (
SELECT
number_id,
id,
SUM(CAST(plus_one + 1 AS FLOAT)) AS U,
SUM(CAST(minus_one + 1 AS FLOAT)) AS D
FROM
comments
GROUP BY
id,