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 ( | |
"encoding/base64" | |
"io/ioutil" | |
"os" | |
) | |
func main() { | |
fileR, _ := ioutil.ReadFile("/Users/XXX/Downloads/content.txt") |
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 ( | |
"net/http" | |
"fmt" | |
"time" | |
"sync" | |
) | |
func main() { |
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
namespace :routes do | |
desc 'Print out all defined routes in CSV format.' | |
task :csv => :environment do | |
class CSVFormatter | |
def initialize | |
@buffer = [] | |
end | |
def result |
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
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)) |
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
module SnakeCamel | |
def to_camel | |
self.gsub(/(?:\b|_)([a-z])/) { Regexp.last_match(1).upcase } | |
end | |
end | |
class String | |
include SnakeCamel | |
end |
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
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: |
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
Rails.application.paths["app/models"].each{|model_path| | |
Dir["#{Rails.root}/#{model_path}/*/*.rb"].each { |file| require file } | |
} | |
models = ActiveRecord::Base.send(:subclasses) |