View notes
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
_ |
View minstack.go
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
// leetcode min stack | |
// https://leetcode.com/problems/min-stack/ | |
type MinStack struct { | |
stack []int | |
minStack []int | |
} | |
/** initialize your data structure here. */ | |
func Constructor() MinStack { | |
return MinStack{stack: make([]int, 0), minStack: make([]int, 0)} |
View dynamic_reducer.py
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 dynamic_reducer(numbers, operator): | |
result = numbers[0] | |
for i in range(1, len(numbers)): | |
if operator == "+": | |
result += numbers[i] | |
elif operator == "-": | |
result -= numbers[i] | |
elif operator == "*": | |
result *= numbers[i] | |
elif operator == "/": |
View account_test.go
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
func TestGetAccountAPI(t *testing.T) { | |
account := randomAccount() | |
testCases := []struct { | |
name string | |
accountID int64 | |
buildStubs func(store *mockdb.MockStore) | |
checkResponse func(t *testing.T, recorder *httptest.ResponseRecorder) | |
}{ | |
{ |
View account.sql.go
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
// Code generated by sqlc. DO NOT EDIT. | |
// source: account.sql | |
package db | |
import ( | |
"context" | |
) | |
const createAccount = `-- name: CreateAccount :one |
View main.go
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" | |
func main() { | |
x := make([]int, 0, 5) | |
x = append(x, 1, 2, 3, 4) | |
fmt.Println("x:", x) // [1 2 3 4] | |
fmt.Printf("x's length: %d\nx's capacity: %d", len(x), cap(x)) // x's length: 4 x's capacity: 5 |
View index.html
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
<html> | |
<body> | |
<h1>CatPhotoApp</h1> | |
<main> | |
<h2>Cat Photos</h2> | |
<!-- TODO: Add link to cat photos --> | |
<p> | |
Click here to view more | |
<a target="_blank" href="https://freecatphotoapp.com">cat photos</a>. | |
</p> |
View reverse_int.py
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 reverse_int(my_num): | |
convert_to_list = str(my_num).split(' ') | |
rev_positive_int = '' | |
str_abs = '' | |
if(my_num <= 0): | |
reversed_value = '' | |
for i in convert_to_list: | |
abs_num = abs(int(i)) | |
str_abs += str(abs_num) |
View olympic_medal.rb
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 | |
# OlympicMedal is class that represents an olympic medal | |
class OlympicMedal | |
# <, <=, >=, >, ==, !=, <=>, .between? | |
include Comparable | |
MEDAL_VALUES = { Gold: 3, Silver: 2, Bronze: 1 }.freeze | |
attr_reader :type |
View pry-output
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 console | |
Running via Spring preloader in process 16338 | |
Loading development environment (Rails 6.1.4.6) | |
[1] pry(main)> help | |
Help | |
help Show a list of commands or information about a specific command. | |
Context | |
cd Move into a new context (object or scope). | |
find-method Recursively search for a method within a class/module or the current namespace. |
NewerOlder