Skip to content

Instantly share code, notes, and snippets.

[{"name":"Khoa"},{"name":"Minh"}]
@khoa-le
khoa-le / products.json
Last active July 4, 2019 04:09
product_json
This file has been truncated, but you can view the full file.
[{"id":478,"sku":"8061254-1-CZ-WG","name":"D\u00e2y chuy\u1ec1n v\u00e0ng Moonshine","attribute_set_id":9,"price":0,"status":1,"visibility":4,"type_id":"configurable","created_at":"2018-02-06 20:34:59","updated_at":"2019-03-25 05:34:11","weight":0.0014,"extension_attributes":{"website_ids":[1],"category_links":[{"position":1,"category_id":"568"},{"position":1,"category_id":"569"},{"position":1,"category_id":"578"},{"position":1,"category_id":"571"},{"position":1,"category_id":"573"},{"position":1,"category_id":"585"},{"position":1,"category_id":"610"},{"position":0,"category_id":"1282"},{"position":0,"category_id":"1305"},{"position":0,"category_id":"1307"},{"position":1,"category_id":"1124"}],"configurable_product_options":[{"id":581,"attribute_id":"137","label":"Size","position":0,"values":[{"value_index":62},{"value_index":63}],"product_id":478}],"configurable_product_links":[476,477]},"product_links":[{"sku":"8061254-1-CZ-WG","link_type":"related","linked_product_sku":"8060500-CZ-WG","linked_product_type"

Backing up redis rdb file is simply copy .rdb to your backup location. So, we have to choose any safe destination that we'd like to store the snapshot file (It is usually safer to transfer to a different server or disk). But, let's figure out where the current RDB file is located

cat /etc/redis/redis.conf |grep '^dir '|cut -d' ' -f2

On my box, /var/lib/redis is the directory where the snapshot file is dumped to. Before copying, it is good idea to save the db in background.

redis-cli bgsave Then copy it to somewhere that is safe. (The path /backup/redis is just an illustration of where it could be copied to)

cp /var/lib/redis/dump.rdb /backup/redis/dump.$(date +%Y%m%d%H%M).rdb

curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar -xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure && make && sudo make install
# brew install 'https://raw.github.com/simonair/homebrew-dupes/e5177ef4fc82ae5246842e5a544124722c9e975b/ab.rb'
# brew test ab
curl -O https://archive.apache.org/dist/httpd/httpd-2.4.2.tar.bz2
tar zxvf httpd-2.4.2.tar.bz2
@khoa-le
khoa-le / config.yml
Created January 10, 2017 02:37
Config redis cluster with snc redis
default:
type: predis
alias: default
dsn:
- '%redis_dns%'
- '%redis_dns1%'
- '%redis_dns2%'
options:
cluster: redis
prefix: "em-management-default:"
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
alias ll="ls -lhA"
alias mkdir="mkdir -p"
alias histg="history | grep"
@khoa-le
khoa-le / bash_alias_mac.sh
Last active September 26, 2016 05:54
bash alias for Mac
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
alias ll="ls -lhA"
alias mkdir="mkdir -p"
alias histg="history | grep"
@khoa-le
khoa-le / gist:ad61d7334dc7295c665666de6e6553a2
Created September 22, 2016 10:24 — forked from ctavan/gist:4482825
Init-script for optionally starting multiple redis instances on the same host running Ubunut/Debian. Highly inspired by the memcached init script that comes with the Ubuntu package. This is useful since redis is single-threaded.
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@khoa-le
khoa-le / immutable-obj-array.js
Last active August 25, 2016 09:10
immutable object or array in javascript
//Merge nested object
var a={1:{id:"3"},2:{id:"4"}};
var index=3;
//want to build merge object
//{1:{id:"3"},2:{id:"4"},3:{id:"5"}};
var b= Object.assign({},a,{[index]:{id:"5"}})
//Override value of a elment array
var a=['2','3','4'];
var index=2;
@khoa-le
khoa-le / deploy.rb
Created June 6, 2016 15:38
Deploy symfony application config with Capifony
# Deployment server info
set :application, "Your Project"
set :domain, "your-domain"
set :deploy_to, "/www/deploy/your-domain"
set :app_path, "app"
set :web_path, "web"
set :maintenance_basename, "maintenance"
set :scm, :git
set :repository, "[email protected]:username/repos.git"