Skip to content

Instantly share code, notes, and snippets.

View schovi's full-sized avatar
👁️

David Schovanec schovi

👁️
View GitHub Profile
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@natritmeyer
natritmeyer / mount_smbfs.sh
Created September 19, 2013 09:40
How to mount and unmount a SMB share on Mac OS X (using mount_smbfs)
#Mounting the share is a 2 stage process:
# 1. Create a directory that will be the mount point
# 2. Mount the share to that directory
#Create the mount point:
mkdir share_name
#Mount the share:
mount_smbfs //username:password@server.name/share_name share_name/
@echarles
echarles / gist:5813448
Created June 19, 2013 10:53
List of ElasticSearch REST commands (retrieved from source code with grep)
DELETE
DELETE _template/{name}
DELETE {index}
DELETE {index}/_alias/{name}
DELETE {index}/_query
DELETE {index}/_warmer
DELETE {index}/_warmer/{name}
DELETE {index}/{type}
DELETE {index}/{type}/_mapping
DELETE {index}/{type}/_query
@puffnfresh
puffnfresh / objectunion.js
Last active December 12, 2015 02:28
Creation of unions, with automatic value constructors and an automatic fold encoding.
// Boilerplate
function objectUnion(definer) {
var defined = 0, length = 0, isDefined = false, definitions, key;
definitions = definer(function() {
var names = arguments, fold;
if(isDefined) {
throw new TypeError('This objectUnion has already been defined');
}
function Ctor() {}
@puffnfresh
puffnfresh / valueobject.js
Created February 2, 2013 20:07
Automatic creation of constructors.
// TODO: Automatically create a useful isEqual function.
function valueObject() {
var names = arguments;
function wrapped() {
var o = this instanceof wrapped ? this : {}, i;
if(arguments.length != names.length) {
throw new TypeError("Expected " + names.length + " arguments, got " + arguments.length);
}
for(i = 0; i < names.length; i++) {
o[names[i]] = arguments[i];
@schovi
schovi / gist:665326
Created November 6, 2010 10:19
Rail3 friendly pagination
# If you are using ActiveRecord and want to paginate it you have to write this:
# PeacefulPaginate.use_for_active_record!
# to end of your config/environment.rb
# If you want to override default .paginate method from WillPaginate gem you have to insert this
# PeacefulPaginate.use_compatible_mod_with_will_paginate!
# to end of your config/environment.rb
# With this you dont have to rewrite nothing else in your application
# In other way how to use it