Skip to content

Instantly share code, notes, and snippets.

View artyom's full-sized avatar

Artyom Pervukhin artyom

View GitHub Profile
@tobert
tobert / mincore.go
Last active August 29, 2015 14:00
mincore in Go
package main
import (
"flag"
"log"
"os"
"syscall"
"unsafe"
)
@artyom
artyom / self-logging.sh
Created November 29, 2014 11:37
Redirect script output to syslog from within script itself
#!/bin/sh -eu
LOGPIPE=/tmp/logpipe.$$
mkfifo $LOGPIPE
logger -t "$0.$$" -f $LOGPIPE &
exec 1>$LOGPIPE
exec 2>&1
rm -f $LOGPIPE
echo "hello on stdout"
echo "hello on stderr" >&2
exec sleep 20
@jameshfisher
jameshfisher / trie.go
Created May 15, 2010 19:05
A trie structure, storing []byte elements, implemented in Go
package trie
import (
"container/vector"
"sort"
)
// A 'set' structure, that can hold []byte objects.
// For any one []byte instance, it is either in the set or not.
type Trie struct {
body common control {
bundlesequence => { "set_dns_configuration" } ;
}
#######################################################################
# Configure DNS
# Use Google's DNS servers, and set the defaut domain to normation.com
#######################################################################
bundle agent set_dns_configuration {
vars:
@peo3
peo3 / linux.c
Created April 21, 2011 11:51
An extension module to call eventfd(2) in python
/*
* Usage in python:
*
* import linux
* efd = linux.eventfd(0, 0)
* ...
* ret = struct.unpack('Q', os.read(efd, 8))
* ...
* linux.close(efd)
*/
#!/usr/bin/env python
import sys
import subprocess
def grep(fd, magic, chunk_size=1024, alignement=0):
"""
Iteratively yield positions of the magic in a file descriptor
:param fd: open file descriptor (device or a file)
:param magic: substring to find
@imankulov
imankulov / client.py
Created September 1, 2012 09:35
Helper class to ease testing Django views
# -*- coding: utf-8 -*-
from django.test.client import Client as BaseClient
from django.core.urlresolvers import reverse
class Client(BaseClient):
"""
I used to be reluctant testing Django views until I wrote this class
@nf
nf / analyze.go
Last active January 12, 2016 21:14
'spent' script to log where time is spent
package main
import (
"bufio"
"fmt"
"net/url"
"os"
"regexp"
"sort"
"strconv"
@mynameisfiber
mynameisfiber / gist:2853066
Created June 1, 2012 15:44
Golang http close body blocking problem
package main
import (
"crypto/tls"
"net"
"net/http"
"time"
"fmt"
"errors"
)
@hostmaster
hostmaster / registry_ls.sh
Last active April 28, 2020 10:44
get a list package versions in GitHub Package Repository
#!/bin/bash
set -eo pipefail
TOKEN=${GITHUB_TOKEN:?environment variable is empty or unset}
[ -n "$1" ] && GITHUB_REPOSITORY=$1
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:? please provide a name of a repository}
OWNER=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)