Skip to content

Instantly share code, notes, and snippets.

View RSNara's full-sized avatar

Ramanpreet Nara RSNara

  • Facebook
View GitHub Profile
@RSNara
RSNara / rn-setup.md
Last active June 6, 2018 01:07
How I set up React Native
  1. Install Android Studio
  2. Install Android SDK
  3. Android Emulator
  4. In Android Studio, go to [File] -> [Project Structure] to find the SDK location.
  5. Write SDK location into ANDROID_SDK environment variable.
  6. Download Android NDK from Building React Native from source docs and extract beside the $ANDROID_SDK folder.
  7. Set extracted Android NDK location to ANDROID_NDK environment variable.
  8. Clone React Native.
  9. Create a local.properties file in the React Native repository, as instructed in Building React Native from source docs.
  10. Run android emulator.
@RSNara
RSNara / .spacemacs
Last active October 29, 2017 02:22
My .spacemacs configuration file. It requires that `cj` be setup correctly.
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@RSNara
RSNara / cj
Last active April 10, 2019 09:00
A bash function that I use to create a daily org journal.
#!/bin/bash
function cj() {
JOURNAL_HOME="$HOME/.journal"
FILE="$JOURNAL_HOME/$(date +%Y-%m-%d)".org
mkdir -p "$JOURNAL_HOME"
if [[ ! -f "$FILE" ]]; then
JOURNAL_COUNTER_FILE="$JOURNAL_HOME/.journal-counter"
@RSNara
RSNara / raf-loop.cljs
Created September 1, 2017 16:35
A requestAnimationFrame loop that's useful as a game loop.
(defn raf-loop [func]
(let [stop (atom false)
id (atom nil)]
(reset! id (.requestAnimationFrame js/window
(fn helper [& args]
(when-not @stop
(reset! id (.requestAnimationFrame js/window helper))
(try
(apply func args)
(catch js/Error ex
@RSNara
RSNara / throttle.js
Last active May 10, 2017 20:22
Throttle in JS
function throttle(fn) {
let token = null;
return function thunk() {
if (token) {
return;
}
token = requestAnimationFrame(() => {
token = null;
thunk.apply(this, arguments);
@RSNara
RSNara / debounce.js
Last active August 17, 2017 21:50
An implementation of debounce.
function debounce(fn) {
let token = null;
return function thunk() {
if (token) {
cancelAnimationFrame(token);
}
token = requestAnimationFrame(() => {
token = null;
thunk.apply(this, arguments);
@RSNara
RSNara / adjacent.cljs
Created January 1, 2017 23:34
Silly adjacent implementation.
(defn adjacent [n coll]
(lazy-seq
(if-not (empty? coll)
(loop [i 0
element []
others coll]
(cond
(= i n) (cons element (adjacent n (rest coll)))
(empty? others) (list element)
:else (recur (inc i) (conj element (first others)) (rest others)))))))
@RSNara
RSNara / load-basscss.js
Last active June 14, 2016 02:46
There wasn't any good way of loading Basscss with all of its addons (via lein). This, when injected into index.html, gets the job done.
(() => {
var basscssAddons = [
'responsive-margin', 'responsive-padding', 'forms', 'btn',
'btn-outline', 'btn-primary', 'btn-sizes', 'colors',
'background-colors', 'background-images', 'border-colors', 'darken',
'lighten', 'input-range', 'progress', 'all', 'media-object',
'highlight', 'highlight-dark',
];
function createBasscssAddonLink(addon) {
@RSNara
RSNara / keybase.md
Created May 23, 2016 04:42
keybase.md

Keybase proof

I hereby claim:

  • I am rsnara on github.
  • I am ramanpreet (https://keybase.io/ramanpreet) on keybase.
  • I have a public key ASDsidiMvMNDxCwLYu9ofiegfUVpWmfFgXew3kqBa0mVbQo

To claim this, I am signing this object:

(() => {
const cookie = document.getElementById('bigCookie');
(function loop() {
setTimeout(loop);
cookie.dispatchEvent(new MouseEvent('click', { bubbles: true}));
})();
})();
function itemRatio(item) {