Skip to content

Instantly share code, notes, and snippets.

@sudarshansarolkar
sudarshansarolkar / Quirks of C.md
Created November 21, 2022 00:52 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
[gpg]
program = gpg
[core]
pager = less -S
warnAmbiguousRefs = true
editor = vim
excludesfile = /Users/kshibata/.gitignore_global
[branch]
autosetuprebase = always
[rerere]
@sudarshansarolkar
sudarshansarolkar / Indexer.java
Created June 13, 2018 16:11 — forked from mumrah/Indexer.java
Java class to index NYTimes data into Solr. Data available here http://archive.ics.uci.edu/ml/datasets/Bag+of+Words. Beware of hard coded paths and urls!
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
import java.io.IOException;

Generating Flame Graphs for Apache Spark

Flame graphs are a nifty debugging tool to determine where CPU time is being spent. Using the Java Flight recorder, you can do this for Java processes without adding significant runtime overhead.

When are flame graphs useful?

Shivaram Venkataraman and I have found these flame recordings to be useful for diagnosing coarse-grained performance problems. We started using them at the suggestion of Josh Rosen, who quickly made one for the Spark scheduler when we were talking to him about why the scheduler caps out at a throughput of a few thousand tasks per second. Josh generated a graph similar to the one below, which illustrates that a significant amount of time is spent in serialization (if you click in the top right hand corner and search for "serialize", you can see that 78.6% of the sampled CPU time was spent in serialization). We used this insight to spee

@sudarshansarolkar
sudarshansarolkar / machine_learned_index.py
Created December 20, 2017 21:05 — forked from tokestermw/machine_learned_index.py
Using deep learning to approximate a B-Tree index from this paper: https://arxiv.org/abs/1712.01208 (The Case for Learned Index Structures)
import click
import torch
import torch.autograd
import torch.nn.functional as F
from torch.autograd import Variable
import os
import random
import math
@sudarshansarolkar
sudarshansarolkar / netflix-priam-aws.md
Created March 30, 2017 17:14 — forked from diegopacheco/netflix-priam-aws.md
How to Run Netflix Priam?

Install java 8

# Remove java 7
sudo yum remove -y java

# Install basic packages
sudo yum install -y git

# Download and install java 8
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
@sudarshansarolkar
sudarshansarolkar / gist:3436aa506f0ccc705bf0
Created December 16, 2015 17:30 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@sudarshansarolkar
sudarshansarolkar / nginxproxy.md
Created October 30, 2015 22:35 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@sudarshansarolkar
sudarshansarolkar / q=*%3A*&wt=csv
Created October 28, 2015 16:01 — forked from mkhludnev/q=*%3A*&wt=csv
sample nested documents to demonstrate block join indexing and searching in Solr 4.5
id,_version_,BRAND_s,_root_,type_s,COLOR_s,SIZE_s
12,,,10,,Blue,XL
11,,,10,,Red,XL
10,1445176108735528960,Nike,10,parent,,
22,,,20,,Blue,XL
21,,,20,,Red,M
20,1445176108738674688,Nike,20,parent,,
32,,,30,,Blue,M
31,,,30,,Red,XL
30,1445176108740771840,Puma,30,parent,,
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,