Skip to content

Instantly share code, notes, and snippets.

View vguerra's full-sized avatar
💭
🏂

Victor Guerra vguerra

💭
🏂
View GitHub Profile
@vguerra
vguerra / plot.awk
Created October 4, 2021 05:29 — forked from katef/plot.awk
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
diff --git a/utils/update_checkout/update_checkout/update_checkout.py b/utils/update_checkout/update_checkout/update_checkout.py
index 56e7ea24d4..54fcb18107 100755
--- a/utils/update_checkout/update_checkout/update_checkout.py
+++ b/utils/update_checkout/update_checkout/update_checkout.py
@@ -117,17 +117,17 @@ def update_single_repository(pool_args):
except Exception:
pass
- if checkout_target:
- shell.run(['git', 'status', '--porcelain', '-uno'],

Ex 1

document = sc.textFile("hdfs:///user/user172/5000-8.txt")
wordCounts = document.flatMap(lambda line: line.split()).map(lambda word: (word, 1)).reduceByKey(lambda left, right: left + right)
wordCounts.saveAsTextFile("hdfs:///user/user172/tp/wordcount")

Ex 2

@vguerra
vguerra / ast.txt
Created July 9, 2018 11:49
AST dump
(source_file
(top_level_code_decl
(brace_stmt
(defer_stmt
(func_decl implicit "$defer()" interface type='() -> ()' access=fileprivate
(parameter_list)
(brace_stmt
(call_expr type='()' location=../../../../examples/defer.swift:2:5 range=[../../../../examples/defer.swift:2:5 - line:2:28] nothrow arg_labels=_:
(declref_expr type='(Any..., String, String) -> ()' location=../../../../examples/defer.swift:2:5 range=[../../../../examples/defer.swift:2:5 - line:2:5] decl=Swift.(file).print(_:separator:terminator:) function_ref=single)
(tuple_shuffle_expr implicit type='(Any..., separator: String, terminator: String)' location=../../../../examples/defer.swift:2:11 range=[../../../../examples/defer.swift:2:10 - line:2:28] scalar_to_tuple elements=[-2, -1, -1] variadic_sources=[0] default_args_owner=Swift.(file).print(_:separator:terminator:)
@vguerra
vguerra / latency.txt
Created September 8, 2016 11:57 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@vguerra
vguerra / gist:fee51b92f3da901a147d
Created April 27, 2015 15:24
cvs merging back changes for openacs from a given branch
# Example using oacs-5-8 branch.
# tag first the desired branch
cvs checkout -r oacs-5-8 openacs-4
cd openacs-4
cvs tag -F vg-merge-oacs-5-8-date
# you can update the current checkout with
cvs up -A
@vguerra
vguerra / gist:11d13b572edd46816af0
Created March 9, 2015 10:46
Commits count per author email
git log --format=%ae |sort | uniq -c| sort -nr| less
@vguerra
vguerra / gist:2700a655499e510e9067
Created October 30, 2014 14:10
Modifying variables out of function scope via the stack
#include <stdio.h>
int fun() {
int a = 1;
int *p = &a;
while (*p != 10) {p++;}
*p = 30;
return 0;
}
@vguerra
vguerra / gist:53b03d589ecdbd93d31f
Created October 2, 2014 10:04
Eliminating branches with templates
#include <iostream>
#include <string>
template <bool B>
void Log(std::ostream& out, const std::string& str) {
if (B) {
out << str << "\n";
}
@vguerra
vguerra / gist:ad50cf2e2102b725b133
Last active August 29, 2015 14:06
Ordered insertion into a vector: using learn search vs. binary search
// Victor Guerra <vguerra@gmail.com>
// 2014-09-26
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>