Skip to content

Instantly share code, notes, and snippets.

View jiahut's full-sized avatar
🎯
Focusing

zhijia,.zhang jiahut

🎯
Focusing
View GitHub Profile
@rogerleite
rogerleite / install_monaco_font.sh
Last active April 27, 2024 05:27
Install Monaco font in Linux
#!/bin/bash
# Install Monaco font in Linux
# Version from nullvideo https://gist.github.com/rogerleite/99819#gistcomment-2799386
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \
sudo wget https://gist.github.com/rogerleite/b50866eb7f7b5950da01ae8927c5bd61/raw/862b6c9437f534d5899e4e68d60f9bf22f356312/mfont.ttf -O - > \
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \
sudo fc-cache
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@samstokes
samstokes / regex-groups-global.rb
Created November 18, 2009 03:28
How to extract groups from a regex match in Ruby without globals or temporary variables. Code snippets supporting http://blog.samstokes.co.uk/post/251167556/regex-style-in-ruby
if "foo@example.com" =~ /@(.*)/
$1
else
raise "bad email"
end
# => "example.com"
@mechanicker
mechanicker / dky.el
Created December 2, 2010 09:57
emacs customization helper file
;; -*-mode:Emacs-Lisp;buffer-cleanup-p:t;buffer-read-only:t-*-
;; Time-stamp: <2010-09-14 12:13:40 dky>
;;-----------------------------------------------------------------------------
;; Author : Dhruva Krishnamurthy
;; Date : 7th Dec 2000
;; Note : I thank a lot of other people whose code I have used
;;-----------------------------------------------------------------------------
;; Some variable declarations
(defvar buffer-cleanup-p nil
@bakkdoor
bakkdoor / thrift-mode.el
Created January 8, 2011 02:56
Simple thrift mode (taken from https://github.com/kragen/stevej-emacs/blob/master/thrift-mode/thrift.el) and adjusted to highlight self-defined types, unions & namespaces nicely.
(require 'font-lock)
(defvar thrift-mode-hook nil)
(add-to-list 'auto-mode-alist '("\\.thrift\\'" . thrift-mode))
(defvar thrift-indent-level 2
"Defines 2 spaces for thrift indentation.")
;; syntax coloring
@joshski
joshski / example.cakefile
Created April 16, 2011 08:54
My first cakefile
CoffeeScript = require 'coffee-script'
{exec} = require 'child_process'
fs = require 'fs'
SOURCES = [
'app',
'line'
]
task 'features', 'Run the cucumber features (with mininal output)', ->
@progrium
progrium / gist:956006
Created May 4, 2011 20:50
Greenlet exception handling in gevent
import gevent
import gevent.pool
class GroupWithExceptionCatching(gevent.pool.Group):
def __init__(self, *args):
super(GroupWithExceptionCatching, self).__init__(*args)
self._error_handlers = {}
def _wrap_errors(self, func):
"""Wrap a callable for triggering error handlers
@ishaaq
ishaaq / MyUnitTest.java
Created May 6, 2011 04:59
Mockito doAnswer() callbacks
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.testng.Assert;
import org.testng.annotations.Test;
public class MyUnitTest {
int executions;
class ServiceA {
final ServiceB runner;
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@sofish
sofish / Native_FullScreen.js
Created November 10, 2011 09:02
Native FullScreen JavaScript API
/*
Native FullScreen JavaScript API
CopyRight: Johndyer, http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
-------------
Assumes Mozilla naming conventions instead of W3C for now
*/
(function() {
var
fullScreenApi = {
supportsFullScreen: false,