Skip to content

Instantly share code, notes, and snippets.

View shakeel's full-sized avatar

Shakeel Mahate shakeel

View GitHub Profile
@rseroter
rseroter / function.go
Created March 1, 2022 17:26
Go service that reads Google Cloud Storage objects
package goportable
import (
"encoding/json" //encoding the response
"log" //writing logs
"net/http"
"strings" //flattening an array
"cloud.google.com/go/storage" //talking to cloud storage
"github.com/GoogleCloudPlatform/functions-framework-go/functions" //go middleware
@shakeel
shakeel / windows-10-setup.md
Last active November 12, 2021 10:21
How I setup Windows 10

Setup Windows 10

Use scoop to install all of the UNIX command line tools and most of my needed software tools.

powershell
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop bucket add versions
scoop install curl
@algal
algal / NamesOnMacOS.md
Last active January 2, 2025 10:37
A note on how a Mac gets its various names

Names on macOS

Since I couldn't find documentation on how a Mac machine gets its name, I thought I'd write up these notes for my own reference later.

A macOS machine has a few different names, which might or might not be equal.

1. ComputerName

Every machine has a pretty user-facing name. This is the ComputerName.

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active December 3, 2025 17:13
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@jsomers
jsomers / android-websters.md
Last active May 7, 2025 02:42
Instructions for using Webster's 1913 on Android

To use Webster's 1913 dictionary on Android, install Colordict 3, an app that accepts this StarDict format. https://play.google.com/store/apps/details?id=com.socialnmobile.colordict

Next download James's S3 archive. https://s3.amazonaws.com/jsomers/dictionary.zip

You will need to extract the .dict file from inside three containers - .dz, .tar, .bz2 from innermost to outermost. 7zip handles all of these formats.

Place the .dict, .idx and .ifo files in the dictdata directory on your sdcard or local storage root. This is where colordict looks for dictionaries.

When the files are in the right place, you can run Colordict and tap the folder icon in the top right to see the dictionaries installed and set the dictionary priority. I put the 1913 dictionary above the defaults "Wordnet" and "Wikipedia." When you look up a word, ColorDict shows the definition, if available, from these multiple sources.

@igrigorik
igrigorik / drive-appscript.js
Last active September 13, 2024 07:27
Sample BigQuery queries for the HTTP Archive dataset.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Run Query", functionName: "runQuery"} ];
ss.addMenu("HTTP Archive + BigQuery", menuEntries);
}
function runQuery() {
var projectNumber = 'httparchive';
var sheet = SpreadsheetApp.getActiveSheet();
uint32_t FindMissing(uint32_t* arr) {
uint32_t res[4];
__m128i c = _mm_set1_epi32(0);
for (int i = 0; i < 100; i+=4) {
c = _mm_add_epi32(c,
_mm_loadu_si128((__m128i*)&arr[i]));
}
_mm_store_si128((__m128i*)res, c);
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@groks
groks / sequence.go
Created November 5, 2011 23:41
A Sequence object using Appengine's unimplemented AllocateIDs RPC
/* Sequence: https://gist.github.com/1342205
Example:
var defSeq *sequence.Sequence
func init() {
defSeq = sequence.Make("Default")
defSeq.BatchSize = 3 // for testing...
}
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]