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
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active June 17, 2024 09:54
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

@igrigorik
igrigorik / drive-appscript.js
Last active September 30, 2021 13:58
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" }
]
@bradfitz
bradfitz / gist:1080828
Created July 13, 2011 17:38
Go optional args, v2
package main
import (
"fmt"
)
type Person struct {
Name string
Age int
Position string
@jeresig
jeresig / .vimrc
Created May 4, 2011 16:46
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on