Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / _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 / 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 / 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 / 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 / create_getter_setter_methods_for_java.rb
Created July 18, 2012 07:58
create getter setter methods for java, by writing order for this java bean
#encoding: utf-8
require 'find'
class CreateGetterSetterMethodsForJava
def initialize
@work_path = File.dirname(File.expand_path(__FILE__))
if ARGV.length != 0
if File.file?(ARGV[0])
@ywjno
ywjno / gist:3088388
Created July 11, 2012 06:28
Don't output assers logs in Rails 3.2.x
# add this code in config/environments/development.rb
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end