Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Saleeba tomsaleeba

View GitHub Profile
@inadarei
inadarei / base64.js
Created Jan 6, 2013
base64 encode/decode in Node.js
View base64.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@Gomah
Gomah / Dockerfile
Last active Mar 23, 2021
Nuxt.js Dockerfile :: Now.sh
View Dockerfile
FROM node:10-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN yarn install
View deoplete.init.vim
" Tiny init.vim for deoplete
" vim-plug
set runtimepath+=$XDG_CONFIG_HOME/nvim/plugged/deoplete.nvim
set completeopt+=noinsert,noselect
set completeopt-=preview
hi Pmenu gui=NONE guifg=#c5c8c6 guibg=#373b41
hi PmenuSel gui=reverse guifg=#c5c8c6 guibg=#373b41
View map-reduce-example.groovy
// Groovy map-reduce example
// declare a closure
def half = { it ->
it / 2
}
// declare another closure
def sum = { result, i ->
result + i
@phuesler
phuesler / netcat_tcp_server.sh
Last active Apr 21, 2022
Simple tcp server using netcat
View netcat_tcp_server.sh
#!/bin/bash
# Simple tcp server using netcat
# - depending on the netcat version either use nc -l 5555 or nc -l -p 5555
# - verify with `telnet locahhost 5555`
# - quit the telnet with `ctrl-]` and then type quit
# - the while loop is there so reopen the port after a client has disconnected
# - supports only one client at a time
PORT=5555;
while :; do nc -l -p $PORT | tee output.log; sleep 1; done
@cmlenz
cmlenz / babel.config.js
Created Apr 2, 2022
Add babel-plugin-transform-import-meta plugin in test environment only
View babel.config.js
const test = process.env.NODE_ENV === 'test';
module.exports = {
plugins: [
...(test ? ['babel-plugin-transform-import-meta'] : [])
]
};
@hanayashiki
hanayashiki / patch-arrayBuffer.js
Created Dec 16, 2019
Safari 13.0.4: Blob.arrayBuffer is not a function
View patch-arrayBuffer.js
(function () {
File.prototype.arrayBuffer = File.prototype.arrayBuffer || myArrayBuffer;
Blob.prototype.arrayBuffer = Blob.prototype.arrayBuffer || myArrayBuffer;
function myArrayBuffer() {
// this: File or Blob
return new Promise((resolve) => {
let fr = new FileReader();
fr.onload = () => {
resolve(fr.result);
@iktakahiro
iktakahiro / server4spa.py
Last active Sep 17, 2022
Python3 http.server for Single Page Application
View server4spa.py
#!/usr/bin/env python
# Inspired by https://gist.github.com/jtangelder/e445e9a7f5e31c220be6
# Python3 http.server for Single Page Application
import urllib.parse
import http.server
import socketserver
import re
from pathlib import Path
@championofblocks
championofblocks / wav-mp3
Last active Sep 21, 2022
Command line bash to convert all wav to mp3
View wav-mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done
@vancluever
vancluever / amifind.sh
Created Jan 26, 2016
Find the most recent Ubuntu AMI using aws-cli (or any other AMI for that matter)
View amifind.sh
#!/bin/sh
# Use AWS CLI to get the most recent version of an AMI that
# matches certain criteria. Has obvious uses. Made possible via
# --query, --output text, and the fact that RFC3339 datetime
# fields are easily sortable.
export AWS_DEFAULT_REGION=us-east-1
aws ec2 describe-images \