Skip to content

Instantly share code, notes, and snippets.

@madhums
madhums / .zshrc
Last active March 15, 2024 20:42
my zshrc file (using ohmyzsh)
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@madhums
madhums / config.ini
Last active November 22, 2023 12:15
install android sdk on linux (without installing android studio)
# ~/.android/avd/<NAME_OF_AVD>/config.ini
PlayStore.enabled = no
abi.type = x86_64
avd.id = <build>
avd.ini.encoding = UTF-8
avd.name = <build>
disk.cachePartition = yes
disk.cachePartition.size = 66MB
disk.dataPartition.path = <temp>
@madhums
madhums / base64-image-upload.js
Created September 14, 2014 17:37
save base64 encoded image
/*
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674
*/
var fs = require('fs');
// string generated by canvas.toDataURL()
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
// strip off the data: url prefix to get just the base64-encoded bytes
@madhums
madhums / install-android-emulator-brew-macos.md
Last active September 14, 2023 07:07
installing android emulator using cli on a mac

In your command line

brew install android-sdk --cask
sdkmanager "emulator"
sdkmanager "platform-tools"
sdkmanager "system-images;android-26;google_apis;x86_64"
avdmanager create avd -n NAME -k "system-images;android-26;google_apis;x86_64" # the one that you use above
@madhums
madhums / app.js
Created August 3, 2011 20:20
Express settings for node.js
var express = require('express');
var app = express.createServer();
require('./settings').boot(app);
app.dynamicHelpers({
base: function(){
// return the app's mount-point
// so that urls can adjust. For example
// if you run this example /post/add works
@madhums
madhums / Makefile
Created August 5, 2015 20:09
Makefile for golang projects
.PHONY: build doc fmt lint dev test vet godep install bench
PKG_NAME=$(shell basename `pwd`)
install:
go get -t -v ./...
build: vet \
test \
go build -v -o ./bin/$(PKG_NAME)
@madhums
madhums / keystone-magic-link-example.js
Last active June 4, 2023 02:05
An example app using keystonejs and magic-link passport auth using jwt
@madhums
madhums / .babelrc
Last active March 23, 2023 12:44
eslint prettier config
{
"presets": ["next/babel"],
"plugins": []
}
@madhums
madhums / gin_html_render.go
Last active August 18, 2022 07:53
render html templates in gin (go)
// Package GinHTMLRender provides some sugar for gin's template rendering
//
// This work is based on gin contribs multitemplate render https://github.com/gin-gonic/contrib/blob/master/renders/multitemplate
//
// Usage
//
// router := gin.Default()
//
// // Set html render options
// htmlRender := GinHTMLRender.New()
@madhums
madhums / react-native-ecosystem-reading.md
Created February 25, 2020 22:43
react native ecosystem reading

Basically you need to get familiar with the react ecosystem. Here's some that you would be widely using

  • React: Some important concepts here are
  • Redux: I am assuming you already know about this
  • Redux Saga: for async api comms
  • React Native: Pretty much uses the same react, redux stuff except for some new interfaces. Some important things to learn here are