Skip to content

Instantly share code, notes, and snippets.

View balakrishnanc's full-sized avatar

Balakrishnan Chandrasekaran balakrishnanc

View GitHub Profile

The ffast and the Furious

This is a small and admittedly contrived demo showing how some weird but safe code could become vulnerable if run in an environment where some shared library has changed the FPU's FTZ/DAZ bits to force denormals to zero.

To run it:

# Create an empty file
$ touch gofast.c      
@alanthird
alanthird / noto-fonts.el
Last active November 2, 2023 14:22
Set up Noto fonts in Emacs
;; Provided by Sebastian Urban
;; More information at https://idiocy.org/emacs-fonts-and-fontsets.html
(set-fontset-font "fontset-default" 'adlam "Noto Sans Adlam")
(set-fontset-font "fontset-default" 'anatolian "Noto Sans Anatolian Hieroglyphs")
(set-fontset-font "fontset-default" 'arabic "Noto Sans Arabic")
(set-fontset-font "fontset-default" 'aramaic "Noto Sans Imperial Aramaic Regular")
(set-fontset-font "fontset-default" 'armenian "Noto Sans Armenian")
(set-fontset-font "fontset-default" 'avestan "Noto Sans Avestan")
(set-fontset-font "fontset-default" 'balinese "Noto Sans Balinese")
@waqaraqeel
waqaraqeel / get_cdn.py
Last active February 23, 2023 22:43
Figures out which CDNs were involved in a webpage fetch given HAR file.
#!/usr/bin/env python3
"""
Figures out which CDNs were involved in a webpage fetch given HAR file.
Requires dnspython
Borrows heavily from https://github.com/turbobytes/cdnfinder
Thank you to cdnplanet.com
Usage: ./get_cdn.py -f har-file
Or you could just import the get_cdn function
@allenday
allenday / bitcoin-cash.sql
Last active June 16, 2022 21:32
What are the current balances of a random set of 1000 addresses on blockchain X?
WITH double_entry_book AS (
-- debits
SELECT
ARRAY_TO_STRING(inputs.addresses, ",") AS address
, inputs.type
, -inputs.value AS value
FROM `bigquery-public-data.crypto_bitcoin_cash.transactions` JOIN UNNEST(inputs) AS inputs
WHERE block_timestamp_month = '2019-01-01'
UNION ALL
@allenday
allenday / gini-balance-bitcoin.sql
Created January 31, 2019 10:31
Calculate Gini coefficient for Bitcoin balances.
WITH double_entry_book AS (
-- debits
SELECT
array_to_string(inputs.addresses, ",") as address
, inputs.type
, -inputs.value as value
, block_timestamp
FROM `bigquery-public-data.crypto_bitcoin.inputs` as inputs
UNION ALL
@allenday
allenday / zero-fee-bitcoin-tx.sql
Created January 25, 2019 07:39
Find zero-fee Bitcoin transactions
SELECT
ROUND((input_value - output_value)/ size, 0) AS fees_per_byte,
COUNT(*) AS txn_cnt
FROM
`bigquery-public-data.crypto_bitcoin.transactions`
WHERE TRUE
AND block_timestamp >= '2018-01-01'
AND is_coinbase IS FALSE
GROUP BY 1
@cryzed
cryzed / fix-infinality.md
Last active January 19, 2024 08:56
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@henriquebastos
henriquebastos / 00-detect-virtualenv-sitepackages.py
Last active October 17, 2022 04:22
IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
"""IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
IPython can detect virtualenv's path and injects it's site-packages dirs into sys.path.
But it can go wrong if IPython's python version differs from VIRTUAL_ENV's.
This module fixes it looking for the actual directories. We use only old stdlib
resources so it can work with as many Python versions as possible.
References:
http://stackoverflow.com/a/30650831/443564
@willurd
willurd / web-servers.md
Last active April 25, 2024 09:21
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@railwaycat
railwaycat / mac-switch-meta.el
Created August 28, 2012 13:43
meta key switch
;; Keybonds
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper w)]
(lambda () (interactive) (delete-window)))
(global-set-key [(hyper z)] 'undo)