Skip to content

Instantly share code, notes, and snippets.

const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@coreyfarrell
coreyfarrell / npm-clone.sh
Created August 5, 2018 20:26
Script to clone by npm name
#!/bin/sh -e
npmname=$1
destination=/usr/src/npm/$npmname
if test -d $destination; then
echo "$npmname is already cloned into:"
echo " $destination"
exit 0
fi
const markdownIt = require('markdown-it')
const frontMatter = require('front-matter')
const Prism = require('prismjs')
const aliases = {
'js': 'jsx',
'html': 'markup'
}
const highlight = (str, lang) => {
@jfmengels
jfmengels / lodash-fp-documentation.md
Last active February 6, 2024 20:57
Generated docs for Lodash/fp. Help make them better at https://github.com/jfmengels/lodash-fp-docs
@demetriusnunes
demetriusnunes / Component.js
Created December 18, 2015 18:49
Concise component definition for AngularJS 1.x
'use strict';
angular.module('Component', [])
.factory('Component', function () {
return function(bindings, template, linkFn, options) {
var directive = {
scope: parseBindings(bindings),
template: parseTemplate(template),
link: linkFn
@koreno
koreno / README.md
Last active April 1, 2020 10:44
'rebaser' improves on 'git rebase -i' by adding information per commit regarding which files it touched.

Prebase

git-prebase improves on 'git rebase -i' by adding information per commit regarding which files it touched.

  • Each file gets an alpha-numeric identifier at a particular column, a list of which appears below the commit list. (The identifiers wrap around after the 62nd file)
  • Commits can be moved up and down safely (without conflicts) as long as their columns don't clash (they did not touch the same file).

Installation

Add the executable to your path and git will automatically expose it as

@jonathanheron
jonathanheron / gist:5910535ce7d393193311
Last active October 1, 2015 13:43
Installation snippet for Intercom Messenger for the Acquire plan
<!-- Add this just before your closing </body> tag -->
<!-- Replace 'APP_ID' with your app ID -->
<script>
window.intercomSettings = { app_id: 'APP_ID' };
</script>
<!-- Replace 'APP_ID' with your app ID -->
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/APP_ID';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
@jfilip
jfilip / merged_branch_cleanup.rb
Last active February 21, 2016 05:42
Cleanup your local merged branches from a remote repository!
#!/usr/bin/env ruby
class MergedBranchCleanup
attr_reader :remote, :branch
class << self
def run(remote="origin", branch="master")
MergedBranchCleanup.new(remote, branch).start
end
@ericroberts
ericroberts / anagram.js
Last active August 29, 2015 14:17
Doing the anagram exercise from exercism.io
var anagram = function(word) {
return new Anagram(word);
};
function Anagram(word) {
this.matches = matches;
function matches() {
possible_anagrams = retrieveAnagrams(arguments);
return possible_anagrams.filter(function(anagram) {
@dansilivestru
dansilivestru / .bithoundrc
Last active March 25, 2019 12:23
default .bithoundrc file for ignoring project files (modify as needed and commit to the root of your project)
{
"ignore": [
"**/deps/**",
"**/node_modules/**",
"**/thirdparty/**",
"**/third_party/**",
"**/vendor/**",
"**/**-min-**",
"**/**-min.**",
"**/**.min.**",