Skip to content

Instantly share code, notes, and snippets.

View emres's full-sized avatar
💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming

Emre Sevinç emres

💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming
View GitHub Profile
@emres
emres / bash_multiline_comment.sh
Created August 22, 2019 08:57
Bash block and multiline comment styles
#!/usr/bin/env bash
: <<'### README ###'
Style 1
=======
This is a multiline comment, created by combining two relatively
less known Bash features, the `:` command, and Here Documents.
This has the advantage of less syntactic noise per line, and the
@emres
emres / enlighten.py
Created June 4, 2019 14:13
Get as many Zen koans as possible from GitHub API using Python
import time
import random
import requests
from requests.exceptions import HTTPError
koans = []
num_same_koan_found = 0
max_num_same_koan_found = 30
zen_url = 'https://api.github.com/zen'
@emres
emres / compare-monospace-fonts-ms-windows.el
Created May 9, 2019 09:50
Compare mono spaced fonts in MS Windows by printing the same string of text in all of them
;; see also:
;; https://gist.github.com/emres/917ffc60f4fe209a6a1bad6b3abd4fa1
(defun font-is-mono-p (font-name)
(string-match "-mono-" font-name))
(defun compare-monospace-fonts ()
"Display a list of all monospace font faces. Tested on MS Windows 10."
(interactive)
(pop-to-buffer "*Monospace Fonts*")
(erase-buffer)
@emres
emres / compare-monospace-font-families-linux.el
Created May 9, 2019 09:48
Print the same string of text in all the available fixed width (mono spaced) fonts in a new Emacs buffer
;; See the following for more details
;; https://emacs.stackexchange.com/a/50215/8887
;; and also see the following on a recent GNU/Linux or similar system:
;; /usr/share/doc/fontconfig/fontconfig-user.html
;; for the explanation of spacing=100
;; also see the following UNIX StackExchange answer:
;; https://unix.stackexchange.com/a/363368/13105
(defun compare-monospace-font-families ()
"Display a list of all monospace font faces. Tested on GNU/Linux."
(interactive)
@emres
emres / sample-mono-fonts.el
Last active April 30, 2019 13:06
Sample the mono spaced fonts in Emacs, printing the same line in different mono fonts
(defun font-is-mono-p (font-name)
(string-match "-mono-" font-name))
(defun compare-monospace-fonts ()
"Display a list of all monospace font faces. Tested on MS Windows 10."
(interactive)
(pop-to-buffer "*Monospace Fonts*")
(erase-buffer)
(dolist (font-name (x-list-fonts "*"))
(if (and (font-is-mono-p font-name)
@emres
emres / arc.py
Created January 15, 2019 15:56
Copy of ActiveState recipe: Adaptive Replacement Cache in Python
# Copy of ActiveState recipe: Adaptive Replacement Cache in Python
# Original URL, last visited on 15-Jan-2019:
# http://code.activestate.com/recipes/576532/
#
# For more details, please see the following:
# - http://u.cs.biu.ac.il/~wiseman/2os/2os/os2.pdf
# - https://www.usenix.org/conference/fast-03/arc-self-tuning-low-overhead-replacement-cache
# - https://www.usenix.org/conference/hotstorage15/workshop-program/presentation/santana
# - http://www.c0t0d0s0.org/archives/5329-Some-insight-into-the-read-cache-of-ZFS-or-The-ARC.html
# - https://blogs.oracle.com/roch/it-is-the-dawning-of-the-age-of-the-l2arc
@emres
emres / calendar-analytics-3.sh
Created March 23, 2018 12:41
Calendar Analytics 3
jq '.value[] .attendees[].emailAddress.name' events.json | sort | uniq | egrep -i -v \(Belgium\|meeting\|\emre\)
@emres
emres / calendar-analytics-2.sh
Last active March 23, 2018 12:35
Calendar Analytics 2
jq '.value[] .attendees[].emailAddress.name' events.json | sort | uniq
@emres
emres / calendar-analytics.sh
Created March 23, 2018 12:29
Calendar Analytics 1
jq '.value[] .attendees[].emailAddress.name' events.json
@emres
emres / control.sh
Created April 27, 2017 14:17 — forked from randerzander/control.sh
Ambari Service Start/Stop script
USER='admin'
PASS='admin'
CLUSTER='dev'
HOST=$(hostname -f):8080
function start(){
curl -u $USER:$PASS -i -H 'X-Requested-By: ambari' -X PUT -d \
'{"RequestInfo": {"context" :"Start '"$1"' via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' \
http://$HOST/api/v1/clusters/$CLUSTER/services/$1
}