Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# encoding: utf-8
# Author: qingfeng@douban.com
from __future__ import with_statement
from optparse import OptionParser
import os
parser = OptionParser(version="new9 command v1.0 -- by qingfeng@douban.com")
parser.add_option("-p", "--install",
@kachayev
kachayev / barber.go
Last active December 11, 2015 17:29
Solve "Sleeping Barber Problem" with Golang (more about problem - http://en.wikipedia.org/wiki/Sleeping_barber_problem)
package main
import (
"fmt"
"time"
"math/rand"
)
const (
CUTTING_TIME = 20
@Macil
Macil / local.usr.bin.skype
Last active January 31, 2017 06:14
Skype AppArmor profile(tested with Ubuntu 14.10 and Skype 4.3)
#include <tunables/global>
/usr/bin/skype {
#include <abstractions/base>
#include <abstractions/user-tmp>
#include <abstractions/audio>
#include <abstractions/nameservice>
#include <abstractions/ssl_certs>
#include <abstractions/fonts>
#include <abstractions/ibus>
#include <abstractions/dbus>
@daurnimator
daurnimator / main.c
Created June 1, 2015 04:17
Linux fork detection using thread specific keyrings.
$ gcc main.c -lkeyutils && ./a.out
15904 1
15904 0
15904 0
15904 0
15905 1
15906 1
15905 0
15906 0
15907 1
@Mygod
Mygod / iperf.sh
Last active November 30, 2019 22:18 — forked from madeye/iperf.sh
Bandwidth test for shadowsocks
#!/bin/bash
number=$1
method=$2
ss-tunnel -k test -m $method -l 8387 -L 127.0.0.1:8388 -s 127.0.0.1 -p 8389 &
ss_tunnel_pid=$!
ss-server -k test -m $method -s 127.0.0.1 -p 8389 &
ss_server_pid=$!
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
@hitsumabushi
hitsumabushi / default
Last active September 21, 2020 09:12
Preseed Files : working with Wheezy & Ubuntu 14.04
# D-I config version 2.0
default debian/7.4/amd64/boot-screens/vesamenu.c32
prompt 1
timeout 300
menu title - Boop Menu -
label Debian-7.4
menu label ^0 Debian 7.4
#include debian/7.4/amd64/boot-screens/menu.cfg
kernel debian/7.4/amd64/linux
@kachayev
kachayev / barber.erl
Last active November 6, 2020 03:44
Solve "Sleeping Barber Problem" with Erlang (more about problem - http://en.wikipedia.org/wiki/Sleeping_barber_problem)
-module(barber).
-export([run/2, barber/1, clients/1, simulator/2]).
-define(CUT_DUTAION, 20).
run(RoomSize, Duration) ->
% create barber
BPid = spawn(?MODULE, barber, [?CUT_DUTAION]),
% run simulartor with barber PID
SPid = spawn(?MODULE, simulator, [BPid, RoomSize]),
@chrisklaiber
chrisklaiber / SimpleHTTPServer6.py
Created February 15, 2018 16:16
Python SimpleHTTPServer over IPv6. Run as `python -m SimpleHTTPServer6 [PORT]`
import BaseHTTPServer
import SimpleHTTPServer
import socket
class HTTPServer6(BaseHTTPServer.HTTPServer):
address_family = socket.AF_INET6
if __name__ == '__main__':
@waylybaye
waylybaye / index.js
Last active March 10, 2022 11:09
Send Notification using Telegram when new IAP is purchased
const functions = require('firebase-functions');
const TelegramBot = require('node-telegram-bot-api');
const token = "***"
const chatID = 1024 // your telegram id, you must first send a message to your bot
exports.notifyIAP = functions.analytics.event('in_app_purchase').onLog((event) => {
const purchaseValue = event.valueInUSD;
if (purchaseValue > 0) {
const bot = new TelegramBot(token, {polling: false});