Skip to content

Instantly share code, notes, and snippets.

@akorobov
akorobov / rustup-install.md
Created March 19, 2017 19:15
Installing rustup in different location

To install rustup in different directory (i.e. /opt):

  1. install rustup in custom directory pointed to by RUSTUP_HOME envvar:
curl https://sh.rustup.rs -sSf | sudo RUSTUP_HOME=/opt/rustup sh -s -- -y
  1. select default tool chain
@akorobov
akorobov / emacs-25.2-term-24bit-colors.diff
Last active March 20, 2018 10:16
Patch for emacs 25.2 (rc2) to enable 24-bit colors in terminal
diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index f7a47f8..e9cfe7a 100644
--- a/doc/misc/efaq.texi
+++ b/doc/misc/efaq.texi
@@ -1491,6 +1491,39 @@ exhibits all the colors Emacs knows about on the current display.
Syntax highlighting is on by default since version 22.1.
+Emacs 26.1 and later support direct color mode in terminals. If Emacs
+finds Terminfo capabilities @samp{setb24} and @samp{setf24}, 24-bit

Keybase proof

I hereby claim:

  • I am akorobov on github.
  • I am akorobov (https://keybase.io/akorobov) on keybase.
  • I have a public key whose fingerprint is C507 2F37 C7A6 D970 C9E6 C0A3 AAD0 3E1A 6C26 B71F

To claim this, I am signing this object:

@akorobov
akorobov / reinit-sound.sh
Created March 15, 2014 17:54
Fix(audio subsystem reinitialization) for no sound in osx 10.9(.2?) after sleep with headphones in
sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext
sudo killall -9 coreaudiod
@akorobov
akorobov / ipv6-httpd.py
Created December 11, 2013 00:58
quick ipv6 http server using python's SimpleHttpServer
import socket
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class MyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/ip':
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
@akorobov
akorobov / PkiUtils.java
Created October 9, 2013 23:46
Example of reading and writing x509 certificate and RSA private keys encoded in PEM format using BouncyCastle 1.48 (new api)
public class PkiUtils {
public static final int MinPassPhraseLength = 4;
public static List<?> readPemObjects(InputStream is, final String pphrase)
throws IOException {
List<Object> list = new LinkedList<Object>();
PEMParser pr2 = new PEMParser(new InputStreamReader(is));
JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
JcaX509CertificateConverter certconv = new JcaX509CertificateConverter().setProvider("BC");
@akorobov
akorobov / no-itunes.sh
Last active December 17, 2015 10:29
Prevent iTunes from launching when using pause/plain/next/prev keysThis works in OS X 10.8.4+
sudo cp /System/Library/CoreServices/rcd.app/Contents/MacOS/rcd /System/Library/CoreServices/rcd.app/Contents/MacOS/rcd.orig
# make sure replace with equal number of spaces(we're patching executable binary)
sudo perl -pi -e 's#tell application id "com.apple.iTunes" to launch# #g' /System/Library/CoreServices/rcd.app/Contents/MacOS/rcd
# sign new binary
sudo codesign -f -s - /System/Library/CoreServices/rcd.app/Contents/MacOS/rcd
# restart
killall -9 rcd
@akorobov
akorobov / gist:5259538
Created March 28, 2013 00:42
c++ - statically typed language
#include <map>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
// map of int -> string
// note that string is not included
map<int, std::string> m;
// assigning integer instead of string
// compiles just fine, sigh...
@akorobov
akorobov / mono-light-theme.el
Last active December 14, 2015 03:59
emacs 24 monochrome theme based/inspired by https://github.com/fxn/monochrome-theme.el
(deftheme mono-light
"Light monochrome theme")
(let ((class '((class color) (min-colors 10)))
(black "#080808") ; black
(white "#fafafa") ; "white"
(lgray "#b3b3b3")
(dgray "#303030")
(sgray "#606060")
(sgray+1 "#707070")
@akorobov
akorobov / ut.sml
Last active December 12, 2015 04:59
Unittesting in SML
fun toStr (xs:int list) = List.foldl (fn (i,s) => Int.toString(i) ^ " " ^ s) "" xs;
(* returns true if all test cases were successful, false otherwise *)
fun test name (results:bool list) : bool =
let fun checkT (t, (failed, total)) =
if t then (failed, total + 1) else ([total+1] @ failed, total + 1)
val (failed, total) = List.foldl checkT ([], 0) results
in case (failed, total) of
(x::xs, t) => (print ("> Failed " ^ name ^ " [" ^ toStr(failed) ^ "] (total " ^ Int.toString(t) ^")\n") ; false)
| (nil, t) => (print ("> Success " ^ name ^ " (total " ^ Int.toString(t) ^")\n"); true)