Skip to content

Instantly share code, notes, and snippets.

@yyscamper
yyscamper / rackhd-install-os-add-more-users-example.json
Last active January 12, 2016 08:41
RackHD Param for Adding Multi Users in OS Bootstrap
{
"name": "Graph.InstallCentOS",
"options": {
"defaults": {
"obmServiceName": "noop-obm-service"
},
"install-os": {
"version": "7.0",
"repo": "{{api.server}}/centos/7/os/x86_64",
"rootPassword": "root",
@yyscamper
yyscamper / setupnat.sh
Last active February 24, 2016 13:53
Setup NAT in RackHD Vagrant
#!/bin/sh
# Reference link: http://www.aboutdebian.com/proxy.htm
INTIF="eth1"
EXTIF="eth0"
/sbin/depmod -a
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
// Copyright 2015, EMC, Inc.
'use strict';
module.exports = {
friendlyName: 'SKU Discovery',
injectableName: 'Graph.SKU.Discovery',
options: {
defaults: {
graphOptions: {
@yyscamper
yyscamper / compact-eslint-airbnb.js
Created March 29, 2017 06:39
Convert ESLint airbnb JavaScript config into single file
'use strict';
var _ = require('lodash');
var airbnb = require('eslint-config-airbnb');
var yaml = require('js-yaml');
function load(filename) {
console.log('load file ' + filename);
return require(filename);
}
@yyscamper
yyscamper / .eslintrc.json
Created March 29, 2017 06:41
ESLint Airbnb Javascript Standard Configuration (Single File Version)
{
"rules": {
"strict": [
"error",
"never"
],
"import/no-unresolved": [
"error",
{
"commonjs": true,
@yyscamper
yyscamper / .eslintrc.yml
Last active March 29, 2017 06:46
ESLint Configuration, based on Airbnb JavaScript Standard, but with some customization
env:
es6: true
node: true
parserOptions:
ecmaFeatures:
experimentalObjectRestSpread: true
generators: false
objectLiteralDuplicateProperties: false
ecmaVersion: 6
sourceType: module
@yyscamper
yyscamper / parseFloat.go
Created August 2, 2017 06:59
An advance ParseFloat for golang, support scientific notation, comma separated number
package main
import (
"fmt"
"math"
"strconv"
"strings"
)
func ParseFloat(str string) (float64, error) {
@yyscamper
yyscamper / geoip.sh
Created December 1, 2017 08:39
Script to Download GeoIP Database for Logstash
TARGET=/root/geoip
wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz -O $TARGET/tmp.tar.gz
tar -xvzf GeoLite2-City.tar.gz -C $TARGET --strip-components 1
rm $TARGET/tmp.tar.gz
@yyscamper
yyscamper / jsonb_rename_keys.sql
Created February 26, 2018 09:07
PostgreSQL: Rename JSONB Keys (Batch Mode)
CREATE OR REPLACE FUNCTION jsonb_rename_keys(
jdata JSONB,
keys TEXT[]
)
RETURNS JSONB AS $$
DECLARE
result JSONB;
len INT;
newkey TEXT;
oldkey TEXT;
@yyscamper
yyscamper / jsonb_remove_keys.sql
Created February 26, 2018 09:49
PostgreSQL: Remove Multiple Keys From JSONB
CREATE OR REPLACE FUNCTION jsonb_remove_keys(
jdata JSONB,
keys TEXT[]
)
RETURNS JSONB AS $$
DECLARE
result JSONB;
len INT;
target TEXT;