Skip to content

Instantly share code, notes, and snippets.

View pid's full-sized avatar

Sascha pid

  • Baden-Württemberg, Germany
View GitHub Profile
@pid
pid / jasper-solutions.js
Last active December 19, 2015 07:49
Solutions: Jasper - JavaScript, Assessment of Skills with Peer Evaluation and Review
/* global Jasper */
/* http://kalisjoshua.github.io/Jasper/ */
Jasper('start');
// "Pass in a function that returns true."
Jasper(function() {
return true;
});
@pid
pid / gist:5948041
Created July 8, 2013 11:36
use the browser as notepad
data:text/html, <html contenteditable>
@pid
pid / gist:5970580
Created July 10, 2013 21:41
Fun (JavaScript/JAVA)
// http://stackoverflow.com/a/245073/995269
What's the difference between JavaScript and Java?
One is essentially a toy,
designed for writing small pieces of code,
and traditionally used and abused by
inexperienced programmers. The other is a scripting language
for web browsers.
@pid
pid / gist:5974342
Created July 11, 2013 10:27
```brew update``` and ```brew doctor```is stalling/hangs ::: SOLUTION
First, I don't know why.....but my solution at the moment
cd /usr/local
$ git remote -v
origin https://github.com/mxcl/homebrew.git (fetch)
origin https://github.com/mxcl/homebrew.git (push)
$ brew doctor -d
# hangs,stalling, no respond
@pid
pid / .git_hooks_pre-commit
Created July 15, 2013 01:56
Automatically JSHint files before Git commit (git hook)
#!/bin/bash
# Pre-commit Git hook to run JSHint on JavaScript files.
#
# If you absolutely must commit without testing,
# use: git commit --no-verify
filenames=($(git diff --cached --name-only HEAD))
which jshint &> /dev/null
if [ $? -ne 0 ];
@pid
pid / gist:6038807
Created July 19, 2013 12:32
error: can't exec '/Developer/usr/bin/xcodebuild' (No such file or directory)
error: can't exec '/Developer/usr/bin/xcodebuild' (No such file or directory)
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
@pid
pid / gist:6039252
Created July 19, 2013 13:53
generate slug / speaking url node.js or browser
// http://pid.github.io/speakingurl/
var slug;
var options = {
maintainCase: true,
separator: '_'
};
var mySlug = require('speakingurl').createSlug(options);
slug = mySlug("Bel été !");
console.log(slug); // Output: Bel_ete

This is a small collection of scripts showing how to use require.js. It's only one of several ways of setting up a require.js project, but it's enough to get started.

At its core, require.js is about three things:

  1. Dependency management
  2. Modularity
  3. Dynamic script loading

The following files show how these are achieved.

@pid
pid / gist:6103387
Created July 29, 2013 10:15
Adding AMD into the mix and don't forget CommonJS
/* Thanks to http://oli.me.uk/2013/07/21/exporting-through-amd-commonjs-and-the-global-object/ */
(function () {
// YOUR ORIGINAL CODE HERE
if (typeof define === 'function' && define.amd) {
define(function () {
return Foo;
});
}
@pid
pid / gist:6119939
Created July 31, 2013 07:08
Firewall iptables config example securing access to mongodb
iptables -N MongoDB
iptables -I INPUT -s 0/0 -p tcp --dport 27017 -j MongoDB
iptables -I INPUT -s 0/0 -p tcp --dport 28017 -j MongoDB
iptables -I MongoDB -s 127.0.0.1 -j ACCEPT
iptables -I MongoDB -s 10.0.0.1 -j ACCEPT
iptables -I MongoDB -s 10.0.0.2 -j ACCEPT
iptables -I MongoDB -s 10.0.0.3 -j ACCEPT
iptables -A MongoDB -s 0/0 -j DROP
/etc/init.d/iptables save