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 January 9, 2025 08:17
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 / LICENSE
Last active March 14, 2025 14:12
Read YAML file from Bash script
MIT License
Copyright (c) 2014 Piotr Kuczynski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR
@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
})