Skip to content

Instantly share code, notes, and snippets.

View marcusandre's full-sized avatar

Marcus André marcusandre

  • Germany
  • 08:45 (UTC +01:00)
View GitHub Profile
@marcusandre
marcusandre / install_mongo.sh
Last active October 9, 2015 21:38
install MongoDB on Ubuntu 12.04 LTS
#!/bin/bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
sudo apt-get -y update
sudo apt-get -y install mongodb-10gen

Project

Description: What does this project do and who does it serve?

Project Setup

How do I, as a developer, start working on the project?

  1. What dependencies does it have (where are they expressed) and how do I install them?
  2. How can I see the project working before I change anything?
@marcusandre
marcusandre / Makefile
Created January 14, 2013 20:48
Mocha setup
TESTS = $(shell find test -name "*.js")
test:
@NODE_ENV=test mocha \
$(TESTS)
.PHONY: test
@marcusandre
marcusandre / slugify.js
Last active December 14, 2015 06:09
Generate a slug with JavaScript.
// sync example.
function createSlug(title) {
return title
.toLowerCase()
.replace(/[^\w ]+/g,'')
.replace(/ +/g,'-');
}
var slug = createSlug('This is a test!');
console.log(slug);
@marcusandre
marcusandre / gen_appcache.md
Last active December 15, 2015 07:59
Generate Appcache (incl. xhr) in Chrome DevTools

Generate Appcache Manifest (incl. xhr) in Chrome DevTools

  1. Open your Chrome Developer Tools
  2. Navigate to the Network tab
  3. Just right click into the panel and choose Copy ALL as HAR (maybe the page needs a reload)
  4. Switch to the console tab and save your HAR data in a variable. (var data = cmd + v)
  5. Now let's create the cache manifest:
console.log('CACHE MANIFEST\n\nCACHE:');
@marcusandre
marcusandre / .editorconfig
Last active December 15, 2015 18:09
My .editorconfig file.
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.js]
@marcusandre
marcusandre / ping.js
Created September 7, 2013 10:44
ping
// `ping` backend from client via websocket
// frontend code
// ping every 60 seconds or so
ping.send({
"user": userid,
"time": new Date.now()
});
#!/usr/bin/bash
uglifyjs -nc script.js > script.min.js
gzip -f -c --best script.min.js > script.min.js.gz
uglifyjs --max-line-len 80 -nc script.js
echo "Done"
wc -c scripts.min.js.gz
@marcusandre
marcusandre / mysql_installation.sh
Created October 21, 2013 19:25
Install MySQL Server on a Ubuntu machine without a password
#!/usr/bin/bash
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password rootpass'
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password rootpass'
apt-get update
apt-get -y install mysql-server-5.5
@marcusandre
marcusandre / create_hash.js
Last active December 27, 2015 07:39
[Idea] Create a hash from Date and request ID.
var id = 123 // 'something from the database'
require('crypto')
.createHash('sha1')
.update(new Date() + id)
.digest('hex');