Skip to content

Instantly share code, notes, and snippets.

View Fonsan's full-sized avatar

Erik Fonselius Fonsan

View GitHub Profile
@Fonsan
Fonsan / foo.sql
Created December 21, 2023 22:44
Postgres table changes listen notify
DROP TABLE IF EXISTS foo ;
CREATE TABLE foo(
id serial primary key,
body text
);
INSERT INTO foo (body) values ('blabal');
require 'json'
require 'time'
counting_hash = Hash.new(0)
line_enumerator = STDIN.each_line
line_enumerator.each do |line|
puts line
end
# https://streamlink.github.io/
tw() {
TMPFILE=`mktemp`
echo $TMPFILE
vlc $TMPFILE &
streamlink --hls-segment-threads 10 -f -o $TMPFILE $1 best
}
2016-12-27 20:49:17 1.5 GiB pbfs/africa-161201.osm.pbf
2016-12-27 20:49:27 28.9 MiB pbfs/antarctica-161201.osm.pbf
2016-12-27 20:49:27 4.5 GiB pbfs/asia-161201.osm.pbf
2016-12-27 20:49:59 493.6 MiB pbfs/australia-oceania-161201.osm.pbf
2016-12-27 20:50:02 248.9 MiB pbfs/central-america-161201.osm.pbf
2016-12-27 20:50:04 18.0 GiB pbfs/europe-161201.osm.pbf
2016-12-27 20:52:05 7.5 GiB pbfs/north-america-161201.osm.pbf
2016-12-27 20:52:57 981.0 MiB pbfs/south-america-161201.osm.pbf
Total Objects: 8
@Fonsan
Fonsan / PureFTPD
Last active September 29, 2016 17:08 — forked from gaiottino/PureFTPD
sudo yum update # -yes?
sudo yum groupinstall "Development Tools"
sudo yum install openssl-devel htop
mkdir install
cd install
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.41.tar.gz
tar -xvzf pure-ftpd-1.0.41.tar.gz
cd pure-ftpd-*
./configure --with-tls --with-ftpwho --with-puredb --without-pam
make
require 'open3'
module Enumerable
alias :all_are? :all?
end
Open3.popen3(%(ruby -e 'STDOUT.sync = true; STDERR.sync = true;3.times { |i| STDOUT.puts(i); STDERR.puts(i); sleep 1 }')) do |stdin, stdout, stderr, wait_thr|
maxlen = 1024
pipes = {
stdout => :stdout,
import zlib
from imposm.parser.pbf.parser import PBFFile, PrimitiveBlockParser
import imposm.parser.pbf.parser
import imposm.parser.pbf
import StringIO
import cachetools
import bisect
import sys
import resource
import random
require 'open-uri'
require 'nokogiri'
date = (Date.today - 2).strftime("%y%m%d")
paths = %w(
africa
asia
australia-oceania
central-america
europe
parallel_fetch(ServerPid, FirstKey, SecondKey, ThirdKey) ->
FirstRequestId = make_ref(),
SecondRequestId = make_ref(),
ThirdRequestId = make_ref(),
ServerPid ! {self(), FirstRequestId, FirstKey},
ServerPid ! {self(), SecondRequestId, SecondKey},
ServerPid ! {self(), ThirdRequestId, Thirdkey},
FirstValue = receive