Skip to content

Instantly share code, notes, and snippets.

View dirkk0's full-sized avatar

Dirk Krause dirkk0

View GitHub Profile
<html>
<head>
<title>Cloud9, NodeJS & Heroku: websockets for all</title>
<script src="/socket.io/socket.io.js"></script>
<script>
onerror = function(msg) {
log(msg);
}
@dirkk0
dirkk0 / doit.sh
Created July 12, 2013 09:57
Installing Cloud9 on Amazon EC2 (revisted, Cloud9 v0.7)
sudo apt-get update
# get ec2 ip and hostname
sudo apt-get install -y build-essential g++ libssl-dev apache2-utils git libxml2-dev screen
#install node
git clone https://github.com/joyent/node.git
# git checkout v0.10.13 did work once, but I couldn't work again, so I fell back to 0.8
#compilation takes over 30 minutes on a t1.micro
@dirkk0
dirkk0 / gist:6020551
Created July 17, 2013 13:28
Installing Echoplexus on Amazon EC2
sudo apt-get update
# get ec2 ip and hostname
curl http://169.254.169.254/latest/meta-data/public-ipv4 > public.ip
curl http://169.254.169.254/latest/meta-data/public-hostname > public.hostname
sudo apt-get install --yes build-essential curl git
#install latest node
sudo apt-get install --yes python-software-properties python g++ make
@dirkk0
dirkk0 / list.json
Last active December 22, 2015 00:18
Simple example to get JSON data
{
"users": [
"Jim",
"Jack",
"Joe"
]
}
@dirkk0
dirkk0 / gist:6390977
Created August 30, 2013 15:22
Retreive users from mean.io database (i.e. retrieve data from mongoDB via mongoose)
//require mongoose node module
var mongoose = require('mongoose');
//connect to local mongodb database
var db = mongoose.connect('mongodb://127.0.0.1:27017/mean-dev');
//attach lister to connected event
mongoose.connection.once('connected', function() {
console.log("Connected to database")
});
@dirkk0
dirkk0 / gist:6496579
Created September 9, 2013 14:43
test.py
#!/usr/bin/env python
# coding: utf8
from docx import *
import urllib2
# filename = "template.docx"
# document = opendocx(filename)
document = newdocument()
@dirkk0
dirkk0 / gist:6576740
Last active December 23, 2015 03:58
Get all users in pump.io

If you look at /routes/api.js, you see the endpoints that you can access already.

One of them is /api/user//followers

But in line 179 you see app.get("/api/users", smw, anyReadAuth, listUsers);

so it turns out that the user list is already available. listUsers is defined

@dirkk0
dirkk0 / test.sh
Last active December 23, 2015 12:49
trigger backups with php and bash
while true
do
if [ -f /var/www/del.txt ]
then
echo done
# ./doit.sh
rm /var/www/del.txt
echo -e "subject:backup created\nhello world" | sendmail -v [email protected]
fi
sleep 10
<?
echo "<pre>executiong ...</pre>";
$output = shell_exec('/var/www/createBackup.sh');
echo "<pre>$output</pre>";
echo "<pre>....done.</pre>";
?>
@dirkk0
dirkk0 / server.js
Last active December 26, 2015 13:09
static web server in node
var static = require('node-static');
var file = new static.Server('./public');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response);
}).resume();
}).listen(8080);