Skip to content

Instantly share code, notes, and snippets.

View hoahm's full-sized avatar

Hoa Hoang hoahm

View GitHub Profile
@xigang
xigang / sort_time.go
Created May 4, 2017 04:04
Sorting by time.Time in Golang
package main
import (
"fmt"
"sort"
"time"
)
type reviews_data struct {
review_id string
@tixastronauta
tixastronauta / facebook_leads.md
Last active July 22, 2024 05:23
Receiving Facebook Leads on a Webhook
@epintos
epintos / [Jenkins] Build Execute Shell
Last active March 12, 2018 13:38
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
#!/bin/bash +x
set -e
# Remove unnecessary files
echo -e "\033[34mRemoving unnecessary files...\033[0m"
rm -f log/*.log &> /dev/null || true &> /dev/null
rm -rf public/uploads/* &> /dev/null || true &> /dev/null
# Build Project
echo -e "\033[34mBuilding Project...\033[0m"
@tamoyal
tamoyal / gist:2ea1fcdf99c819b4e07d
Last active February 13, 2020 11:24
Upgrade Postgres 9.3 to 9.4 on Ubuntu
# Be sure to save your config files. Optional but I do:
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~
# Package repo (for apt-get)
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Also probably optional but I like to update sources and upgrade
sudo apt-get update
@henrik
henrik / using_string_range.rb
Last active July 12, 2019 08:18
Is a given time in a time range, in Ruby?
# Note: upper bound is 12:01:59 (you could use second precision to get around this, e.g. "12:01:00")
time = Time.mktime(2014, 10, 14, 12, 1)
allowed_ranges = [
"11:59".."12:01",
]
formatted_time = time.strftime("%H:%M")
p allowed_ranges.any? { |range| range.cover?(formatted_time) }
@Pi7z4
Pi7z4 / compile_and_install_phalcon_mamp.md
Created April 26, 2014 19:19
Compile and Install Phalcon for MAMP

Find the path to your MAMP php bin directory. This is usually located within the MAMP folder in Applications:

	/Applications/MAMP/bin/php/phpx.x.x/bin

Open Terminal and export the PHP bin path:

	export PATH=/Applications/MAMP/bin/php/phpx.x.x/bin:$PATH
@pkuczynski
pkuczynski / parse_yaml.sh
Last active July 9, 2024 04:42
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@jch
jch / yard-mount.rb
Created July 2, 2012 18:17
mount yard documentation at /docs
# 1) Running a raw RackAdapter in config.ru mounted at '/' works fine
require 'bundler/setup'
require 'yard'
run YARD::Server::RackAdapter.new(
{'surfiki' => [YARD::Server::LibraryVersion.new('surfiki', nil, File.expand_path('../.yardoc', __FILE__))]},
{
:single_library => true,
:caching => false
})