Skip to content

Instantly share code, notes, and snippets.

; Function Attrs: nounwind readonly uwtable
define double @_Z10DotProductRK6VectorS1_(%class.Vector* nocapture %v1, %class.Vector* nocapture %v2) #0 {
entry:
%size_.i = getelementptr inbounds %class.Vector* %v1, i64 0, i32 0
%0 = load i64* %size_.i, align 8, !tbaa !0
%data_.i = getelementptr inbounds %class.Vector* %v1, i64 0, i32 1
%1 = load double** %data_.i, align 8, !tbaa !3
%size_.i8 = getelementptr inbounds %class.Vector* %v2, i64 0, i32 0
%2 = load i64* %size_.i8, align 8, !tbaa !0
%data_.i9 = getelementptr inbounds %class.Vector* %v2, i64 0, i32 1
@mikea
mikea / latency.txt
Created May 31, 2012 15:27 — forked from hellerbarde/latency.markdown
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
Read 1 MB sequentially from memory 250,000 ns 250 µs
Round trip within same datacenter 500,000 ns 0.5 ms
Disk seek 10,000,000 ns 10 ms
@mikea
mikea / gist:563022
Created September 2, 2010 21:55
appengine: upload data to blob programmatically
PAYLOAD_TEMPLATE = \
"""--==boundary\r
Content-Disposition: form-data; name="file"; filename="%s"\r
Content-Type: %s\r
\r
%s\r
--==boundary--\r
"""
destination_url = blobstore.create_upload_url('/upload-sink')
@mikea
mikea / gist:6493bdccad356297d471
Last active September 13, 2015 23:19
LazyGroupBy for RxJava
public static <K, T> Observable.Transformer<T, Pair<K, Observable<T>>> lazyGroupBy(
final Func1<? super T, ? extends K> keySelector) {
return new Observable.Transformer<T, Pair<K, Observable<T>>>() {
@Override
public Observable<Pair<K, Observable<T>>> call(Observable<T> observable) {
return Observable.create(s -> {
Map<K, Subscriber<? super T>> children = new HashMap<>();
Multimap<K, T> buffer = ArrayListMultimap.create();
Set<K> createdObservers = new HashSet<>();
// setup
int status = 0;
do {
// preconditions
status = doSomething();
if (status) break;
status = doSomethingElse();
if (status) break;
#include <stdio.h>
#include <time.h>
typedef unsigned int uint32;
typedef long long int64;
template<typename F, typename V>
V collision_point(const F& f, V x) {
V slow = x;
V fast = f(x);
===============
Unity generated
===============
Temp/
Library/
=====================================
Visual Studio / MonoDevelop generated
=====================================
ExportedObj/
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@mikea
mikea / gist:4c053e72a60d6f187cb6
Created June 12, 2014 18:52
Put cursor on ints in Arrays.asList expression and invoke Analyze Dataflow To Here
public class Test {
private static void foo(String value, int...ints) {
System.out.println(value + " " + Arrays.asList(ints));
}
private static void bar(String value, int...ints) {
foo(value, ints);
}
private static void baz(String value) {
@mikea
mikea / HeadTest.java
Created May 14, 2014 18:24
Attempt to implement headAndTail function. Results in double reading a file.
public class HeadTest {
public static void main(String[] args) {
Observable<Integer> fileReader = Observable.create((Observable.OnSubscribe<Integer>) subscriber -> {
System.out.println("Reading from a file");
subscriber.onNext(100); // header
for (int i = 0; i < 10; ++i) {
subscriber.onNext(i);
}