Skip to content

Instantly share code, notes, and snippets.

@Syrup-tan
Syrup-tan / _readme.md
Last active February 15, 2016 22:48
simple acme-tiny sh wrapper

Shell script to generate ssl certificates signed from letsencrypt.

demo

Requires diafygi/acme-tiny.

Requires a web-server with a configured /.well-known/acme-challenge/ set to CHALLENGE_PATH in the third line of the script. See Step 3 of diafygi's great readme

TODO:

  • configurable ./account.key (i.e. not hardcoded)
@Syrup-tan
Syrup-tan / oh god why.js
Created October 18, 2015 22:11
ENTERPRISE QUALITY STRING REVERSER
w = reverse('SebaJun');
while (v = w.next().value) console.log(v);
function *reverse(s) {
yield s;
for (i = 0, j = 0; j++ < s.length; i = 0) while (s[i+1] && i + j < s.length) {
yield s = [
s.slice(0, i),
s.slice(i+1, i+2),
s.slice(i, i+1),
s.slice(i+2),
#!/bin/sh
## Load std
. 'lib-std.sh'
transfer_accountlist() {}
transfer_homedir() {}
transfer_wpdb() {}
transfer_account() {}

SSL over :80 with nginx

Using nginx's error_page directive we can support SSL over both :80 and :443

Why?

Some intrusive firewalls, ISPs, companies, and ``Anti-virus'' programs attempt to intercept SSL connections on :443. Some of these programs even offer their own certificate, in order to perform MiTM attacks. In more extreme cases, connections may be entirely blocked on :443.

By allowing SSL connections on :80, users with these threats may still access the server securely.

How?

Using nginx's

caesar(atob('TFdWIFFSVyBEUSBEVlZEVlZMUSwgTFdWIEQgUUxRTUQ7IFFSVyBZRFBTTFVILVJRSCwgV0tSWEpLLg=='), 23);
function caesar(s, n) {
n = n || 13;
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
return s.toUpperCase().replace(/./g, function(l) {
var index = alphabet.indexOf(l);
return index < 0 ? l : alphabet[(index + n) % 26];
});
}
Example: https://denpa.moe/~syrup/himawari8.png
@Syrup-tan
Syrup-tan / stdlib.sh
Created April 20, 2015 22:16
A simple standard library for posix sh, WIP
#!/bin/sh
## sh stdlib
plus_equals() { FUNCTION="plus_equals()";
## Handle options
case "$1" in
-h)
echo;
#!/bin/sh
## Configuration
OUTPUT=~/www/anya.txt;
## Get the search scripts
. ~/www/search.bash;
## Get all of the messages from Anya that contain danbooru
from_buffer '#r/a/dio' | grep_nick 'Anya' | grep 'danbooru' > "$OUTPUT";
@Syrup-tan
Syrup-tan / search.bash
Last active August 29, 2015 14:18
A simple ZNC search script.
#!/bin/bash
## search.{bash,zsh} v0.0.3
## Configuration
LOG_DIR=~znc/'.znc/moddata/log/syrup-tan';
DEFAULT_SERVER='rizon';
## Usage
## Source the file with $ . ./search.bash
## All queries must begin with a from_* function
#!/bin/sh
## MySQL Setup Configuration
MYSQL_DATABASE='mydb_name';
MYSQL_USERNAME='mydb_user';
INCLUDE_DEVELOPER_DEFAULTS=false;
## Get the MySQL files