Skip to content

Instantly share code, notes, and snippets.

View rakannimer's full-sized avatar
💭
I may be slow to respond.

Rakan Nimer rakannimer

💭
I may be slow to respond.
View GitHub Profile
@zephraph
zephraph / clean_node_modules.sh
Last active June 13, 2023 13:53
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
@Salakar
Salakar / slotCalc.js
Last active July 9, 2019 15:26
Shard Firebase RTDB by `userId` or any arbitrary string/identifier. Uses a 16 bit cyclic redundancy check to calculate the users shard number based on their user id string. This negates the need for a master instance that maps where users data is stored. See comment below code block for more details.
const lookup = [
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
@hyb175
hyb175 / realmMock.js
Last active August 13, 2023 17:41
Realm Mock for jest
// https://github.com/realm/realm-js/issues/370#issuecomment-270849466
export default class Realm {
constructor(params) {
this.schema = {};
this.callbackList = [];
this.data = {};
this.schemaCallbackList = {};
params.schema.forEach((schema) => {
this.data[schema.name] = {};
});
@rakannimer
rakannimer / add-react-jest-airbnb-linting.sh
Last active August 14, 2018 07:42
Adding react-airbnb styleguide linting to create-react-app
( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add -D "$PKG@latest"; )
yarn add babel-eslint
echo "{
\"parser\": \"babel-eslint\",
\"env\": {
\"browser\": true,
\"node\": true,
\"jest\": true,
},
\"extends\": \"airbnb\",

command

adb shell input keyevent 0

Name

KEYCODE_UNKNOWNI

index

C

var gulp = require('gulp');
var browserify = require('browserify');
var notify = require('gulp-notify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var plumber = require('gulp-plumber');
var less = require('gulp-less');
var csso = require('gulp-csso');
var watch = require('gulp-watch');
var envify = require('envify');
@reu
reu / pub-sub.js
Created April 9, 2013 01:51
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
@hrp
hrp / twitter.json
Created April 4, 2011 00:20
Example JSON response from Twitter streaming API
{
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...",
"truncated": true,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"favorited": false,
"source": "<a href=\"http://twitter.com/\" rel=\"nofollow\">Twitter for iPhone</a>",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "54691802283900928",