Skip to content

Instantly share code, notes, and snippets.

@xyb
xyb / gist:8a9ee3b116dcc51be8f5b65ee0e57df4
Last active November 21, 2021 07:30
post github issue faild
@xyb
xyb / docker-save.sh
Created July 2, 2020 08:06
save docker image to a compressed tar ball
#!/bin/sh
image="$1"
tarfile=$(echo "$image" | sed -e 's:/:--:g' -e 's/$/.tar/')
tgzfile=$(echo "$tarfile" | sed -e 's/$/.gz/')
docker save "$image" -o "$tarfile"
gzip "$tarfile"
echo "$image" saved to "$tgzfile"
@xyb
xyb / sqlite-kv-restful.py
Last active July 1, 2020 04:10 — forked from georgepsarakis/sqlite-kv-restful.py
Simple SQLite-backed key-value storage Rest API. Built with Flask & flask-restful.
#!/usr/bin/env python3
"""
Requirements:
pip install Flask==1.1.2 Flask-RESTful==0.3.8
"""
import os
import sqlite3
from datetime import datetime
def format_local_datetime(dt):
"""Return a string with local timezone representing the date."""
try:
return dt.astimezone().strftime('%Y-%m-%d %H:%M %z')
except (TypeError, ValueError):
# Python 2 do not have builtin timezone
import time
def get_timezone_offset():
@xyb
xyb / cdctool.py
Created February 28, 2020 06:03
A tool help to compare huge files by splitting them into small content-based chunks.
#!/usr/bin/env python3
# Usage: python3 cdctools.py <data_file> [<chunk_size>]
# Usage: MORE_DETAILS=1 python3 cdctools.py <data_file> [<chunk_size>]
import os
import sys
import fastchunking
READ_BUFFER_SIZE = 1024 * 4
@xyb
xyb / pyinstrument_json_to_flamegraph.py
Created October 31, 2019 08:10
Convert github.com/joerick/pyinstrument's json format to flamegraph
#!/usr/bin/env python3
# Author: Xie Yanbo <xieyanbo@gmail.com>
import json
USE_LONG_FILE_PATH = True
def to_flamegraph(pyinst_data):
def walk(data):
@xyb
xyb / cookiemonster.go
Last active February 3, 2019 15:41 — forked from rwifeng/cookiemonster.go
Simple script to extract (encrypted) cookies out of Chrome OS X cookie store. Usage: ./cookiemonster domain.com
package main
import (
"golang.org/x/crypto/pbkdf2"
"crypto/aes"
"crypto/cipher"
"crypto/sha1"
"database/sql"
"fmt"
"log"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Xie Yanbo <xieyanbo@gmail.com>
# Date: 2012-03-21
# see also:
# Unicode Standard Annex #11
# East Asian Width
# http://unicode.org/reports/tr11/
@xyb
xyb / moosefs.rb
Last active July 13, 2016 11:02
Install moosefs on mac osx using homebrew
require "formula"
class Moosefs < Formula
desc "a fault tolerant network distributed file system for petabyte range storage"
homepage "http://moosefs.org/"
url "http://ppa.moosefs.com/src/moosefs-3.0.79-1.tar.gz"
sha256 "f2ddce542c1b2e918060e23e953e220c4a23be982e2bdf214a783f8bac2fb87e"
depends_on "pkg-config" => :build
depends_on "autoconf" => :build
@xyb
xyb / twister.rb
Created July 7, 2016 03:21
Install twister the p2p microblogging software on mac osx using homebrew
require 'formula'
class Twister < Formula
desc "twister is an experimental peer-to-peer microblogging software."
homepage "http://www.twister.net.co/"
url "https://github.com/miguelfreitas/twister-core/archive/v0.9.34.tar.gz"
sha256 "b250508c7d1c72d1d0dcb2377f65199d1af27e3da9a0f4b4277d818304b101bf"
depends_on "autoconf" => :build
depends_on "automake" => :build