Skip to content

Instantly share code, notes, and snippets.

@hoangmy92
hoangmy92 / centos7-node8.sh
Last active November 30, 2017 08:41
Install NodeJS v8 on Centos 7
# Unregister repo
sudo rm -fv /etc/yum.repos.d/nodesource*
# Clear cache
sudo yum clean all
sudo rm -rf /var/cache/yum
# Add new repo
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
@hoangmy92
hoangmy92 / enum.sql
Created July 26, 2017 06:36 — forked from d11wtq/enum.sql
Renaming an ENUM label in PostgreSQL
/*
Assuming you have an enum type like this.
You want to rename 'pending' to 'lodged'
*/
CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled');
BEGIN;
ALTER TYPE dispute_status ADD VALUE 'lodged';
UPDATE dispute SET status = 'lodged' WHERE status = 'pending';
@hoangmy92
hoangmy92 / ar_migrate.rb
Created March 3, 2017 04:41 — forked from icyleaf/ar_migrate.rb
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
Black 0;30 Dark Gray 1;30
Red 0;31 Light Red 1;31
Green 0;32 Light Green 1;32
Brown/Orange 0;33 Yellow 1;33
Blue 0;34 Light Blue 1;34
Purple 0;35 Light Purple 1;35
Cyan 0;36 Light Cyan 1;36
Light Gray 0;37 White 1;37
=========
I get the same error message when I run docker.
It is solved by adding myself to the user group 'docker'
Try to run the following command to add yourself to the group
usermod -aG docker ${USER}
Or you can run the following command to find out what groups you belong to
groups $USER
https://github.com/docker/compose/issues/1214
@hoangmy92
hoangmy92 / using_meld_on_mac.md
Created November 20, 2016 18:28 — forked from p1nox/using_meld_on_mac.md
Using meld on Mac

Using Meld merging tool on Mac

  1. Install XQuartz

  2. Install meld with brew

     brew install meld
    
  3. Copy PYTHONPATH

@hoangmy92
hoangmy92 / gist:0ec2bd892e21049692aec10221de7586
Created November 19, 2016 09:02 — forked from Amitesh/gist:1160428
Paperclip file name cleanup or rename
#http://blog.wyeworks.com/2009/7/13/paperclip-file-rename
Paperclip.interpolates :default_image_type do |attachment, style|
attachment.instance.get_user_default_profile_image
end
Paperclip.interpolates :normalized_avatar_file_name do |attachment, style|
attachment.instance.normalized_avatar_file_name
end
@hoangmy92
hoangmy92 / yaml_to_tsv.rb
Created September 10, 2016 15:47 — forked from amonmoce/yaml_to_tsv.rb
A Ruby code that convert yaml file into tsv file ... like $ruby yaml_to_tsv.rb in_filename.yml out_filename.tsv; Rubocop tested no offense
# Check the output file
if ARGV[1].nil?
print 'Insert the name of your output file (tsv file) '
outname = $stdin.gets.chomp
else
outname = ARGV[1]
end
# Deserialize
require 'yaml'
survey = YAML.load(File.read(ARGV[0]))
# -*- encoding: utf-8 -*-
import re
def convert_bold(content):
raw = bytearray(content)
for m in re.finditer(r"\'\'((?!\'\').)+\'\'", content):
start = m.start()
end = m.end()
@hoangmy92
hoangmy92 / url_slug.php
Created May 26, 2016 07:35 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.