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 / multerconfig.js
Last active October 12, 2021 07:05
multer s3 contentType fix
import stream from 'stream';
const mime = require('mime-types');
import aws from 'aws-sdk';
import multer from 'multer';
import multerS3 from 'multer-s3';
multer({
//...,
storage: multerS3({
@u007
u007 / api_category_config_schema.graphql
Last active February 6, 2021 13:53
strapi graphql with nested field
const { find2 } = require('../controllers/category')
module.exports = {
definition: `
type Category2 {
id: ID!
created_at: DateTime!
updated_at: DateTime!
Title: String
Icon: String
@u007
u007 / README.md
Last active May 26, 2020 17:18
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
u007 / somefunction.js
Created June 26, 2019 09:08
firebase function get current logged in user
const auth: any = context.auth || {}
if (!auth || !auth.uid) {
//not logged in
}
let authUser = await admin.auth().getUser(auth.uid)
@u007
u007 / source.js
Last active March 19, 2019 15:07
mongodb stitch function for database trigger to save updated_at and created_at
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
u007 / .eslintrc.js
Created March 13, 2019 09:36
nuxt + typescript + prettier
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parser: 'vue-eslint-parser',
parserOptions: {
'parser': '@typescript-eslint/parser',
'ecmaVersion': 2017,
@u007
u007 / docker-compose.yml
Created January 25, 2019 12:23
docker-compose for logrotate
version: "3.2"
services:
logrotate:
image: blacklabelops/logrotate
restart: unless-stopped
volumes:
- "/home/yourpathtolog:/log"
- "./logrotate-status:/logrotate-status"
environment:
- "LOGS_DIRECTORIES=/log"
@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
@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 / 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