Skip to content

Instantly share code, notes, and snippets.

View gousiosg's full-sized avatar

Georgios Gousios gousiosg

View GitHub Profile
@gousiosg
gousiosg / RxPortScan.scala
Last active December 15, 2015 12:59
A reactive port scanner written using Rx.Java (0.13 onwards) and Scala 2.10 Futures
import java.net.Socket
import rx.subscriptions.Subscriptions
import rx.lang.scala.Observable
import scala.concurrent.{Future, future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
// A reactive parallel port scanner written with Rx.Java
// @author: @gousiosg, @headinthebox
@gousiosg
gousiosg / VanityPullRequests.cs
Last active December 15, 2015 16:39
Find Github pull requests that are then tweeted. Implemented with Rx.Net in C#.
/*
* Github commits that are then tweeted.
* by @gousiosg, @headinthebox
*/
void Main()
{
var q = from ghinfo in PullRequestersInfo()
from u in ghinfo
from t in Tweets(u).TakeUntil(Observable.Timer(TimeSpan.FromMinutes(5)))
select new {User = u, Tweet = t};
select a.month,
a.total_commits - b.commits_from_pull_reqs as direct,
b.commits_from_pull_reqs as pullreq
from
(select strftime("%Y-%m-01", substr(c.created_at, 0, 20)) as month,
p.id as prid, count(c.id) as total_commits
from commits c, projects p, project_commits pc
where p.id = pc.project_id
and c.id = pc.commit_id
group by month, p.id) as a,
@gousiosg
gousiosg / teapot.php
Created October 7, 2013 17:16
The teapot in PHP!
<?php
class Triangle
{
var $colors = array("yellowgreen", "tomato", "plum");
var $vertices;
function Triangle($vertices)
{
assert(sizeof($vertices) == 3);
@gousiosg
gousiosg / stackoverflow.sql
Last active July 22, 2024 11:10
Script to import the stackexchange dumps into MySQL
# Copyright (c) 2013 Georgios Gousios
# MIT-licensed
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use stackoverflow;
create table badges (
Id INT NOT NULL PRIMARY KEY,
UserId INT,
@gousiosg
gousiosg / nagios.nginx
Last active February 16, 2018 10:56
Nagios on a virtual host with nginx on Debian
server {
listen 80;
server_name nagios.tld.org;
access_log /var/log/nginx/nagios.access.log;
error_log /var/log/nginx/nagios.error.log info;
root /usr/share/nagios3/htdocs;
index index.php index.html;
@gousiosg
gousiosg / analysis.R
Last active December 2, 2015 11:41
Complete machine learning example
library(reshape)
library(ggplot2)
library(corrplot)
library(caret)
source('ml.R')
# Util stuff
load.filter <- function(path) {
setAs("character", "POSIXct",
@gousiosg
gousiosg / session.sh
Last active December 10, 2020 11:43
GHTorrent from scratch session
#First, install RVM as per https://rvm.io
rvm install 2.5.1
rvm use 2.5.1
git clone [email protected]:gousiosg/github-mirror.git
cp config.yaml.standalone config.yaml
# Install dependencies
gem install bundler
@gousiosg
gousiosg / buien-hue.rb
Last active December 9, 2020 10:22
Set color of a Hue lightbulb based on fine-grained rain information
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
require 'hue'
delft="http://www.buienradar.nl/Json/RainForecast3Hours?lat=52.006&lon=4.355&weatherstationid=6344&streetlevel=false"
percipitation = JSON.parse(open(delft).read)['forecasts'][1]["precipation"]
@gousiosg
gousiosg / geocode.rb
Created October 8, 2015 21:27
Geocode a list of addresses using OpenStreetMaps
#!/usr/bin/env ruby
#
require 'open-uri'
require 'json'
require 'pp'
require 'uri'
File.open('locs').each_line do |location|
url=URI.escape("http://nominatim.openstreetmap.org/search/#{location}?format=json&addressdetails=1")