Skip to content

Instantly share code, notes, and snippets.


Stephen Paul Weber singpolyma

View GitHub Profile
View mod_onions.lua.patch
diff -r 7a3ac037e57f mod_onions/mod_onions.lua
--- a/mod_onions/mod_onions.lua Fri Jun 08 21:59:42 2018 +0200
+++ b/mod_onions/mod_onions.lua Mon Dec 03 01:28:59 2018 +0000
@@ -148,12 +148,16 @@
function socks5listener.onconnect(conn)
+ if not sessions[conn].socks5_handler == socks5_handshake_sent then
module:log("debug", "Connected to SOCKS5 proxy, sending SOCKS5 handshake.");
View git-ipfs
set -e
TMP="$(mktemp -d)"
git clone -q --bare . "$TMP"
cd "$TMP"
git update-server-info
if [ objects/pack/*.pack != 'objects/pack/*.pack' ]; then
cat objects/pack/*.pack | git unpack-objects
singpolyma / stanza.xml
Last active Mar 7, 2017
Movim file transfer
View stanza.xml
<message type='chat'>
<reference xmlns='urn:xmpp:reference:0' type='data'>
<media-sharing xmlns='urn:xmpp:sims:1'>
<file xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
singpolyma / Gemfile
Last active Apr 8, 2020
Add cell numbers from a set of vcards to your XMPP roster (through Cheogram)
View Gemfile
source ""
gem "blather"
gem "vcard"
View SqlSimpleHelpers.hs
module SqlSimpleHelpers where
import Prelude hiding (all)
import Control.Applicative ((<*>))
import Data.Tagged (Tagged(..), asTaggedTypeOf)
import Data.Text (Text)
import qualified Data.Text as T
class SqlColumns a where
columns :: Tagged a [Text] -- ^ Columns representend in the Haskell data, in order used in ToRow/FromRow
singpolyma / http-stream-file.hs
Created Mar 14, 2016
Stream a file as it is created (such as a video)
View http-stream-file.hs
module Main (main) where
import Control.Monad (forever, when)
import System.Environment (getArgs)
import System.IO (withBinaryFile, hIsEOF, IOMode(ReadMode), hSetBuffering, BufferMode(BlockBuffering))
import Control.Concurrent (threadDelay)
import Blaze.ByteString.Builder.ByteString (fromByteString)
import Data.ByteString (ByteString)
import Data.ByteString as BS
import Data.Text as T
singpolyma / html2text.rb
Created Nov 20, 2015
Example algorithm to textify HTML of tweetish posts
View html2text.rb
require 'nokogiri'
def content_text(nodes) do |el|
if el.text? || el.attributes['class'].to_s.match(/\b(?:h\-card|vcard|h\-x\-username)\b/) || el.attributes['rel'].to_s.match(/\btag\b/)
elsif == 'a'
href = el.attributes['href'].to_s
if el.text.strip == ''
singpolyma /
Last active Aug 29, 2015
Mutable variable swap in rust
// This allows you to consume a variable ane replace it with a new value
fn option_map_mut<T, F: FnOnce(T) -> T>(x: &mut Option<T>, f: F) {
match *x {
Some(_) => {
*x = Some(f(x.take().unwrap()));
None => {}
singpolyma /
Created Apr 22, 2015
Novena Autorotate Script
set -e
x="$(cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw)"
y="$(cat /sys/bus/iio/devices/iio:device0/in_accel_y_raw)"
[ "$x" -lt 0 ] && abs_x=$(( $x * -1 ))
singpolyma / TDD.hs
Created Apr 8, 2015
TDD add exercise (no errors yet)
View TDD.hs
module TDD (add) where
import qualified Data.Text as T
data ArgumentError = ArgumentError deriving (Show)
add :: String -> Integer
add s = sum $ map toI $ T.split (\d -> d == ',' || d == '\n') (T.pack s)
toI :: T.Text -> Integer