Skip to content

Instantly share code, notes, and snippets.

@arvinsim
arvinsim / .ideavimrc
Created March 27, 2023 06:17
Change Jetbrains IDE AceJump default if you are using IdeaVim
// https://github.com/acejump/AceJump
// https://stackoverflow.com/questions/46719530/how-do-i-tell-intellij-ideavim-to-re-source-the-ideavimrc
// IdeaVim users can choose to activate AceJump with a single keystroke (f, F and g are arbitrary) by running:
echo -e '
" Press `f` to activate AceJump
map f <Action>(AceAction)
" Press `F` to activate Target Mode
@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()
@arvinsim
arvinsim / mockigLink.tsx
Created May 31, 2022 08:57
Mocking <Link> components in NextJS
@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 / 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 / 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
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 / 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')
@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 / 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)