Skip to content

Instantly share code, notes, and snippets.

@cliffwoo
cliffwoo / rmcomment.pl
Created November 17, 2013 09:41
Remove comments and empty lines from source code
#!/usr/bin/perl
undef $/;
$text = <>;
$text =~ s/\/\/[^\n\r]*(\n\r)?//g;
$text =~ s/\/\*+([^*]|\*(?!\/))*\*+\///g;
$text =~ s/\n+/\n/g;

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
require 'date'
author = "Saito"
email = "[email protected]"
date = Date.new(2012, 7, 30)
s = %w{
. . . . . . .
. . o o o . .
. o . . . . .
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package guestbook
import (
"http"
"io"
"os"
@cliffwoo
cliffwoo / 44.go
Created January 12, 2013 02:49 — forked from srid/44.go
// Exercise: Loops and Functions - http://tour.golang.org/#44
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
x, y := 0, 1
return func() int {
x, y = y, x + y
@cliffwoo
cliffwoo / gist:4133499
Created November 23, 2012 00:54
MacOS下修改主机名
#修改主机名
scutil --set HostName $newhostname
#计算机名
scutil --set ComputerName $newcomputername
@cliffwoo
cliffwoo / chat.rb
Created November 14, 2012 01:21 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@cliffwoo
cliffwoo / simple-nginx-webdav.sh
Created November 6, 2012 06:47 — forked from dysinger/simple-nginx-webdav.sh
A simple nginx/webdav setup for use with things like mobile-org
#!/bin/sh
# on ubuntu: need some utils & dev libs
sudo apt-get install apache2-utils openssl libssl-dev libpcre3-dev
# compile nginx
cd /tmp
curl http://nginx.org/download/nginx-0.7.64.tar.gz | tar xz
cd nginx*
./configure --with-http_ssl_module --with-http_dav_module \
@cliffwoo
cliffwoo / nginx.sh
Created November 1, 2012 03:15 — forked from marshluca/nginx.sh
/etc/init.d/nginx
# /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6