Skip to content

Instantly share code, notes, and snippets.

View u007's full-sized avatar
🏠
Working from home

James u007

🏠
Working from home
View GitHub Profile
@u007
u007 / action_signup.go
Last active April 14, 2017 10:11
go buffalo mailer
// actions/action_signup.go //in action handler file
import (
g "project/actions/shared"
"project/models"
"github.com/gobuffalo/buffalo"
// "github.com/pkg/errors"
// "fmt"
"project/actions/mailer/user"
)
@u007
u007 / select2.js
Last active April 6, 2017 16:54
react and select2
//taming select2
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
var input = null
class SelectFieldComponent extends Component {
componentDidMount() {
//UserRoleForm.onRendered()
@u007
u007 / application.js
Last active October 12, 2017 04:30
underscore, moment, jquery in webpack
//underscore
global._ = require('underscore')
//jquery
window.$ = window.jQuery = require("jquery")
//moment
window.moment = require('moment')
@u007
u007 / StaticIframe.js
Last active October 19, 2017 16:24
react and iframe without rerendering
'use strict';
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
var input, wrapper
class StaticIframeComponent extends Component {
constructor(props) {
@u007
u007 / Caddyfile
Last active December 4, 2018 15:41
Caddy vs traefik
www.example.com:80, www.example.com:443 {
tls self_signed
log /logs access.log
errors visible
proxy /assets nginx:80
proxy / web:3000
redir 301 {
if {>X-Forwarded-Proto} is http
/ https://{host}{uri}
@u007
u007 / web
Last active July 9, 2018 11:12
logrotate configuration example
# /etc/logrotate.d/web
# me = my username
# with max of 10MB
/home/me/web/log/production.log {
size 10M
copytruncate
create 0666 me
compress
rotate 4
missingok
@u007
u007 / docker-compose.yml
Last active August 9, 2018 08:05
docker compose for web development
version: "3"
services:
mysql:
image: 'mariadb:10'
ports:
- "3306:3306"
volumes:
- ./mariadb:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD=root"
@u007
u007 / slicepointer_reflect.go
Last active October 15, 2018 09:51
golang setting pointer slice with reflect
package main
import (
"fmt"
"reflect"
)
type X struct {
Name string
Values *[]Y
@u007
u007 / README.md
Last active August 7, 2019 11:23
DGraph Cheatsheet

DGraph Cheat sheet

How it works?

Dgraph is a graph databases. It stores data in a similar fashion for any type of collections. To differentiate the collection list, we may add a predicate, let's say "_type" indicate the type of collection / table. Example: User will have _type='users' and Role will have _type='roles'. ID field in dgraph is named "uid"

@u007
u007 / docker-comose.yml
Created November 25, 2018 09:37
dgraph docker compose
version: "3.2"
services:
dzero:
image: dgraph/dgraph:v1.0.10
volumes:
- "./dgraph0:/dgraph"
ports:
- 5080:5080
- 6080:6080
restart: on-failure