Skip to content

Instantly share code, notes, and snippets.

Working from home

James u007

Working from home
View GitHub Profile
u007 / multerconfig.js
Last active Oct 12, 2021
multer s3 contentType fix
View multerconfig.js
import stream from 'stream';
const mime = require('mime-types');
import aws from 'aws-sdk';
import multer from 'multer';
import multerS3 from 'multer-s3';
storage: multerS3({
u007 / api_category_config_schema.graphql
Last active Feb 6, 2021
strapi graphql with nested field
View api_category_config_schema.graphql
const { find2 } = require('../controllers/category')
module.exports = {
definition: `
type Category2 {
id: ID!
created_at: DateTime!
updated_at: DateTime!
Title: String
Icon: String
u007 /
Last active May 26, 2020
resizing /tmp cpanel centos 7 on linode

goto linode dashboard > node

1st, setting > shutdown watchdog > disable

second, boot into rescue mode

disclaimer: i'm not responsible for any problems with your system (but you may contact me)

mkdir /mnt/r
u007 / somefunction.js
Created Jun 26, 2019
firebase function get current logged in user
View somefunction.js
const auth: any = context.auth || {}
if (!auth || !auth.uid) {
//not logged in
let authUser = await admin.auth().getUser(auth.uid)
u007 / source.js
Last active Mar 19, 2019
mongodb stitch function for database trigger to save updated_at and created_at
View source.js
exports = function(changeEvent) {
console.log("changed", changeEvent.operationType, JSON.stringify(Object.keys(changeEvent)))
//allows replace and create
if(changeEvent.operationType == "update") {
let keys = Object.keys(changeEvent.updateDescription.updatedFields)
console.log("changed", JSON.stringify(Object.keys(changeEvent.updateDescription.updatedFields)))
if(keys.indexOf('created_at') > -1 || keys.indexOf('updated_at') > -1 || keys.length == 0) {
//changed fields contains created_at or updated_at
// on $set, it will trigger "update"
console.log("ignoring change")
u007 / .eslintrc.js
Created Mar 13, 2019
nuxt + typescript + prettier
View .eslintrc.js
module.exports = {
root: true,
env: {
browser: true,
node: true
parser: 'vue-eslint-parser',
parserOptions: {
'parser': '@typescript-eslint/parser',
'ecmaVersion': 2017,
u007 / docker-compose.yml
Created Jan 25, 2019
docker-compose for logrotate
View docker-compose.yml
version: "3.2"
image: blacklabelops/logrotate
restart: unless-stopped
- "/home/yourpathtolog:/log"
- "./logrotate-status:/logrotate-status"
u007 / docker-comose.yml
Created Nov 25, 2018
dgraph docker compose
View docker-comose.yml
version: "3.2"
image: dgraph/dgraph:v1.0.10
- "./dgraph0:/dgraph"
- 5080:5080
- 6080:6080
restart: on-failure
u007 /
Last active Aug 7, 2019
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 / slicepointer_reflect.go
Last active Oct 15, 2018
golang setting pointer slice with reflect
View slicepointer_reflect.go
package main
import (
type X struct {
Name string
Values *[]Y