Skip to content

Instantly share code, notes, and snippets.

Avatar

jhjguxin jhjguxin

View GitHub Profile
View puppeteer.md
@jhjguxin
jhjguxin / ringbuffer.rb
Created Oct 29, 2018 — forked from eerohele/ringbuffer.rb
A simple ring buffer for Ruby.
View ringbuffer.rb
class RingBuffer < Array
attr_reader :max_size
def initialize(max_size, enum = nil)
@max_size = max_size
enum.each { |e| self << e } if enum
end
def <<(el)
if self.size < @max_size || @max_size.nil?
@jhjguxin
jhjguxin / unicorn.rb
Created Sep 8, 2016 — forked from ak47/unicorn.rb
force figaro ENV vars to reload on unicorn USR2 restarts
View unicorn.rb
root = "/var/www/cake/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.stderr.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.cake.sock"
worker_processes 2
timeout 15
@jhjguxin
jhjguxin / gist:b359d96e8c2452d8a6cd18678c0e8440
Last active Apr 20, 2016
make a Virtual Router (soft wifi host ap) Ubuntu 15
View gist:b359d96e8c2452d8a6cd18678c0e8440
```sh
#/bin/bash!
# sudo apt-get install hostapd
# git clone https://github.com/oblique/create_ap.git && cd create_ap
# sudo make install
iwconfig
sudo create_ap wlp3s0 enp4s0f0 francis-ubuntu aaabbbccc123
```
@jhjguxin
jhjguxin / gist:942131cc6795cbf98ceb
Created Jan 26, 2016 — forked from donnierayjones/LICENSE
Render Bootstrap as "small" layout when printing
View gist:942131cc6795cbf98ceb
@media print {
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
float: left;
}
.col-sm-12 {
width: 100%;
}
.col-sm-11 {
width: 91.66666667%;
}
@jhjguxin
jhjguxin / number_to_chinese_amount_in_words_helper.rb
Created Jan 11, 2016
NumberToCapitalZh 数字转成中文大写金额
View number_to_chinese_amount_in_words_helper.rb
module NumberToChineseAmountInWordsHelper
# Formats a +number+ into a chinese amount in words(e.g., 壹万元整).
#
# === Examples
# number_to_capital_zh(10001.00) # => '壹万元整',
# number_to_capital_zh(100000.10) # => '壹拾万元壹角整',
# number_to_capital_zh(0.1) # => '壹角整',
# number_to_capital_zh(1.11) # => '壹元壹角壹分',
# number_to_capital_zh(1.01) # => '壹元零壹分',
# number_to_capital_zh(0.01) # => '壹分',
@jhjguxin
jhjguxin / linebreak.rb
Created Oct 27, 2015 — forked from niallsmart/linebreak.rb
Axlsx line break
View linebreak.rb
require 'axlsx'
Axlsx::Package.new do |package|
workbook = package.workbook
workbook.add_worksheet do |sheet|
wrap = workbook.styles.add_style alignment: {wrap_text: true}
sheet.add_row ["Foo\r\nBar", "Foo\rBar", "Foo\nBar", "Foo\n\r\nBar"], style: wrap
end
package.serialize "linebreak.xlsx"
@jhjguxin
jhjguxin / deploy.rb
Last active May 10, 2019
use qiniu to speed up your site asset file load time
View deploy.rb
set :linked_files, %W{
... config/app.god config/qrsync.json
config/application.yml
}
# you should remove bin from linked_dirs config
# https://github.com/capistrano/bundler/issues/45
set :linked_dirs, %w{config/unicorn log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
@jhjguxin
jhjguxin / install_mysql_5_5_centos.md
Last active Sep 27, 2017
Install MySQL Database 5.5.37 on CentOS 6.5/5.10, Red Hat (RHEL) 6.5/5.10
View install_mysql_5_5_centos.md

Install MySQL Database 5.5.37 on CentOS 6.5/5.10, Red Hat (RHEL) 6.5/5.10

1.change user

su

2.Install Remi repository

@jhjguxin
jhjguxin / remote_debug_android_chrome_on_linux.md
Last active Aug 29, 2015
remote debug mobile web page on linux through chrome
View remote_debug_android_chrome_on_linux.md
chrome://inspect/#devices
localhost:8999

chrome://flags/#enable-devtools-experiments

http://www.html5rocks.com/en/tutorials/developertools/revolutions2013/?redirect_from_locale=zh
adb forward tcp:8999 localabstract:chrome_devtools_remote

http://stackoverflow.com/questions/3877027/jquery-callback-on-image-load-even-when-the-image-is-cached