Skip to content

Instantly share code, notes, and snippets.

@thread13
thread13 / public_enc_example.sh
Created April 13, 2021 04:40 — forked from thinkerbot/public_enc_example.sh
Public-key encryption example using OpenSSL
#!/bin/bash
#
# Public-Key Encryption and Decryption
# * http://www.openssl.org/
# * http://barelyenough.org/blog/2008/04/fun-with-public-keys/
#
# Mac OS X 10.6.4
# OpenSSL 0.9.8l 5 Nov 2009
# Generate keys
@thread13
thread13 / sshpub-to-rsa
Created April 13, 2021 04:40 — forked from thwarted/sshpub-to-rsa
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
import sys
import base64
import struct
@thread13
thread13 / set_modtime.v.3.1.1-v3.patch
Created April 8, 2017 14:36
a proposed patch for rsync v. 3.1.1 to fix faulty nanosecond mtimes -- ignoring 1 second overflow as well ( at least Linux futimens() wants that )
diff -r 27d7a363f071 rsync.c
--- a/rsync.c Sat Apr 08 21:05:18 2017 +1000
+++ b/rsync.c Sat Apr 08 23:04:43 2017 +1000
@@ -549,7 +549,29 @@
flags |= ATTRS_SKIP_MTIME;
if (!(flags & ATTRS_SKIP_MTIME)
&& cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
- int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode);
+
+ /* tv_nsec is a long type */
@thread13
thread13 / set_modtime.v.3.1.1.patch
Last active April 8, 2017 14:33
a proposed patch for rsync v. 3.1.1 to fix faulty nanosecond mtimes
diff -r 534ce1d4fb97 rsync.c
--- a/rsync.c Sat Apr 08 20:56:59 2017 +1000
+++ b/rsync.c Sat Apr 08 21:02:00 2017 +1000
@@ -549,7 +549,21 @@
flags |= ATTRS_SKIP_MTIME;
if (!(flags & ATTRS_SKIP_MTIME)
&& cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
- int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode);
+ /* tv_nsec is a long type */
+ long ns = F_MOD_NSEC(file) ;
@thread13
thread13 / rsync.3.1.1.ignore-missing-times.v3.diff
Last active April 8, 2017 14:29
a proposed patch file for rsync 3.1.1 to ignore time/attr setting failures with --delete-missing-args or --ignore-missing-args
diff -r 0bbc80b2fd14 options.c
--- a/options.c Wed Apr 05 18:11:37 2017 +1000
+++ b/options.c Fri Apr 07 19:50:39 2017 +1000
@@ -2640,11 +2640,11 @@
}
}
- /* --delete-missing-args needs the cooperation of both sides, but
- * the sender can handle --ignore-missing-args by itself. */
+ /* both --delete-missing-args and --ignore-missing-args
@thread13
thread13 / rsync.3.1.3.ignore-missing-args.excerpts.c
Created April 7, 2017 12:10
rsync 3.1.1 : --ignore-missing-args
// definition
#line 941 options.c
{"delete-missing-args",0,POPT_BIT_SET, &missing_args, 2, 0, 0 },
{"ignore-missing-args",0,POPT_BIT_SET, &missing_args, 1, 0, 0 },
// structure definition -- just in case )
#line 115 popt/popt.h
@thread13
thread13 / rsync.3.1.2.ignore-missing-times.diff
Last active April 8, 2017 14:30
a proposed patch file for rsync 3.1.2 to ignore time/attr setting failures with --delete-missing-args or --ignore-missing-args
diff -r 5e35d4717bd7 options.c
--- a/options.c Thu Apr 06 20:00:09 2017 +1000
+++ b/options.c Fri Apr 07 20:01:03 2017 +1000
@@ -2642,11 +2642,11 @@
}
}
- /* --delete-missing-args needs the cooperation of both sides, but
- * the sender can handle --ignore-missing-args by itself. */
+ /* both --delete-missing-args and --ignore-missing-args
@thread13
thread13 / fsql.py
Last active October 14, 2023 11:38 — forked from jcarbaugh/fsql.py
#!/usr/bin/env python
# [ https://gist.github.com/jcarbaugh/100651/download# ]
# Convert a mysql dump into a sqlite-compatible format.
# I wrote this for just one script... no guarantees that it will work with others...
# python fsql.py < mysqldump.sql > readyforsqlite.sql
import re
import sys