Skip to content

Instantly share code, notes, and snippets.

View ball6847's full-sized avatar
🎯
Focusing

Porawit Poboonma ball6847

🎯
Focusing
  • 7 Peaks Software Co., Ltd.
  • Bangkok, Thailand
View GitHub Profile
@narate
narate / ffplay-voov.sh
Created January 16, 2018 17:43
FFPLAY VOOV LIVE
#!/bin/bash
# Usage :
# ./ffplay-voov.sh 'http://www.voovlive.com/voov-web/share/index?room_id=200327322&anchor_id=601157725&lang=en&video_id=100990185'
M3U8=$(echo $1 | python -c 'import sys,re;print("http://5430.liveplay.myqcloud.com/voov/5430%s.m3u8"%re.match(".*video_id=(\d+)",sys.stdin.read()).groups()[0])')
ffplay $M3U8
@slavafomin
slavafomin / 0-README.md
Last active March 15, 2023 13:35
Angular 2 match other field validator / Password match validator

Angular 2 match other field validator

This custom validator for Angular 4 allows you to have fields that must be equal to some other fields. Such validator is very useful for password confirmation validation, for example.

Besides checking if two values are matching, it also subscribes to changes from other control and re-validates when either of two controls is updated.

Usage

# Here's how to back up a named volume
# 1. Using a `ubuntu` image, we mount the named volume (`myproj_dbdata`) to a `/dbdata` folder inside the `ubuntu` container.
# 2. Then, we create a new folder inside the `ubuntu` container named `/backup`.
# 3. We then create an archive containing the contents of the `/dbdata` folder and we store it inside the `/backup` folder (inside the container).
# 4. We also mount the `/backup` folder from the container to the docker host (your local machine) in a folder named `/backups` inside the current directory.
docker run --rm -v myproj_dbdata:/dbdata -v $(pwd)/backups:/backup ubuntu tar cvf /backup/db_data_"$(date '+%y-%m-%d')".tar /dbdata
# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
if [ -f "$NVM_DIR/bash_completion" ]; then
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
//+---------------------------------------------------------------------+
//| Blessing 3 v3.9.6.09 |
//| February 09, 2014 |
//| Copyright ?2007-2011, J Talon LLC/FiFtHeLeMeNt |
//| In no event will authors be liable for any damages whatsoever. |
//| Use at your own risk. |
//| |
//| This EA is dedicated to Mike McKeough, a member of the Blessing |
//| Development Group, who passed away on Saturday, 31st July 2010. |
@narate
narate / pretty_xml.py
Last active January 22, 2016 15:20
Pretty XML string
#!/usr/bin/env python
import sys
import xml.dom.minidom
data = sys.stdin.read()
xml = xml.dom.minidom.parseString(data)
print xml.toprettyxml(indent=" ", newl="")
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@touhonoob
touhonoob / gs.nginx.conf
Created June 6, 2015 13:35
Nginx as Google Cloud Storage Cache
# Cache 10GB for 1 Month
proxy_cache_path /var/cache/nginx keys_zone=GS:10m inactive=720h max_size=10240m;
upstream gs {
server 'storage.googleapis.com:80';
keepalive 100;
}
server {
set $my_domain "yourdomain.com";
@freshjones
freshjones / gist:b0713263033df8cc9f44
Created February 5, 2015 23:18
bash script to monitor and do something with docker events
#!/bin/sh
docker events --filter 'event=start' --filter 'event=stop' | while read event
do
container_id=`echo $event | sed 's/.*Z\ \(.*\):\ .*/\1/'`
echo $container_id
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.