Skip to content

Instantly share code, notes, and snippets.

View pdsouza's full-sized avatar
🤘

Preetam D'Souza pdsouza

🤘
View GitHub Profile
@pdsouza
pdsouza / bogo2.c
Last active December 28, 2015 11:49
bogo2 for Mr. Alen Kubati
main(_,b,o,g,O){char s[]="@\r$rjre#|dgkwule#|ssdKjj&LOL";if(_^'*'>>1)main(-~_,_,~_,_,-~_);putchar(_--[s]-~0xFC);}
@pdsouza
pdsouza / ContentionTest.java
Last active January 1, 2016 17:29
Thread contention microbenchmark
import java.util.concurrent.atomic.AtomicInteger;
/**
* Simple thread contention microbenchmark consisting of
* concurrently updating a shared counter a bunch of times.
*
* Synchronization strategies used:
* (1) intrinsic monitor lock
* (2) compare-and-swap atomic instruction via AtomicInteger
*/
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFdSCQwBEAC+NYI25Vj5wsh2fpJ/D+1Q779hc5u0ap2CHTIkJm6+LIcb5jXS
+rbM7LT83V45Ehsj0XbgOLL5P8tudczs+y4XLBHrF//ZAKSUb1Ey7ek/4ixMZvsI
Vj+HV0vlEmpPbEd1KeM5W8QmSCzZrdgVrib492kpAh46uCiIDCiRpezihVIRDCKu
qcEtSxmY3/kubo8y35tma9I4kVt/YprxO5+2gTDNKHgriyBkL83MgxZUEhslHp9+
cd17iS6TS1IkNn4YWrnYIIqxu7T8Ac/dTczJDhHgOwMYkjtCYK+VFFNg+En12zzQ
xQFScbni858l3hJNjEVfkJGAynsLxyY2cb2/PJmyTHwy7wCk6QALruT0uxxD1TwQ
5rS+np/CqaZWrZO+Q12PEIMoLYPNa6/VLWcCGv6oTtXHjXPaejy53UQwnKQSwEkp
@pdsouza
pdsouza / git-notes.md
Last active May 29, 2019 12:17
notes on git

Quick reference

Which commits are on branch B, but not on branch A?

$ git log --oneline A..B

Which commits are not reachable from both A and B? (Symmetric difference)

$ git log --oneline A...B
@pdsouza
pdsouza / linux-kernel-debugging.md
Last active February 15, 2023 13:51
linux kernel: debugging

Linux Kernel Debugging

Debugging an Oops

Let's say we have a kernel oops like in maruos/platform_external_lxc#2 (comment). Here's the relevant snippet:

[  289.238687] Unhandled fault: synchronous external abort (0x96000010) at 0xffffff800087a000
[  289.238853] Internal error: : 96000010 [#1] PREEMPT SMP
[ 289.239003] CPU: 0 PID: 4928 Comm: lxc-start Not tainted 3.10.73-g84d48e8-00002-gfb7b9c7 #1
# http://stackoverflow.com/a/7944434/996825
def max_subarray(a)
sum = [0]
max, head, tail = sum[0], -1, -1
cur_head = 0
(0...a.size).each do |j|
# base case included below since sum[-1] = sum[0]
sum[j] = [0, sum[j-1] + a[j]].max