Skip to content

Instantly share code, notes, and snippets.

View sogko's full-sized avatar

Hafiz Ismail sogko

View GitHub Profile
@sogko
sogko / log.js
Last active August 29, 2015 14:03
NodeJS datetimestamp-ed logger
/**
* NodeJS logger with datetime stamp just because.
* ===============================================
*
* Hold onto your socks now.
*
* Usage example
* var logger = new (require('./logger'))().log;
* var prefixedLogger = new (require('./logger'))('[PREFIX]').log;
*
var Arango = require('arangojs');
var async = require('async');
var db = Arango.Connection();
var testDate = 1406881769977; // Fri Aug 01 2014 08:29:29 GMT+0000
var dateDelta = 500000;
var data = [];
var edgesData = [];
var createdDocuments = [];
var Arango = require('arangojs');
var async = require('async');
var db = Arango.Connection();
var testDate = 1406881769977; // Fri Aug 01 2014 16:29:29 GMT+0800 (SGT)
var dateDelta = 500000;
var data = [];
var edgesData = [];
var createdDocuments = [];
@sogko
sogko / app.js
Last active November 8, 2022 12:31
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@sogko
sogko / go-list-deps.sh
Created May 1, 2015 11:43
A useful terminal command using `go list` to list (non-standard) dependencies in your package directory
go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
@sogko
sogko / ClickOutsideListener.react.js
Last active January 1, 2018 13:14
A pure ES6-style composable React component that handles clicks outside of a HTML node / React component. (No mixins)
/*
A pure ES6-style composable React component that handles clicks outside of a HTML node.
This is for those who prefers composibility over mixins.
Simply drop-in the event listener component into your React component.
Adapted from: https://github.com/Pomax/react-onclickoutside
*/
var React = require('react');
@sogko
sogko / schema.graphql
Last active October 7, 2015 10:12
hello-world-graphql-part-1 - Schema definition (Shorthand notation)
//
// In GraphQL's type system shorthand notation.
// (See: http://graphql.org/docs/typesystem)
//
type Query {
latestPost: String
}
@sogko
sogko / main.go
Last active August 3, 2016 07:37
hello-world-graphql-part-1 - Schema definition (golang)
package main
import (
"github.com/graphql-go/graphql"
)
var queryType = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"latestPost": &graphql.Field{
@sogko
sogko / main.go
Last active August 3, 2016 07:39
hello-world-graphql-part-1 - Server
package main
import (
"net/http"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql-go-handler"
)
var queryType = graphql.NewObject(graphql.ObjectConfig{
// ...
@sogko
sogko / response.json
Created October 7, 2015 11:16
hello-world-graphql-part-1 - Expected response
{
"data": {
"latestPost": "Hello World!"
}
}