Skip to content

Instantly share code, notes, and snippets.

View violetguos's full-sized avatar

Violet Guo violetguos

View GitHub Profile
@violetguos
violetguos / files.md
Created January 26, 2022 03:01
How to Structure Your Machine Learning Code Repository
.
├── README.md
├── data
├── evaluation
├── models
├── notebook
├── requirements.txt
├── results
├── singularity_python.sh
@violetguos
violetguos / pl-1
Last active January 25, 2021 23:45
medium
╔══════════════════╦══════════════════════╗
║ ecosystem ║ number of packages ║
╠══════════════════╬══════════════════════╣
║ Python’s `pip` ║ 235000 ║
║ Ruby’s gem ║ 133000 ║
║ Javascript’s NPM ║ 1m+ ║
╚══════════════════╩══════════════════════╝
@violetguos
violetguos / tic_tac_toe.rb
Created June 15, 2020 18:42
TOP ruby project
class Board
attr_accessor :board_config
def initialize
@board_config = [["_", "_", "_"], ["_", "_", "_"], ["_", "_", "_"]] # 3 by 3
@dim = 3
end
def lookup(coord)
return @board_config[coord[0]][coord[1]]
@violetguos
violetguos / bubble_sort.rb
Created June 11, 2020 19:01
TOP bubble sort assignment
def bubble_sort(arr)
# drop ignores previous sorted elems
arr.each_with_index do |dum, drop_i|
arr.drop(drop_i).each_with_index do |elem, i|
if arr[i+1] != nil && arr[i] > arr[i + 1]
temp = arr[i]
arr[i] = arr[i+1]
arr[i+1] = temp
end
end
def stonk_picker(stonk_arr)
# find the max diff between elements
max_profit = 0
max_idx = [0, 0]
stonk_arr.each_with_index do |buy, buy_idx|
stonk_arr.each_with_index do |sell, sell_idx|
# puts "%d %d" % [buy_idx, sell_idx]
if buy_idx < sell_idx && sell - buy > max_profit
max_idx[0] = buy_idx
max_idx[1] = sell_idx # get original idx
@violetguos
violetguos / substring.rb
Created June 8, 2020 21:00
TOP's ruby project
def substrings(words, dictionary)
result = Hash.new(0)
words = words.split(" ")
dictionary.map do |dict|
words.each do |word|
if word.downcase.include?(dict.downcase)
result[dict] += 1
end
end
end
@violetguos
violetguos / main.rb
Created June 4, 2020 14:27
TOP's ruby project
def caesar_cipher(msg, offset)
msg_arr = []
msg.chars.each do |m_char|
if m_char.match(/[A-Z]/)
# wraps around 26 alphabets, mod 26
msg_arr.push((m_char.ord + offset - 'A'.ord) % 26 + 'A'.ord)
elsif m_char.match(/[a-z]/)
msg_arr.push((m_char.ord + offset - 'a'.ord) % 26 + 'a'.ord)
else
@violetguos
violetguos / arxiv_id_to_name.py
Created April 21, 2020 21:31 — forked from lebrice/arxiv_id_to_name.py
A simple tool to add the name of downloaded paper pdf's in front of the id. Also removes duplicate downloads of the same arxiv paper.
"""A simple tool to add the name of downloaded paper pdf's in front of the id.
(Written by [email protected])
If there are multiple downloads of same paper, replaces the original with the
latest download. This can be useful in a downloads folder filled with copies.
For instance:
"""
import glob
@violetguos
violetguos / a.md
Created January 7, 2020 15:59
how to remove files from GIT LFS
  • apply the --no-blob-protection for all files tracked under .gitattibutes
  • apply --no-blob-protection fot .gitattributes itself
@violetguos
violetguos / algo.tex
Created December 28, 2018 21:25
good pseudo code template in latex
\documentclass{article}
\usepackage{algorithm} % algorithm
\usepackage[noend]{algpseudocode} % algorithm
\usepackage{bm} % bold in math
\usepackage{array} % thick column hline
\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}