Skip to content

Instantly share code, notes, and snippets.

View dreamyguy's full-sized avatar
👨‍💻 Code-bending

Wallace Sidhrée dreamyguy

👨‍💻 Code-bending
View GitHub Profile
@brianfeister
brianfeister / attach_heads.js
Created December 15, 2012 13:04
Sub-theming engine for Grunt.js + Roots Theme + Twitter Bootstrap
/**
* Task: attach_heads
* Description: Set the heads for all themes declared in themes.json
*/
module.exports = function(grunt) {
'use strict';
var fs = require('fs');
var path = require('path');
@ilyakatz
ilyakatz / pre-commit
Last active February 22, 2023 14:51
helpful precommit hooks
#!/bin/bash -l
# A git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
#
.git/hooks/pre-commit-master-no-no
if [[ $? == 1 ]]
then
@fernandosavio
fernandosavio / delayedForEach.js
Last active May 30, 2022 06:44
An Array forEach with a delay between steps.
/**
* An array forEach with a delay between steps.
*
* @param {Function} callback Function to execute for each element. It receives three arguments, the element value, the element index and the array being traversed, respectivily.
* @param {Number} timeout Number of milliseconds that the function call should be delayed by.
* @param {Object} thisArg Object to use as this when executing callback.
* @this {Array}
* @return {undefined}
*/
Array.prototype.delayedForEach = function(callback, timeout, thisArg){
@aras-p
aras-p / preprocessor_fun.h
Last active May 28, 2024 05:15
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@Celleb
Celleb / _columnfix.scss
Last active December 23, 2015 08:09
Fixes grid layout problems for zurb foundation 4 for internet explorer 8 and 7
/* zurb foundation 4 grid column fix for ie8 and below */
@mixin columnFix($columns: 12){
$i: 1;
@while $i < $columns + 1 {
$colWidth: ($i/$columns)*100%;
$colWidth7: ($i/$columns)*98%;
& .large-#{$i}, & .small-#{$i} {
width: $colWidth;
*width: $colWidth7; //sets the width for ie7
@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@bobjackman
bobjackman / git-stats
Last active July 12, 2018 13:52
Get a summary of total LOC added, removed, gross line changes, && net total LOC. Credit to (alex)[http://stackoverflow.com/users/887836/alex] modified by (kogi)[http://stackoverflow.com/users/84762/kogi]
#!/usr/bin/env bash
# usage:
# git-stats #gives stats for the whole branch
# git-stats --author="yourname here" #gives stats for specific author
#
# though not all tested, this should be compatible with all limiting options supported by git-log (https://www.kernel.org/pub/software/scm/git/docs/git-log.html#_commit_limiting)
git log --pretty=tformat: --numstat $@ "`git merge-base HEAD develop`..HEAD" | gawk '{ adds += $1 ; subs += $2 ; net += $1 - $2 ; gross += $1 + $2 ; commits += 1 } END { print "total commits\tadded loc\tremoved loc\tgross loc\tnet loc\n"; printf "%d\t%d\t%d\t%d\t%d\n", commits, adds, subs, gross, net }' | column -s $'\t' -t
@stefansundin
stefansundin / install-pre-commit.sh
Last active September 17, 2023 11:46
Git pre-commit check to stop accidental commits to master/main/develop branches.
#!/bin/bash
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are six variants that I have built:
# - pre-commit: stops commits to master/main/develop branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set the desired version like this before proceeding:
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@natelandau
natelandau / .bash_profile
Last active May 20, 2024 08:41
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management