Skip to content

Instantly share code, notes, and snippets.

@WNut42
WNut42 / ruby.2.6.3-setup.sh
Created June 23, 2019 14:28 — forked from mustafaturan/ruby.2.6.3-setup.sh
ruby 2.6.3 setup for centos 6.x
#!/usr/bin/env bash
# repository
cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
# system update
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
@WNut42
WNut42 / loop_queue.go
Last active March 18, 2018 17:12
use Go implement loop-queue
// 循环队列的实现
package main
import (
"fmt"
)
const MAXSIZE = 10
@WNut42
WNut42 / tmux-cheatsheet.markdown
Created November 27, 2016 12:34 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
#!/usr/bin/env ruby
# From my blog post at http://www.postal-code.com/binarycode/2009/06/06/better-range-intersection-in-ruby/
class Range
def intersection(other)
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
my_min, my_max = first, exclude_end? ? max : last
other_min, other_max = other.first, other.exclude_end? ? other.max : other.last
@WNut42
WNut42 / string.rb
Created January 23, 2014 02:10
String#[]的一个用法
string = 'hello world'
result = $& if string =~ /hell/
# 可以替换为:
result = string[/hell/]
result = $2 if string =~ /(\w+)\s(\w+)/
# 可以替换为:
result = string[/(\w+)\s(\w+)/, 2]
@WNut42
WNut42 / binary_search.rb
Created January 8, 2014 09:28
binary search
#
# 实现简单的二分查找(递归):
#
# 给定一个数和有序数组,返回该数在数组中的下标
#
class BinarySearch
attr_accessor :origin_array
@WNut42
WNut42 / simple_irb
Created January 8, 2014 09:26
simple irb
#!/usr/bin/env ruby
top = binding
loop do
p eval(gets, top)
end
@WNut42
WNut42 / book.rb
Created December 25, 2013 02:53
ActiveRecord代码规范
class Book < ActiveRecord::Base
# extends ...................................................................
# includes ..................................................................
# security (i.e. attr_accessible) ...........................................
# relationships .............................................................
# validations ...............................................................
# callbacks .................................................................
# scopes ....................................................................
# additional config .........................................................
# class methods .............................................................
@WNut42
WNut42 / gist:6191401
Created August 9, 2013 05:36
geminabox with http basic auth 1
require "rubygems"
require "geminabox"
Geminabox.data = "/var/geminabox-data" # …or wherever
use Rack::Auth::Basic, "GemInAbox" do |username, password|
'your massively secure password' == password
end
run Geminabox