Skip to content

Instantly share code, notes, and snippets.

@saggiyogesh
saggiyogesh / MEMOIZE.md
Created April 20, 2021 18:27 — forked from mrousavy/MEMOIZE.md
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia
@saggiyogesh
saggiyogesh / build.sh
Created July 24, 2020 19:47 — forked from dzlab/build.sh
Configure NGINX to log HTTP POST request's body
#!/bin/bash
echo "Building NGINX along with Echo module"
# install prerequisites
yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel
# download the Echo module
curl -L -O 'https://github.com/openresty/echo-nginx-module/archive/v0.58.tar.gz'
tar -xzvf v0.58.tar.gz && rm v0.58.tar.gz
mv echo-nginx-module-0.58 /tmp/echo-nginx-module
@saggiyogesh
saggiyogesh / extensions.tsx
Created October 15, 2019 06:41
vscode extensions lists
Bracket Pair Colorizer
Clipboard History
Code Spell Checker
ESLint
Import Cost
@saggiyogesh
saggiyogesh / cleanup.sh
Created September 5, 2019 10:56 — forked from superseb/cleanup.sh
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
@saggiyogesh
saggiyogesh / bash.sh
Created August 25, 2019 15:28
Bash script to increment no in file name
#!/usr/bin/env bash
set -e
# find existing version of static.zip
cd ios;
name=$(ls | grep static)
echo 'grep name: '$name
@saggiyogesh
saggiyogesh / remove-null.js
Created September 7, 2018 06:21
Remove null, undefined from doc in mongodb. [Terminal code]
function getNullKeysRecursively(doc, keyName, nullKeys) {
for (var item_property in doc) {
// SKIP BASE-CLASS STUFF
if (!doc.hasOwnProperty(item_property)) continue;
// SKIP ID FIELD
if (item_property === '_id') continue;
// FULL KEY NAME (FOR SUB-DOCUMENTS)
var fullKeyName;
if (keyName) fullKeyName = keyName + '.' + item_property;
@saggiyogesh
saggiyogesh / code-push-rn-ios.md
Created August 9, 2018 13:46
Commands for code push RN IOS
  • Add an app to code-push code-push app add myiosapp ios react-native

    Copy the Production deployment key. Use this key when asked in terminal after doing react-native link code-push

  • Release a build for ios. code-push release-react myiosapp ios

  • Promote the build to production. code-push promote myiosapp Staging Production

@saggiyogesh
saggiyogesh / parse.js
Last active April 25, 2018 10:58
Parsing custom objects in JSON.parse in javascript
// This script is executed in mongo shell to replace all occurence of a STRING, with an objectId string
// and then using parse, converting objectId string to actual objectId
db.Dummy.find({}).forEach(function(doc) {
console.log(doc._id);
let newDoc = JSON.stringify(doc).replace('STRING', '5ab23ff3423159ad5d0251c0');
print('newDoc', newDoc);
let jsonDoc = JSON.parse(newDoc, (key, value) => {
if (value === '5ab23ff3423159ad5d0251c0') {
@saggiyogesh
saggiyogesh / portainer.sh
Created October 30, 2017 08:10
portainer
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart always portainer/portainer -H unix:///var/run/docker.sock