Skip to content

Instantly share code, notes, and snippets.

View rbanffy's full-sized avatar
🎯
Focusing

Ricardo Bánffy rbanffy

🎯
Focusing
View GitHub Profile
@rbanffy
rbanffy / index.html
Last active January 15, 2017 12:03
1 million map sets #jsbench #jsperf (http://jsbench.github.io/#b07102dd070c61f32381ac5341172e38) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>1 million map sets #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@rbanffy
rbanffy / index.html
Last active January 15, 2017 12:09
1 million obj[index] attributions #jsbench #jsperf (http://jsbench.github.io/#ce01d4e851c37d2d9a58bd646d5a3773) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>1 million obj[index] attributions #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
#!/bin/sh
function bitrate {
file $1 | sed 's/.*, \(.*\)kbps.*/\1/'
}
mp3file=$1
if [ $(bitrate $mp3file) -gt 192 ]; then
echo 'I should compress this'
@rbanffy
rbanffy / nsaname.yaml
Created April 12, 2017 16:50
Ansible playbook to rename your servers using nsaname (https://www.npmjs.com/package/nsaname)
---
- name: properly name servers
hosts: servers
become_method: sudo
vars:
source: 192.168.57.1
tasks:
- name: create hostname
local_action: command nsaname -h
@rbanffy
rbanffy / redshift.el
Created May 12, 2017 16:38
Redshift for Emacs
(defun sunset (color)
"Redshifts the #RRGGBB COLOR."
(let ((rgb
(mapcar
(lambda (x) (string-to-number x 16))
(list
(substring color 1 3)
(substring color 3 5)
(substring color 5 7)))))
(concat
@rbanffy
rbanffy / identifier_ranges.py
Created June 15, 2017 22:03
Show unicode identifier ranges for Python 3
"Show unicode identifier ranges."
in_identifier_range = False
for codepoint in range(int('10ffff', 16)): # Last mapped codepoint is U+10FFFF
if chr(codepoint).isidentifier() and not in_identifier_range:
# We are transitioning into a range.
in_identifier_range = True
start = codepoint
elif not chr(codepoint).isidentifier() and in_identifier_range:
# We are transitioning out of a range.
@rbanffy
rbanffy / terraform_up.sh
Last active September 25, 2017 11:47
Quick and very dirty Terraform updater
#! /bin/sh
curl -s -o /tmp/tf.zip $(curl -s https://www.terraform.io/downloads.html | grep darwin_amd64.zip | sed -e s/.*\=\"//g | sed s/\"\>.*//g)
unzip /tmp/tf.zip
sudo mv terraform $(which terraform)
@rbanffy
rbanffy / gist:5e3b04ca4555d37d744a1f0b5756e9a2
Created October 18, 2018 10:48
Make a sane hostname for my VMs
echo vm-$(ifconfig | fgrep ether | head -n 1 | awk '{ print $2 }' | sed -r s/[:]/-/g) > /etc/hostname
### Keybase proof
I hereby claim:
* I am rbanffy on github.
* I am rbanffy (https://keybase.io/rbanffy) on keybase.
* I have a public key ASAewHcvJxwUP9dNnxVJFWO8vSP6wEg7QK0oPd9vDDXzdQo
To claim this, I am signing this object:
@rbanffy
rbanffy / README.md
Created January 26, 2019 13:28
SCRIPT-8