Skip to content

Instantly share code, notes, and snippets.

@hemc4
hemc4 / fetchAndCache.js
Last active February 23, 2024 08:10
Create an in memory cache with ttl. Fetch and serve data from this cache
class InMemoryCache {
constructor() {
this._cache = {};
this._timeouts = {};
}
set(key, value, time) {
if (this._timeouts[key]) {
clearTimeout(this._timeouts[key]);
delete this._timeouts[key];
@hemc4
hemc4 / hugo_deploy_to_gh_pages.sh
Created August 30, 2020 09:33
Hugo github pages deploy
#!/bin/sh
# If a command fails then the deploy stops
set -e
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
# Build the project.
hugo -t mem # if using a theme, replace with `hugo -t <YOURTHEME>`
# Add environment variable NDK_ROOT for cocos2d-x
export NDK_ROOT=/Users/hekumar/game-ex/frmlib/android-ndk-r9d
export PATH=$NDK_ROOT:$PATH
# Add environment variable ANDROID_SDK_ROOT for cocos2d-x
export ANDROID_SDK_ROOT=/Users/hekumar/Library/Android/sdk
export PATH=$ANDROID_SDK_ROOT:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH
# Add environment variable ANT_ROOT for cocos2d-x
@hemc4
hemc4 / .zshrc
Last active February 12, 2020 15:06
.zshrc
ZSH_DISABLE_COMPFIX="true"
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@hemc4
hemc4 / .vimrc
Last active August 24, 2017 09:37
vimrc configuration
"""""""""""""""""
"Vundle
""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=$HOME/.vim/bundle/Vundle.vim
@hemc4
hemc4 / go_get_bitbucket.txt
Created February 17, 2017 07:26
Go get private repo
1 $ git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"
#!/bin/bash
set -e
DISTRIBUTION_ID=E6VHHP64I3KLD
#list all invlaidations
aws cloudfront list-invalidations --distribution-id $DISTRIBUTION_ID
#!/bin/bash
set -e
DISTRIBUTION_ID=E6VHHP64I3KLD
BUCKET_NAME=hemc.io-cdn
# Copy over pages - not static js/img/css/downloads
aws s3 sync --acl "public-read" --sse "AES256" public/ s3://$BUCKET_NAME --exclude 'post'
# Invalidate root page and page listings
@hemc4
hemc4 / build_site.sh
Created February 11, 2017 09:54
hugo npm build
#!/bin/bash
# delete everything in public except .git
find public -path public/.git -prune -o -exec rm -rf {} \; 2> /dev/null
# Build a fresh copy
hugo -v
@hemc4
hemc4 / package.json
Created February 11, 2017 09:52
hugo npm
{
"name": "hemcio",
"version": "1.0.0",
"description": "hemc blog",
"scripts": {
"start": "hugo server -w -v --buildDrafts",
"build": "./build_site.sh",
"deploy": "./deploy_site.sh",
"deploystatus":"./deploystatus.sh"
},