Skip to content

Instantly share code, notes, and snippets.

location / {
if ($request_method = OPTIONS) {
add_header Content-Length 0;
add_header Content-Type text/plain;
return 200;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_max_temp_file_size 0;
@raucao
raucao / site.nginxconf
Last active November 18, 2021 22:12
Nginx log format for detailed JSON entries
log_format json '{"ip":"$remote_addr",'
'"time":"$time_local",'
'"host":"$host",'
'"method":"$request_method",'
'"uri":"$uri",'
'"status":$status,'
'"size":$body_bytes_sent,'
'"referer":"$http_referer",'
'"ua":"$http_user_agent"}';
@raucao
raucao / nginx-lua-s3.nginxconf
Last active September 8, 2020 01:29
Nginx proxy to S3
location ~* ^/s3/(.*) {
set $bucket '<REPLACE WITH YOUR S3 BUCKET NAME>';
set $aws_access '<REPLACE WITH YOUR AWS ACCESS KEY>';
set $aws_secret '<REPLACE WITH YOUR AWS SECRET KEY>';
set $url_full "$1";
set_by_lua $now "return ngx.cookie_time(ngx.time())";
set $string_to_sign "$request_method\n\n\n\nx-amz-date:${now}\n/$bucket/$url_full";
set_hmac_sha1 $aws_signature $aws_secret $string_to_sign;
set_encode_base64 $aws_signature $aws_signature;

A/V calls in Conversations

Here are some short notes for server admins and developers of other XMPP clients.

Notes for server admins

Most calls will require server side assistence. Depending on the network it might be enough to have a STUN server for Conversations to learn your external IP and punch a hole in the NAT. On some, more restrictive, networks however this isn’t enough and Conversations will need a TURN server. TURN servers are used to proxy the entire (encrypted) traffic through the server. (In my initial testing this was often the case when mobile networks were involved.)

To ensure best possible user experience in all situations server admins should set up both.

@raucao
raucao / typekit.js
Last active February 12, 2020 06:25
Improved Typekit embed code
(function(d) {
var tkTimeout=3000;
if(window.sessionStorage){if(sessionStorage.getItem('useTypekit')==='false'){tkTimeout=0;}}
var config = {
kitId: 'a1b2c3f4',
scriptTimeout: tkTimeout
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";if(window.sessionStorage){sessionStorage.setItem("useTypekit","false")}},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='//use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
import time
import board
import adafruit_dht
import paho.mqtt.publish as publish
dhtDevice = adafruit_dht.DHT11(board.D14)
broker_address = "192.168.2.52"
port = 1883
client_id = "python"
username = "foo"
"""Script to reset time on CardIO via serial, run on HOST computer
inspired by: https://badge.team/projects/suckless_flash
"""
from __future__ import print_function
import sys, time
dev=open("/dev/ttyACM0", "w")
print(chr(0x03), end="", file=dev)
" Highlight trailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
au ColorScheme * highlight ExtraWhitespace guibg=red
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
<iq id='set1'
type='set'
to='hackerbeach@chat.kosmos.org'>
<vCard xmlns='vcard-temp'>
<PHOTO>
<TYPE>image/png</TYPE>
<BINVAL>
iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAAAAAB5Gfe6AAAIi0lEQVR42u2deWwUZRiHZ2Z7QFtoFyhtkQqIggoECkiUSyEFW2yLhYCRIwgqkRgOQyKKhkA4xOCFQRIQIgZDTBStEGhpoRAQsMYYSPAPoZRGLrl7bLdl226lJUJblt35jpnfzPR9/ibwvg/vd3/zrdLQxlHQAaAhAegA0JAAdABoSAA6ADQkAB0AGhKADgANCUAHgIYEoANAQwLQAaAhAegA0JAAdABoSAA6ADQkAB0AGhKADgANCUAHgIYEoANAQwLQAaAhAegA0JAAdABoSAA6ADQkAB0AGhKADgANCUAHgIYEsPxhv7fs2mWLc63MW2+QAN/Z9ZOHdFIsjjsl+7Mzt40QkDehezg6O32Ed0vbJVuA/9Sc9ui8WGg386RfqoCCJBWdExtqwl6JAmrWJ6ITYqfrOq8sAfXr0cnw8bGe4UCPgLxYdCp8dNTTFeoQUDwAnQkvff+SIaBqhs36v/uoUyslCMi1yegfiPCfJAiYhM5ChHRxAf9YfvIbjLhSYQGrXOgkRHB9EGpCGErA7YnoHMQYF2o2FEpA1XB0CmKklAkKqHi85V+oxVocrWW83a8JCrjVahWQ2GBxureMN+4yCRATUJZkbwHuf0kACRATQH2AvQUIV0CbHwVIAAlo4wKoE6QKsLcAqgCqAFEBxlWA31t+pmDL0tenZo0bNbT/oOcnzlq4dk9pZa1UAXEWXQzVlRfvXT0mwJGb9tScLSfKme54BBVgzdVgXcH8kV2jNCUganiXkUuOW0eA7Cbgrzi2cmiHEKdtmjt1+5U6awiQWwH+a9uGKPpIXl2s85KHjQTcXDe4ne6jVl
@raucao
raucao / .vimrc
Created December 21, 2018 07:49
Highlight trailing whitespace in vim
" Highlight trailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red