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 red = "\e[31m#{self}\e[0m" | |
def cyan = "\e[36m#{self}\e[0m" | |
end | |
if defined? Rails | |
project_name = File.basename(Dir.pwd).cyan | |
envrionment = ENV['RAILS_ENV'].red | |
prompt = "(#{project_name}) -> [#{envrionment}]" |
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
# frozen_string_literal: true | |
if Rails.env.development? | |
ActiveSupport::Reloader.to_prepare do | |
module OpenOnVim | |
def open_method(method_name) | |
file, line = method(method_name.to_sym).source_location | |
vim(file, line) | |
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
package main | |
import ( | |
"context" | |
"encoding/json" | |
"errors" | |
"fmt" | |
"net/http" | |
"os" | |
"path/filepath" |
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" | |
"time" | |
) | |
func main() { | |
today := time.Now() | |
future := today.AddDate(0, 4, 0) |
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
/* | |
Sort a linked list in O(n log n) time using constant space complexity. | |
Example 1: | |
Input: 4->2->1->3 | |
Output: 1->2->3->4 | |
Example 2: |
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
/* | |
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. | |
You may assume the two numbers do not contain any leading zero, except the number 0 itself. | |
Example: | |
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) | |
Output: 7 -> 0 -> 8 | |
Explanation: 342 + 465 = 807. |
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 hashtable | |
type Key interface { | |
HashCode() int | |
Equals(Key) bool | |
} | |
type entry struct { | |
hashCode int | |
key Key |
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
def Ok(value) | |
Okay.new(value) | |
end | |
def Err(value) | |
Error.new(value) | |
end | |
class Result | |
attr_reader :value |
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 bfs | |
import "fmt" | |
type City struct { | |
Name string | |
Population uint32 | |
neighbors []Node | |
} |
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
=begin | |
In this problem you will write a function called populate_template which will take in a template string e.g. " Hello {!first_name} - How are you?" and a hash of fields e.g { "first_name" : "John" } as arguments and will return the template string with the fields inserted in the correct place. | |
The usecase for a function like this would be for instance for answer templates to be used by a support team at a company. | |
So in the previous example you would get: | |
populate_template("Hello {!first_name} - How are you?", {"first_name" => "John"}) | |
and you would get: |
NewerOlder