Skip to content

Instantly share code, notes, and snippets.

View Eric-Guo's full-sized avatar

Eric Guo Eric-Guo

View GitHub Profile
diff --git a/ext/bluecloth.h b/ext/bluecloth.h
index 230618b..97053b5 100644
--- a/ext/bluecloth.h
+++ b/ext/bluecloth.h
@@ -7,20 +7,21 @@
#ifndef BLUECLOTH_H
#define BLUECLOTH_H
+#include "ruby.h"
+
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@Eric-Guo
Eric-Guo / git
Created March 24, 2012 12:44 — forked from cdwilson/git
ubuntu apache config for git virtual host - /etc/apache2/conf.d/git
# http://computercamp.cdwilson.us/git-gitolite-git-daemon-gitweb-setup-on-ubunt
<VirtualHost *:80>
ServerName git.server
ServerAdmin webmaster@git.server
DocumentRoot /usr/share/gitweb
<Directory /usr/share/gitweb>
Options FollowSymLinks ExecCGI
AddHandler cgi-script cgi
RewriteEngine On
@Eric-Guo
Eric-Guo / sqlite2pg.sh
Created August 5, 2012 05:46 — forked from eclubb/sqlite2pg.sh
Script to import SQLite3 database into PostgreSQL
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
@Eric-Guo
Eric-Guo / mod_hosts
Created December 16, 2012 09:42
Modify live Linux CD hosts on fly
#!/bin/bash
echo "127.0.0.1 rstudio.cloud-mes.com" >> /etc/hosts
wget -q -O - http://smarthosts.googlecode.com/svn/trunk/hosts >> /etc/hosts
@Eric-Guo
Eric-Guo / gist:4647361
Created January 27, 2013 08:23
ruby-prof double free or corruption about by hello
eric@cvprcsip01:~$ gem list ruby-prof
*** LOCAL GEMS ***
ruby-prof (0.12.1)
eric@cvprcsip01:~$ cat hello.rb
puts "hello ruby-prof!"
eric@cvprcsip01:~$ ruby --version
ruby 1.9.3p374 (2013-01-15 revision 38858) [i686-linux]
@Eric-Guo
Eric-Guo / nginx
Created February 8, 2016 07:58 — forked from vdel26/nginx
Openresty init.d script
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
config.ignore_if do |exception, options|
# use beginning to prevent non unique keys (they include object ids and such)
key = exception.message.split("for").first[0..30]
ExpirableKey.new(key).exist_with_renew
end
@Eric-Guo
Eric-Guo / add_chinese_text_to_picture.rb
Created March 13, 2017 12:28
Using MiniMagick to add text to a picture
# encoding: utf-8
require 'mini_magick'
image = MiniMagick::Image.open('origin.jpg')
image.combine_options do |c|
c.font '/Library/Fonts/Songti.ttc'
c.pointsize 28
c.gravity 'Center'
c.pointsize '22'
c.draw "text 3,3 'Ruby语言'"
c.fill 'red'