Skip to content

Instantly share code, notes, and snippets.

@raecoo
raecoo / launch.json
Last active June 15, 2019 15:33
TypeScript unittest in VS Code
// Ref: https://medium.com/@RupaniChirag/writing-unit-tests-in-typescript-d4719b8a0a40
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Current File",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
@raecoo
raecoo / deploy.rb
Created June 14, 2019 06:01 — forked from Epigene/deploy.rb
Mina deployment file for rails applications
# Mina Deploy
# ===========
#
# Adapted from Creative deploy stack in Manabalss v4, Mar.2015, updated to support staging on Jun.2015
# On first deploy do: mina setup --verbose
# Then do : mina deploy[initialize] --trace
#
# Usage examples:
# mina deploy[soft,seed,compile] to=staging # deploy task with all options | a simple `mina deploy` will deploy to production
# mina rake[db:seed] # for multi-argument tasks # mina 'rake[payments:refund[arg1\,arg2]]'
@raecoo
raecoo / sha256.scala.md
Created June 13, 2019 05:46 — forked from navicore/sha256.scala.md
sha256 single line function in scala

def sha256Hash(text: String) : String = java.security.MessageDigest.getInstance("SHA-256").digest(text.getBytes()).map(0xFF & ).map { "%02x".format() }.foldLeft(""){_ + _}

def sha256Hash(text: String) : String = String.format("%064x", new java.math.BigInteger(1, java.security.MessageDigest.getInstance("SHA-256").digest(text.getBytes("UTF-8"))))

verify via:

scala> sha256Hash("Rusty is a cowboy!")
@raecoo
raecoo / Backup MySQL to Amazon S3.md
Last active February 10, 2019 08:23 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

# use a shared lock and credits_remaining
@lock = Mutex.new
@credits_remaining = 40
@shopify_url = ENV["SHOPIFY_URL"]
# Sends a request to Shopify, blocking until credits are available
def self.request(method, path, params={})
params[:headers] = {"Content-Type" => "application/json"}
# wait for a credit
# use a shared lock and credits_remaining
@lock = Mutex.new
@credits_remaining = 40
@shopify_url = ENV["SHOPIFY_URL"]
# Sends a request to Shopify, blocking until credits are available
def self.request(method, path, params={})
params[:headers] = {"Content-Type" => "application/json"}
# wait for a credit
@raecoo
raecoo / pg_dump_upgrade.md
Last active January 12, 2019 03:22
How to upgrade the pg_dump version on Amazon AMI
  1. find the target postgrsql version on the page https://yum.postgresql.org/repopackages.php

  2. install the package in server.

    sudo rpm -ivh https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-ami201503-95-9.5-3.noarch.rpm

  3. upgrade the library.

sudo yum install postgresql95

@raecoo
raecoo / checkpoint.py
Last active December 20, 2018 09:33
checkpoint.py
# -*- coding: UTF-8 -*-
import requests
import json
def generate_header(url):
import hashlib
hash_object = hashlib.sha1(url + 'conviva95a')
return {'Authorization': 'Bearer ' + hash_object.hexdigest()}
@raecoo
raecoo / .bash_aliases
Last active December 13, 2018 00:57
Docker Environment
alias dev-docker='docker run --name ubuntu_bash -v /target/projects:/root/projects --rm -i -t ubuntu:16.04 bash'
@raecoo
raecoo / deploy.rb
Created November 15, 2018 13:49 — forked from yanyingwang/deploy.rb
mina+puma+nginx
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
require 'mina/rvm' # for rvm support. (http://rvm.io)
require 'mina/puma'
require 'mina/nginx'
# Basic settings: