Skip to content

Instantly share code, notes, and snippets.

View dominikwilkowski's full-sized avatar
🤖
Working

Dominik Wilkowski dominikwilkowski

🤖
Working
View GitHub Profile
@penguinboy
penguinboy / Object Flatten
Created January 2, 2011 01:55
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@nanha
nanha / gist:1385106
Created November 22, 2011 07:28
node.js CRC32
var crypto = require('crypto');
/**
* Calculates the hash/checksum of a string. Default algorithm is MD5.
*
* @param {String} str
* @param {String} algorithm
* @return {String} checksum
* @api public
*/
@tkihira
tkihira / gist:3014700
Created June 28, 2012 23:28
mkdir, rmdir and copyDir(deep-copy a directory) in node.js
var mkdir = function(dir) {
// making directory without exception if exists
try {
fs.mkdirSync(dir, 0755);
} catch(e) {
if(e.code != "EEXIST") {
throw e;
}
}
};
@asabaylus
asabaylus / gist:3071099
Created July 8, 2012 14:12
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@dansimau
dansimau / README.md
Created July 13, 2012 10:39
Enable git-style colour output in regular diff on Mac OS X

Enable git-style colour output in regular diff

Mac OS X

  1. Install colordiff using Homebrew:

     brew install colordiff
    
  2. Add function to your ~/.bash_profile:

@lancejpollard
lancejpollard / index.md
Created October 6, 2012 05:09
Node.js REPL API (readline API, a lower level REPL module)

Node.js Readline API

Readline is a more robust REPL.

readline  = require('readline')
repl      = readline.createInterface(stdin, stdout, autocomplete)

repl.historyIndex = 0
repl.history = ['App.Post.all()']
@pghalliday
pghalliday / 1 test.js
Created November 20, 2012 10:30
node.js windows spawn with cmd /s /c
var http = require('http');
var spawn = require('child_process').spawn;
var child = spawn(
'CMD', [
'/S',
'/C',
'node',
'./child.js'
]
);
@SBoudrias
SBoudrias / readline-test.js
Created May 13, 2013 20:56
Node.js Readline and CLI keypress example
var readline = require('readline'),
_ = require('lodash'),
charm = require('charm')(process.stdout),
rl = readline.createInterface(process.stdin, process.stdout);
var selected = 0;
var choices = [
"foo",
"bar",
"javascript",
@kerotaa
kerotaa / remove-empty-lines-html.rb
Last active May 26, 2020 03:48
A plugin that remove empty lines from HTML files on jekyll.
module Jekyll
module Convertible
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
if File.extname(path).downcase == '.html' then
self.output.strip!
reg = /<\/?pre[^>]*>/i
pres = self.output.scan(reg)
tary = self.output.split(reg)
@travishorn
travishorn / Using Grunt with Travis-CI.md
Last active May 4, 2022 21:59
Using Grunt with Travis-CI

If you are using Grunt to run your tests and Travis-CI for your continuous integration, you will need to command Travis-CI to install the grunt-cli before running your test script(s). grunt-cli is meant to be a global package, so adding it to your dependencies or devDependencies is not ideal.

You'll need the following your package.json...

  • Test script command
  • Grunt and any plugins as dependencies

Like so:

{