Skip to content

Instantly share code, notes, and snippets.

View madhums's full-sized avatar

madhums madhums

View GitHub Profile
@madhums
madhums / graphql-go-mongodb-example.go
Created May 6, 2019 20:47 — forked from trunet/graphql-go-mongodb-example.go
Minimal example of GraphQL Golang and MongoDB playing nicely together. Edit
// Embedded in this article https://medium.com/p/c98e491015b6
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
@madhums
madhums / browserify_for_webpack_users.markdown
Created October 22, 2015 13:06
browserify for webpack users

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

@madhums
madhums / AngularJS-ES6-Test-Skeleton
Last active June 30, 2017 19:37 — forked from busypeoples/AngularJS-ES6-Test-Skeleton
AngularJS - Karma, Jasmine, Browserify, Stringify - ES6 Test Setup
We couldn’t find that file to show.
@madhums
madhums / gulpfile.js
Created July 18, 2015 12:11 — forked from danharper/gulpfile.js
ES6 project with Babel, Browserify & Gulp
'use strict';
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
mongoose.connect('localhost', 'testing_1088');
mongoose.connection.on('error', function () {
@madhums
madhums / gist:4135481
Created November 23, 2012 12:52 — forked from cjohansen/gist:4135065
Naming this in nested functions

tl;dr

If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.

In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.

Naming this in nested functions

I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.

Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.

@madhums
madhums / promises.md
Created October 24, 2012 09:15 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
@madhums
madhums / gh-like.css
Created October 6, 2012 03:26 — forked from robsimmons/gh-like.css
GitHub-esque syntax highlight CSS
/*
Some simple Github-like styles, with syntax highlighting CSS via Pygments.
*/
body{
font-family: helvetica, arial, freesans, clean, sans-serif;
color: #333;
background-color: #fff;
border: none;
line-height: 1.5;
margin: 2em 3em;
@madhums
madhums / gist:3311709
Created August 10, 2012 06:21
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@madhums
madhums / express-pagination.js
Created July 23, 2012 00:23 — forked from xjamundx/express-pagination.js
sample pagination using express route-specific middleware
// articles per page
var limit = 10;
// pagination middleware function sets some
// local view variables that any view can use
function pagination(req, res, next) {
var page = parseInt(req.params.page) || 1,
num = page * limit;
db.articles.count(function(err, total) {
res.local("total", total);