Skip to content

Instantly share code, notes, and snippets.

View lissdy's full-sized avatar

lissdy lissdy

  • Microsoft
  • China
View GitHub Profile
package main
import (
"encoding/base64"
"io/ioutil"
"os"
)
func main() {
fileR, _ := ioutil.ReadFile("/Users/XXX/Downloads/content.txt")
@lissdy
lissdy / go_request.go
Last active January 9, 2024 11:57
Golang send multiple requests
package main
import (
"net/http"
"fmt"
"time"
"sync"
)
func main() {
@lissdy
lissdy / routes_csv.rake
Created August 7, 2018 06:31
Export rails routes to csv
namespace :routes do
desc 'Print out all defined routes in CSV format.'
task :csv => :environment do
class CSVFormatter
def initialize
@buffer = []
end
def result
@lissdy
lissdy / gist:f7cdacd00d096a0ee068c00aeadb9304
Last active December 17, 2017 14:38
CodeWar: Sum of Digits / Digital Root
function digital_root(n) {
if (n < 10)
return n;
return digital_root(n.toString().split('').reduce(function(acc, d) {
return acc + + d;
}, 0));;
}
console.log(digital_root(233412))
@lissdy
lissdy / Snake to Camel in Ruby
Created June 19, 2017 05:12
Snake to Camel in Ruby
module SnakeCamel
def to_camel
self.gsub(/(?:\b|_)([a-z])/) { Regexp.last_match(1).upcase }
end
end
class String
include SnakeCamel
end
@lissdy
lissdy / regular expression匹配月份的正则表达式
Last active August 19, 2016 00:43
匹配月份的正则表达式
https://www.codewars.com/kata/validdate-regex/solutions?show-solutions=1
https://www.codewars.com/kata/548db0bd1df5bbf29b0000b7/solutions/javascript
Description:
Your task is to write a regular expression (regex) that will match a string only if it contains at least one valid date, in the format [mm-dd] (that is, a two-digit month, followed by a dash, followed by a two-digit date, surrounded by square brackets).
You should assume the year in question is not a leap year. Therefore, the number of days each month should have are as follows:
Rails.application.paths["app/models"].each{|model_path|
Dir["#{Rails.root}/#{model_path}/*/*.rb"].each { |file| require file }
}
models = ActiveRecord::Base.send(:subclasses)