Skip to content

Instantly share code, notes, and snippets.

View draveness's full-sized avatar
🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢

Draven draveness

🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢
View GitHub Profile
@draveness
draveness / 1-blogs-serivces-dependency-graph
Last active March 12, 2019 03:04
Mock Interface in Golang
+-------------------------+
| |
| |
+---------------------+ +----->| jekyll |
| | | | |
| | | +-------------------------+
| Service +------+
| |
| +------+ +-------------------------+
+---------------------+ | | |
errors.New("invalid parameter a")
errors.New("invalid parameter b")
errors.New("Record Not Found")
package main
import (
"context"
"errors"
"fmt"
"math/rand"
"time"
)
#line 3 "lex.yy.c"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
@draveness
draveness / podspec
Created December 8, 2018 03:56
podspec
activeDeadlineSeconds <integer>
affinity <Object>
nodeAffinity <Object>
preferredDuringSchedulingIgnoredDuringExecution <[]Object>
preference <Object>
matchExpressions <[]Object>
key <string>
operator <string>
values <[]string>
weight <integer>
@draveness
draveness / zookeeper_cluster_in_docker.yml
Last active November 17, 2017 07:02
zookeeper cluster with docker
version: '3.1'
services:
zoo1:
image: zookeeper
restart: always
hostname: zoo1
volumes:
- ./data/zh1/data:/data
- ./data/zh1/datalog:/datalog
@draveness
draveness / reindex-spotlight-db.sh
Created October 12, 2017 03:41
Reindex Spotlight db. Make files discovery for mdfind.
sudo mdutil -E /
@draveness
draveness / relation_builder.rb
Last active October 7, 2017 15:55
After export all the record from MongoDB, use this to build relation in all records. You need to handle many to many relations by yourself
# frozen_string_literal: true
require 'colorize'
module RelationBuilder
attr_reader :constants
def initialize(constants = [])
if constants.present?
@constants = constants
@draveness
draveness / database_transformer.rb
Last active October 7, 2017 15:08
Export MongoDB collection to ActiveRecord Model directly. Used for MongoId to ActiveRecord migration.
# frozen_string_literal: true
require 'colorize'
module DatabaseTransformer
attr_reader :database
def initialize(database)
@database = database
end
@draveness
draveness / database_transformer.rb
Last active September 29, 2017 08:57
Export MongoDB to csv files and import them into MySQL with mysqldump
module DatabaseTransformer
def self.import(collection, fields, columns)
mongo_export = <<-EOF
mongoexport --host #{hostname} --username #{username} \
--password #{password} \
--authenticationDatabase #{auth_source} \
--db #{database} --collection #{collection} \
--type=csv \
--fields #{fields.join(',')} \
--out #{collection}.csv