Skip to content

Instantly share code, notes, and snippets.

@spaghetti-
spaghetti- / test.py
Last active March 29, 2022 01:36
rtorrent command syntax xmlrpc
To list all torrents in view 'main' and its tracker url we can chain commands like so:
# for testing
$ python3 -m rtorrent_xmlrpc scgi://localhost:16891/RPC2
d.multicall2 '' main d.name= d.size_bytes= d.creation_date= t.multicall=,t.url= f.multicall=,f.path=
d.multicall2 '' main d.name= d.size_bytes= d.creation_date= d.directory_base= t.multicall=,t.url=
brew update
brew install php
git clone --depth 1 https://github.com/phacility/libphutil.git
git clone --depth 1 https://github.com/phacility/arcanist.git
if grep -Fxq 'export PATH=$PATH:$HOME/repos/arcanist/bin' ~/.zshrc
then
echo 'export PATH=$PATH:$HOME/repos/arcanist/bin' | tee -a ~/.zshrc
else
echo 'arcanist bin path exists in path, not appending'
#!/bin/sh
#
# FFmpeg configure script
#
# Copyright (c) 2000-2002 Fabrice Bellard
# Copyright (c) 2005-2008 Diego Biurrun
# Copyright (c) 2005-2008 Mans Rullgard
#
# Prevent locale nonsense from breaking basic text processing.
CREATE OR REPLACE FUNCTION update_table (target_table text, timestamp_col text,
from_timestamp timestamp with time zone, constraint_name text, t ANYELEMENT)
RETURNS SETOF ANYELEMENT
AS $$
DECLARE
querytext text;
DECLARE
tmp text;
BEGIN
SELECT
@spaghetti-
spaghetti- / districts.sql
Created September 4, 2017 14:58
Convert singapore postcodes to districts
create or replace function singapore_postcode_to_district (code text, out district_num int, out district_name text)
as $$
begin
case substring(code from 1 for 2)::int
when 01, 02, 03, 04, 05, 06 then
district_num := 1;
district_name := 'Raffles Place, Cecil, Marina, People''s Park';
when 07, 08 then
district_num := 2;
district_name := 'Anson, Tanjong Pagar';
PUT _ingest/pipeline/extract_timestamp_fromlogfile
{
"processors": [
{
"grok": {
"field": "message",
"patterns": ["%{TIMESTAMP_ISO8601:timestamp}"]
}
}
]
@spaghetti-
spaghetti- / lumber.zsh
Created April 17, 2017 13:07
lumberjack bot ayyy
function right() {
screencapture -R706,427,1,1 -t bmp /tmp/pixel.bmp
echo `xxd -p -l 3 -s 54 /tmp/pixel.bmp`
rm /tmp/pixel.bmp
}
function left() {
screencapture -R593,424,1,1 -t bmp /tmp/pixel.bmp
echo `xxd -p -l 3 -s 54 /tmp/pixel.bmp`
rm /tmp/pixel.bmp
@spaghetti-
spaghetti- / server.cpp
Created March 25, 2017 08:19
Boost asio tcp server example, C++11
#include <iostream>
#include <memory>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
//thanks kalven for tips/debugging
using boost::asio::ip::tcp;
class Session : public std::enable_shared_from_this<Session>
#!/bin/sh
head -1 ~/.ssh/authorized_keys | ssh-keygen -l -f - > /dev/null 2>&1
if [ $? != 0 ];
then
echo "invalid public key found in authorized_keys, exiting.."
exit
fi
/*
* stripcmt()
*
* This is the core of the program. It reads from file 'infile' and outputs
* the code (minus comments) to 'outfile'. It does this inefficiently since
* it outputs byte by byte instead of in blocks, but I'm too lazy to fix that
* right now. Maybe later.
*/
void