Skip to content

Instantly share code, notes, and snippets.

View xenji's full-sized avatar

Mario Mueller xenji

  • Mettmann, Germany
  • 05:09 (UTC +02:00)
View GitHub Profile
require "mongo"
require 'json'
connection = Mongo::Connection.new("localhost", 27017)
db = connection.db('log_201208')
col = db.collection('d_01')
col.create_index([['ts', Mongo::ASCENDING], ['pid', Mongo::DESCENDING]])
col.create_index('status')
require 'tire'
require 'sanitize'
module Jekyll
class ElasticSearchIndexer < Generator
safe true
def generate(site)
Tire::Configuration.url(site.config['search_server'])
var Search = {
searchUrl: "http://search.xenji.com/xenjicom/_search",
processResults: function(results) {
if (typeof results != "undefined")
this.renderResults(results.hits);
},
onkeypress: function(event) {
@xenji
xenji / update_tunnelbroker.rb
Created February 21, 2013 08:16
This is a simple script that I run on my raspberry-pi to update my public WAN IPv4 at tunnerbroker.net. Most of the script is configurable so you might use it for other providers with low effort.
#!/usr/bin/env ruby
require 'net/http'
require 'net/https'
BASEDIR = '/etc'
LAST_IP_FILE = "#{BASEDIR}/tunnelbroker.lastip"
# for debugging.
BE_VERBOSE = false
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
function isNoHomepageSearch(input) {
return input !~ /bIsWorldwide/
}
function getIp(input) {
return $3
}
function isGetRequest(input) {
return input ~ /^"GET/
var redis = require("redis"),
client = redis.createClient();
var amqp = require('amqp');
var amqpc = amqp.createConnection({ host: 'somehost', login: 'guest', password: 'guest', vhost: '/' });
var geoip = require('geoip-lite');
var ll = require("lazylines");
amqpc.on('ready', function () {
amqpc.exchange('heatmap', {passive: true}, function(e){
process.stdin.resume();
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var amqp = require('amqp');
var amqpc = amqp.createConnection({ host: 'somehost', login: 'guest', password: 'guest', vhost: '/' });
process.on('exit', function() {
amqpc.close();
});
$(document).ready(function () {
var socket = io.connect('http://' + location.host),
$body = $('body'),
body_width = $body.width(),
body_height = $body.height(),
count_datapoints = 0,
$map = $('#map'),
datapoints = 1500,
heatmap = new google.maps.visualization.HeatmapLayer({
@xenji
xenji / clang_configure.sh
Last active December 16, 2015 04:29
Build command for PHP5.5 beta3 on FreeBSD 9.1-RELEASE using clang and gcc
env COPTFLAGS="-O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing" CC=clang CXX=clang++ CPP=clang-cpp CFLAGS="-O2 -pipe -fno-strict-aliasing" ./configure --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-cgi --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php.d --with-openssl --with-zlib --enable-bcmath --enable-calendar --with-curl --with-curlwrappers --enable-exif --enable-ftp --with-gd --with-t1lib --enable-gd-native-ttf --with-mhash --enable-intl --enable-mbstring --with-mcrypt --with-mysqli --enable-pcntl --with-pdo-mysql --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-xsl --enable-zip --enable-mysqlnd --with-pear