Skip to content

Instantly share code, notes, and snippets.

package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
@xaprb
xaprb / ewma.go
Created October 1, 2013 19:15
How to define a type as a rebranded native type. Downside: lots of casting. Good or bad?
type SimpleEWMA float64
// Value returns the current value of the moving average.
func (e *SimpleEWMA) Value() float64 {
return float64(*e)
}
// Add adds a value to the series and updates the moving average.
func (e *SimpleEWMA) Add(value float64) {
if *e == 0 { // this is a proxy for "uninitialized"
drop temporary table if exists left1;
drop temporary table if exists left2;
drop temporary table if exists right1;
drop temporary table if exists right2;
drop temporary table if exists right3;
create temporary table left1 (
col1 int unsigned not null auto_increment primary key,
col2 bit not null default 0,
col3 bit not null default 0
@xaprb
xaprb / Logger.asp
Created January 18, 2014 19:45
Old ASP scripts from 2004 or so; forgot what they are even for.
<script Language="VBScript" RunAt="server">
Class Logger
Private m_Name
Private m_Level
Private m_LoggerLevel
Private m_Destination
Private m_BufferOutput
Private m_Buffer
This file has been truncated, but you can view the full file.
A
a
aa
aal
aalii
aam
Aani
aardvark
aardwolf
Aaron

Keybase proof

I hereby claim:

  • I am xaprb on github.
  • I am xaprb (https://keybase.io/xaprb) on keybase.
  • I have a public key whose fingerprint is E877 C582 9D0E 5E8A 3AE1 BC4E D14D 8893 201A BAA0

To claim this, I am signing this object:

@xaprb
xaprb / backup_github.sh
Created March 7, 2015 13:59
Shell script to back up all of an organization's GitHub repos
#!/bin/sh
LOGIN=YOURLOGIN
TOKEN=YOURTOKEN
ORG=YOURORG
DONE=0
PAGE=0
# sample output:
# "total_private_repos": 50,
<?php
$permissions = array(
"owner_read" => 256,
"owner_write" => 128,
"owner_delete" => 64,
"group_read" => 32,
"group_write" => 16,
"group_delete" => 8,
"other_read" => 4,
<?php
$permissions = array(
"owner_read" => 256,
"owner_write" => 128,
"owner_delete" => 64,
"group_read" => 32,
"group_write" => 16,
"group_delete" => 8,
"other_read" => 4,
<?php
$permissions = array(
"owner_read" => 256,
"owner_write" => 128,
"owner_delete" => 64,
"group_read" => 32,
"group_write" => 16,
"group_delete" => 8,
"other_read" => 4,