This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "tokenie/version" | |
require 'securerandom' | |
module Tokenie | |
# Generates a friendly string randomically | |
def self.friendly(options = {}) | |
length = options[:length] || 6 | |
raise ArgumentError, "'length' must be in range (2..16)" if length < 2 || length > 16 | |
loop do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$package_list = [ | |
# nginx | |
"nginx", | |
# mysql | |
"mysql-server","mysql-client", | |
# postgresql-9.1 | |
"postgresql-9.1", "postgresql-client-9.1","postgresql-contrib-9.1", "postgresql-server-dev-9.1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Settings in here override those in "Default/Preferences.sublime-settings", | |
// and are overridden in turn by file type specific settings. | |
{ | |
"font_face": "Courier New", | |
"font_size": 10, | |
"ignored_packages": [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/hoisie/redis" | |
"strconv" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
local http=require("socket.http"); | |
local request_body = [[login=user&password=123]] | |
local response_body = {} | |
local res, code, response_headers = http.request{ | |
url = "http://httpbin.org/post", | |
method = "POST", | |
headers = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
def pp(env) | |
env.map {|key, value| "#{key} => #{value}"}.sort.join("<br/>") | |
end | |
Rack::Handler::WEBrick.run lambda {|env| [200, {"Content-type" => "text/html"}, [pp(env)]]}, :Port => 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/astaxie/beego/orm" | |
_ "github.com/go-sql-driver/mysql" | |
) | |
type Post struct { | |
Id int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Post struct { | |
Id int `field:"id"` | |
Title string `field:"title"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/astaxie/beego/orm" | |
_ "github.com/go-sql-driver/mysql" | |
) | |
type Post struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def snake_case | |
return downcase if match(/\A[A-Z]+\z/) | |
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). | |
gsub(/([a-z])([A-Z])/, '\1_\2'). | |
downcase | |
end | |
end |