Skip to content

Instantly share code, notes, and snippets.

@b4284
b4284 / README.md
Last active December 2, 2018 14:54
A CGI skeleton to process HTTP GET & POST requests for guile scheme

I'm using guile scheme to build some CGI program, and needed to process POST requests for uploaded files -- multipart/form-data to be exact. But what guile provides seems to be lacking this facility, so I wrote a crude one. This should be enough for small enough files. I/O is about 5K-7K KB/s for uploading files.

The main function in the script contains a simple example of how to get the parameters with this skeleton. Its usage is paired with convert.html, which trans-writes whatever you upload to the filesystem.

@b4284
b4284 / guile-script.scm
Last active December 5, 2018 14:53
A "perl -ne" like REPL for guile scheme to work with shell scripts
#!/usr/bin/guile \
-e main -s
!#
;; A "perl -ne" like REPL for guile scheme to work with shell scripts.
;;
;; Usage: <THIS_FILE> [OPTIONS] PROC-STRING [FILE]...
;;
;; PROC-STRING
;; A s-expression string representing a lambda taking 1 or 2 arguments,
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 John Darrington <jmd@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Rutger Helling <rhelling@mykolab.com>
;;;
;;; This file is part of GNU Guix.
/home/b4283/mnt/gnu/store/v5lad91n9wsnxqfqdy76mmsjc1fm8v0c-guix-0.15.0-7.f5a2724/share/guile/site/2.2/gnu/packages:
總計 12856
dr-xr-xr-x 1 root root 16384 1月 1 1970 .
dr-xr-xr-x 1 root root 4096 1月 1 1970 ..
-r--r--r-- 1 root root 2013 1月 1 1970 abduco.scm
-r--r--r-- 1 root root 5373 1月 1 1970 abiword.scm
-r--r--r-- 1 root root 4994 1月 1 1970 accessibility.scm
-r--r--r-- 1 root root 1679 1月 1 1970 acct.scm
-r--r--r-- 1 root root 3860 1月 1 1970 acl.scm
-r--r--r-- 1 root root 4348 1月 1 1970 ada.scm
;; (positional-list-match '("11") '("12"))
;; => #f
;; (positional-list-match '("11") '("11" "12"))
;; => #t
;; (positional-list-match '(any "12") '("11" "12"))
;; => #t
;; (positional-list-match '(any any any any any) '(5 4 3 2))
;; => #f
;; (positional-list-match 'any '(5 4 3 2))
;; => #t
#include <cmath>
#include <functional>
#include <iostream>
using std::function;
using std::cout;
using std::endl;
template<class A> class optional {
bool _isValid;
int c[10];
void func(int c1[10]) {
c1[11] = 66;
}
int main() {
int d[10];
c[11] = 55;
func(d);
@b4284
b4284 / invoice107.jan.feb.sh
Created March 31, 2018 18:31
107年1~2月對獎程式
while read NUM; do
if [[ $NUM == "266" \
|| $NUM == "254" \
|| $NUM == "209" \
|| $NUM == "340" \
|| $NUM == "612" \
|| $NUM == "591" \
|| $NUM == "342" ]];
then
echo BINGOOOO
@b4284
b4284 / lib.c
Created November 10, 2017 16:53
Function Pointer for Compatibility?
#include "lib.h"
int give_me_callback(Callback callback) {
return callback(1, 2.2, "3");
}
@b4284
b4284 / direct_vpn.md
Last active November 4, 2017 01:44
Get Instant VPN Using Tor and OpenVPN for Computers Behind Firewalls

Get Instant VPN Using Tor and OpenVPN for Computers Behind Firewalls

Scenario

Both computers are behind firewall and NAT, and both has direct access to the Internet.

Steps

Step 1: Computer A

  1. Install curl, Tor, OpenSSH and OpenVPN.
  2. Setup Tor, a Hidden Service, and SSH server. That is, having these lines in your Tor configuration file (usually /etc/tor/torrc):