Skip to content

Instantly share code, notes, and snippets.

View xgdgsc's full-sized avatar

xgdgsc

  • Beijing,China
  • 17:23 (UTC +08:00)
View GitHub Profile
@senko
senko / onchange.sh
Last active July 14, 2023 07:54
OnChange - Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@groundwater
groundwater / asynchbase.scala
Created April 20, 2012 17:47
Demo Adapting asynchbase to Scala
package ca.underflow.hbase
import org.hbase.async._
import com.stumbleupon.async._
object Demo extends App {
// This let's us pass inline functions to the deferred
// object returned by most asynchbase methods
@jgarzik
jgarzik / boostgz.cc
Created May 17, 2012 04:03
Append a line of text to a gzip-compressed text file.
/*
Compile on Fedora 16 Linux:
g++ -O2 -Wall -g -o boostgz boostgz.cc -lboost_iostreams-mt
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iostream>
@yamaya
yamaya / xcode-clang-vers
Last active April 3, 2024 02:28
Xcode clang version record
# Xcode 4.3.3
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
# Xcode 4.3.2
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 1, 2024 03:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tshort
tshort / julia_type.md
Created October 4, 2012 18:58
Convert a string to a Julia type
@aponxi
aponxi / sql-mongo_comparison.md
Last active February 21, 2024 11:56
MongoDb Cheat Sheets

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

@xgdgsc
xgdgsc / punzip.py
Last active December 4, 2022 11:33
python script to extract zip with GBK encoding
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# file: unzip.py
import zipfile,os,sys
if len(sys.argv)==2:
fname=sys.argv[1]
else:
print "Usage: python %s filename\n\n" % sys.argv[0]
sys.exit()
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 15, 2024 11:26
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@claws
claws / authentication.py
Last active July 24, 2021 19:37
An authentication module for pyzmq based on zauth from czmq. See the included test file for usage. To run the test function use: python test_authentication.py
'''
An authentication module for pyzmq modelled on zauth from czmq.
The functions to read and generate certificates should be interoperable
with czmq's zcert's - though are not as fully featured.
'''
import datetime
import glob
import json