Skip to content

Instantly share code, notes, and snippets.

View janbiasi's full-sized avatar
🌐
Just building

Jan R. Biasi janbiasi

🌐
Just building
View GitHub Profile
@janbiasi
janbiasi / proxy.js
Last active February 16, 2016 07:48
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 1)
var http = require('http');
var httpProxy = require('http-proxy');
exports.createServer = function(host, proxyPort, httpPort) {
proxyPort = proxyPort || 8000;
httpPort = httpPort || 9000;
host = host || 'localhost';
// Erstellt den Proxy-Server
httpProxy.createServer(httpPort, host).listen(proxyPort);
@janbiasi
janbiasi / microp.js
Created February 9, 2016 10:31
Micro sized promise library for Node.js and the Browser
(function() {
var root = this;
var giveBackOldPromise = Promise;
var isNode = typeof process === 'object' || window === undefined;
var asap = function(handler) {
if(isNode) {
process.nextTick(handler);
} else {
@janbiasi
janbiasi / ajax.js
Last active February 3, 2016 19:52
ajax
(function(window, undefined) {
var strEq = function(str1, str2) {
return str1.toLowerCase() === str2.toLowerCase();
};
var ajaxRequest = function(method, opts) {
opts = opts ? opts : {};
opts.data = opts.data || null;
opts.success = opts.success || function() { };
@janbiasi
janbiasi / index.php
Created January 13, 2016 08:49
Tired of the default XAMPP/MAMP Index? Try this one and get a beautiful directory listing in your server root!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Index of <?= $_SERVER['SERVER_NAME'] ?></title>
<style type="text/css">
html, body { margin: 0; padding: 0; }
body { font-family: 'Helvetica Neue', Arial, sans-serif; padding: 20px; }
a { text-decoration: none; color: #4BB7DB; }
a:hover { text-decoration: underline; }
@janbiasi
janbiasi / example-properties.js
Last active January 6, 2016 10:49
Node Type let you easily work with types and its core possibilities such as enumerability, writability and readonly settings. Properties can be declared with a specific type and a livetime validator.
var out = function(val) { console.log(val); };
var User = Type.create({
properties: {
name: String,
id: {
type: Number,
enumerable: false
},
class: {
#!/bin/bash
if [ ! -d "./data" ]; then
mkdir -f data
fi
C:\mongodb\bin\mongod.exe --dbpath ./data/
#!/bin/bash
echo "Installing Express ..."
npm install -g express-generator
read -p "Choose the name for your app: " appName
if [[ -z "$appName" ]]; then
echo "Installation failed: no name supplied!"
exit 1
fi
#!/bin/bash
sudo rm -rf /usr/local/lib/node_modules
mkdir "${HOME}/.npm-packages"
export PATH="$HOME/.node/bin:$PATH"
@janbiasi
janbiasi / events.java
Last active August 29, 2015 14:22
Simple eventhandling for frames and so on in java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class MyFrame extends JFrame {
private JFrame reference = this;
JButton myButton = new JButton();
myButton.setText("Exit Applcation ...");
/* Add listener for the button to close */
myButton.addActionListener(new ActionListener() {
#!/bin/bash
yum install -y openssh-clients man git vim wget curl ntp
chkconfig ntpd on && chkconfig sshd on
chkconfig iptables off && chkconfig ip6tables off
sed -i -e 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
sed -i 's/^\(Defaults.*requiretty\)/#\1/' /etc/sudoers
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
mkdir /home/vagrant/.ssh && chmod 700 /home/vagrant/.ssh
curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub >> /home/vagrant/.ssh/authorized_keys
chmod 600 /home/vagrant/.ssh/authorized_keys