Skip to content

Instantly share code, notes, and snippets.

View tgxworld's full-sized avatar
🇸🇬

Alan Guo Xiang Tan tgxworld

🇸🇬
View GitHub Profile
export default {
"/admin/site_settings": {
"site_settings": [
{
"setting": "adsense_publisher_code",
"description": "Insert your Publisher ID here",
"default": "",
"type": "string",
"value": "",
"category": "adsense_plugin",
# git log --since 03-02-2014 --pretty=format:"%H %ad" > a.txt
require 'byebug'
require 'date'
require 'json'
require 'faraday'
commits = []
File.open('/home/guoxiang/work/ruby/a.txt', 'r').each_line do |line|
GET _count
DELETE _all
PUT organizations
{
"mappings": {
"document": {
"properties": {
"segments": {
"type": "nested"
@tgxworld
tgxworld / output.rb
Last active August 29, 2015 14:20
Benchmarks for indexing documents into ElasticSearch
# 10 indexes
guoxiang@guoxiang-GS60-2PC-Ghost moe $ ruby split_by_types.rb
Cleaning all documents on existing cluster
{"acknowledged":true}
Searching through all indexes and types took 37 ms
Searching through known index and type took 13 ms
Indexing a document into an existing index took 1.182491 ms
guoxiang@guoxiang-GS60-2PC-Ghost moe $ ruby split_by_indexes.rb
Cleaning all documents on existing cluster
{["test.rb", 9, :T_STRING]=>[9, 0, 0, 0, 0, 0],
["test.rb", 9, :T_ARRAY]=>[1, 0, 0, 0, 0, 0],
["test.rb", 9, :T_REGEXP]=>[1, 0, 0, 0, 0, 0]}
-------------------------------------------------
{["test.rb", 13, :T_STRING]=>[5, 0, 0, 0, 0, 0],
["test.rb", 13, :T_REGEXP]=>[1, 0, 0, 0, 0, 0]}
Calculating -------------------------------------
@tgxworld
tgxworld / test.rb
Last active August 29, 2015 14:18
Interpolate Regexp expression.
{
["/home/guoxiang/work/rails-dev-box/rails/actionpack/lib/action_controller/metal/test.rb", 8, :T_ARRAY]=>[1, 0, 0, 0, 0, 0],
["/home/guoxiang/work/rails-dev-box/rails/actionpack/lib/action_controller/metal/test.rb", 8, :T_STRING]=>[6, 0, 0, 0, 0, 0],
["/home/guoxiang/work/rails-dev-box/rails/actionpack/lib/action_controller/metal/test.rb", 8, :T_REGEXP]=>[1, 0, 0, 0, 0, 0]
}
Run options: --seed 4639
# Running:
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
smushing app/favicon-114.png
smush.it: No savings
3296 -> 3296                             = 100%

smushing app/favicon-120.png
smush.it: No savings
3614 -> 3614                             = 100%

smushing app/favicon-144.png
mem_start = `ps -o rss= -p #{$$}`.to_i
# AO render benchmark
# Original program (C) Syoyo Fujita in Javascript (and other languages)
# https://code.google.com/p/aobench/
# Ruby(yarv2llvm) version by Hideki Miura
#
IMAGE_WIDTH = 256
IMAGE_HEIGHT = 256
NSUBSAMPLES = 2
@tgxworld
tgxworld / bm_io_file_read.rb
Created February 2, 2015 05:42
bm_io_file_read_memoy
mem_start = `ps -o rss= -p #{$$}`.to_i
#
# Seek and Read file.
#
require 'tempfile'
max = 200_000
str = "Hello world! " * 1000
f = Tempfile.new('yarv-benchmark')