Skip to content

Instantly share code, notes, and snippets.

@arvinsim
arvinsim / get_git_remote_origins
Created March 3, 2015 05:41
A hacky script to get the remote origins of the git repositories of in the current directory
import os
import subprocess
import re
currentdir = os.getcwd()
filename = currentdir + "/git_submodule_commands.sh"
pattern = re.compile("(?P<push_url>Push\s+URL):\s+(?P<url>https.*)")
# Check if file exists. If it does, delete it.
if os.path.isfile(filename):
@arvinsim
arvinsim / factorial.hs
Last active August 29, 2015 14:16
A simple factorial function in Haskell
factorial :: Integer -> Integer
factorial i
| i <= 0 = 1
| otherwise = i * factorial(i-1)
main = do
-- 120
print (factorial 5)
@arvinsim
arvinsim / keyboard shortcuts
Last active August 29, 2015 14:17
Keyboard shortcuts for my machines
// Terminator
Control + Shift + e = split Horizontally
Control + Shift + o = split Vertically
Control + Shift + t = open new tab
Control + Shift + i = open new window
Control + Shift + w = close terminal
Control + Shift + q = close window
Control + Shift + g = reset and clear the terminal
Alt + any directional button = focus on terminal depending on direction
@arvinsim
arvinsim / pngchecker.py
Created March 17, 2015 01:55
Check if a file is valid PNG
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
from PIL import Image
# Get filename from arguments
parser = argparse.ArgumentParser(description='get arguments')
It's best to be honest with yourself and come to terms with where you are in life and where you want to be. After that, unless you put action into your belief, you will be sad. Even if you fail, but put action into the belief, you'll be happy and have grown.
There is nothing noble in being superior to your fellow man; true nobility is being superior to your former self.
Hemingway
If your life sucks, make it better. No one will do it for you. Period.
“It’s only on the brink that people find the will to change. Only at the precipice do we evolve.”
reply
@arvinsim
arvinsim / flatten.js
Created March 6, 2017 08:21
Code to flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
// NodeJS
const assert = require('assert');
/**
* Flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
* e.g. [[1,2,[3]],4] -> [1,2,3,4].
*
* @name flatten
* @param {Array} arr An array to flatten, nested or otherwise
* @returns {Array} the flattened array
@arvinsim
arvinsim / keybindings.json
Last active April 13, 2017 07:21
Visual Studio Code Keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+k cmd+p",
"command": "python.execInTerminal",
"when": "editorTextFocus"
}
]
@arvinsim
arvinsim / dark_hacker_new_solarized_custom.css
Created October 12, 2017 00:11
Dark Hacker News - Solarized Custom
* {
color: #93A1A1 !important;
background-color: #002b36 !important;
}
body > center > table > tbody > tr:first-child * {
background-color: #073642 !important;
}
body > center > table > tbody > tr:first-child * a:hover {
background: #002b36 !important;
}
@arvinsim
arvinsim / mockigLink.tsx
Created May 31, 2022 08:57
Mocking <Link> components in NextJS
@arvinsim
arvinsim / common-react-testing-library-statements.tsx
Last active January 4, 2023 01:38
Common React Testing Library features
// Setup user events
const user = userEvent.setup()
// Clicking on an element. Using await is important
await user.click(screen.getTextBy('Some button'))
// Output HTML of screen
screen.debug()