This file contains hidden or 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 ( | |
| "strings" | |
| "fmt" | |
| ) | |
| func WordCount(s string) map[string]int { | |
| words := strings.Fields(s) | |
| counter := map[string]int{} |
This file contains hidden or 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
| # READS A .yml FILE AND FOR EACH KEY IT WILL CREATE A GETTER AND SETTER METHODS | |
| class Flag | |
| def initialize | |
| @yaml = Psych.load_file('config/flags.yml') | |
| @yaml.each_key do |item| | |
| self.class.send(:define_method, item) { @yaml[item] } | |
| self.class.send(:define_method, "#{item}=") { |value| @yaml[item] = value } | |
| end | |
| end | |
| end |
This file contains hidden or 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 TransactionCost < ActiveRecord::Base | |
| belongs_to :company | |
| belongs_to :app | |
| has_many :range_costs | |
| accepts_nested_attributes_for :range_costs, allow_destroy: true, reject_if: lambda { |a| a[:to].blank? && a[:from].blank? && a[:cost].blank? } | |
| validates :app_id, uniqueness: true | |
| validates :range_costs, presence: true |
This file contains hidden or 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 bash | |
| # | |
| # search [file(s)] | |
| # | |
| # This script will read the files passed as parameters and those files | |
| # will contain a list of IPs separated by lines and will search for | |
| # each of those IPs in both omg-switch log files | |
| # | |
| # When no argument is passed, it will open the page on the current branch |
This file contains hidden or 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" | |
| func main() { | |
| id := make(chan string) | |
| go func() { | |
| var counter int64 | |
| for { |
This file contains hidden or 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" | |
| "net/http" | |
| ) | |
| type response struct { | |
| name string | |
| resp *http.Response |
This file contains hidden or 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
| sed -e 's/<KEY>[0-9]\{12\}/(&)/g' -e 's/(<KEY>.*)/<KEY>*************/g' -i blah.log | |
| sed -e 's/<KEYVAL>[0-9]\{12\}/(&)/g' -e 's/(<KEYVAL>.*)/<KEYVAL>*************/g' -i blah.log |
This file contains hidden or 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" | |
| "time" | |
| ) | |
| func main() { | |
| heartbeat := time.Tick(1 * time.Second) | |
| for { |
This file contains hidden or 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" | |
| "net/http" | |
| ) | |
| type work struct { | |
| url string | |
| resp chan *http.Response |
This file contains hidden or 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" | |
| "time" | |
| ) | |
| func main() { | |
| message := make(chan string, 2) // buffer | |
| count := 3 |