Skip to content

Instantly share code, notes, and snippets.

@ywjno
ywjno / shuang_se_qiu.rb
Created July 18, 2012 09:19
create shuang_se_qiu number
#encoding: utf-8
class ShuangSeQiu
def initialize
@times = ARGV && ARGV[0] ? ARGV[0].to_i : 5
end
def create
@times.times do |time|
reds = []
@ywjno
ywjno / gist:3310835
Created August 10, 2012 03:43
create card_no and password(10 numbers)
# encoding: utf-8
require 'openssl'
require 'base64'
require 'sequel'
DB = Sequel.connect('sqlite://cardinfo.sqlite3')
class CardInfo < Sequel::Model
plugin :schema
@ywjno
ywjno / add_default_work_in_rails.sh
Last active October 9, 2015 14:48
add default work in rails 4.x
#!/bin/sh
tee -a Gemfile << EOF
gem 'bootstrap-sass', '~> 3.1.1'
gem 'settingslogic'
gem 'simple_form'
gem 'slim-rails'
group :development do
@ywjno
ywjno / _navbar.html.slim
Created October 8, 2012 08:14
navbar with bootstrap
.navbar.navbar-fixed-top.navbar-inverse
.navbar-inner
.container-fluid
a.btn.btn-navbar data-toggle="collapse" data-target=".nav-collapse"
span.icon-bar
span.icon-bar
span.icon-bar
a.brand href="#{root_url}" project_name
.nav-collapse
ul.nav
@ywjno
ywjno / init-ubuntu-with-shell.sh
Created November 6, 2012 03:56
init ubuntu with shell
#!/bin/bash
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install python-software-properties -y
# add git
sudo apt-add-repository ppa:git-core/ppa -y
# add nodejs
@ywjno
ywjno / Rakefile
Created December 24, 2012 03:17
set system envs by ruby shell
# encoding: utf-8
require 'rubygems'
configs = {
'envs' =>
{'RUBY_HOME' => 'ruby_home_path', 'JRUBY_HOME' => 'jruby_home_path', 'JAVA_HOME' => 'java_home_path'},
'add_path_env' =>
{'RUBY_HOME' => 'bin', 'JRUBY_HOME' => 'bin', 'JAVA_HOME' => 'bin'}
}
@ywjno
ywjno / Paginate.java
Last active December 17, 2015 09:39
about paginate by java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Paginate {
private static final int DEFALUT_SHOW_PAGE_COUNT = 5;
public static List<Map<String, String>> paginate(String pageSizeStr, String pageCdStr) {
int pageSize = Integer.valueOf(pageSizeStr);
@ywjno
ywjno / get_sublime_package_metadata.rb
Created May 28, 2013 02:48
get instelled package infomation form %SUBLIME_TEXT%/Data/Packages folder
# encoding: utf-8
require "find"
require 'json'
jsons = []
Dir.foreach(Dir.pwd) do |dir|
real_path = File.expand_path dir
unless real_path == Dir.pwd
if File.exist?(real_path + '/package-metadata.json')
@ywjno
ywjno / gist:5733829
Created June 8, 2013 03:03
mou app manual
# Mou
![Mou icon](http://mouapp.com/Mou_128.png)
## Overview
**Mou**, the missing Markdown editor for *web developers*.
### Syntax
@ywjno
ywjno / ruby_install.sh
Created October 4, 2013 14:43
install ruby by uesd ruby-install
#!/usr/bin/env bash
wget -O ruby-install-0.3.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.3.0.tar.gz --no-check-certificate
tar -xzvf ruby-install-0.3.0.tar.gz
cd ruby-install-0.3.0/
sudo make install
sudo ruby-install -i /usr/local/ ruby
gem install chef ruby-shadow librarian-chef --no-ri --no-rdoc