Skip to content

Instantly share code, notes, and snippets.

View Arunscape's full-sized avatar
🦀

Arun Woosaree Arunscape

🦀
View GitHub Profile
@Arunscape
Arunscape / main.lisp
Created June 8, 2020 04:32
CommonLisp recursive functions
(defun factorial (n &optional (acc 1))
(if (= n 0)
acc
(factorial (- n 1) (* n acc))
)
)
(factorial 5)
(defun fibonacci (n &optional (a 0) (b 1))
@Arunscape
Arunscape / parser.py
Created November 22, 2019 18:34
naive recursive descent parser (doesn't fully work but if I ever work on a parser again, I want to refer to this)
#! /usr/bin/env python3
from dataclasses import dataclass
from typing import List
import re
"""
alphanumeric ::= [0-9a-zA-Z_-]
numeric ::= [0-9]
#!/usr/bin/python3
import re
completeWords = [
'closely',
'believe',
'accept',
'myths',
'way',
'explained',
@Arunscape
Arunscape / Dockerfile
Last active May 19, 2020 06:30
react dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
# production stage
FROM nginx:stable-alpine as production-stage
@Arunscape
Arunscape / gist:942d2a892e428e91b5137278ebf615e9
Created January 23, 2019 02:25
Build and push image to Dockerhub
REPO_NAME=XXXXXXXXX
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# build the docker image and push to an image repository
docker build -t $REPO_NAME .
docker tag $REPO_NAME $DOCKER_USERNAME/$REPO_NAME
docker push $DOCKER_USERNAME/$REPO_NAME
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
# production stage
FROM nginx:stable-alpine as production-stage
FROM alpine:latest
EXPOSE 80
# using react here only to test
RUN apk update && apk add yarn
RUN yarn
ENV PATH="$PATH:/opt/yarn-[version]/bin"
@Arunscape
Arunscape / rank_mirrors.sh
Created August 30, 2018 20:12
rank pacman mirrors
sudo pacman -S pacman-contrib
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bakup
curl https://www.archlinux.org/mirrorlist/all/https/ | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 6 - > /etc/pacman.d/mirrorlist
@Arunscape
Arunscape / asyncwaterfall.js
Last active August 10, 2018 19:38
async.waterfall example
async.waterfall([
callback=>{
console.log('this is the first function')
callback(null, 'input from step 1')
}
,
(val, callback)=>{
console.log('this is the 2nd function')