Skip to content

Instantly share code, notes, and snippets.

View benjamn's full-sized avatar

Ben Newman benjamn

  • Apollo Graph, Inc (formerly: Meteor, Facebook/Instagram, Quora, Mozilla)
  • New York City
  • 21:21 (UTC -04:00)
View GitHub Profile
L-( ;P :)>- !!!!!! hah ;-( P) hahahah lololololol 8-( >:( lolololol P) :-> <:o) /:-) :X 8-( :O 8( ;-( :T (O.o) !!!!!!!!!! hahahaha :(|) :S B( $-) <:-p =-( lolololol :-S :-( :-B $( >:( :)>- :P :| :-> :-# :* $-( >>:) >:( hahahahah :-\ B-( :P hahahahahah :-( :b !! /:-) >>:) :x :-\ :-b :-b :-P hehehe (o.O) hehehe (o.O) >:) |-) =-) <:o( hehehehehe :-< :-T lololololol :( <:-P :-B hehe >>:) >>:-( :b :^O hehehe =) ;( :-\ :( P( ;-) :-X !!!!! ;-( //:| |-) hehehehehehe !!!!! :-x :-| $( ha hahah ;) !!!!! :| 8-( :-* hahaha $) heheheheheh hehehehehe /:( ;-) 8-( :X P) <:o) :-( ;P :b :-b ;-P :-D heheheheh :\ |-) 8-( :@( hahahah +o( |-) =-) >>:-) :(|) >:-) ! :-P =-( B( :-) :S !!!!!! $-( !! !!!!! :-b B( heheheheheh :-S 8-) !!! =) (o.O) :-> :s X-D >>:( :-& :B hahahaha /:-) :-# :-s :^o $( :-> :( >:o hahahahaha hahahahahaha O:) P) :> /:-( heheheh B-) <:-p //:| !! ;) B-( b-( :? O:) :-\ :> :^O X-D :O L-( :> heheh lololol $( :X heheh hahahahahaha :D ;-) O:( =-) heh |-( :-B +o( >>:-( P) :-* lololololol :-X :-S <:-p lolololololol ;( h
extern bool compare_and_swap(void** vp, void* cmp, void* val);
template <class T>
bool CASRefs(T** vp, T* cmp, T* val)
{
if (val)
val->AddRef();
if (compare_and_swap(vp, cmp, val)) {
if (cmp)
cmp->Release();
function diff(a, b) {
[].sort.call(arguments);
return b - a;
}
console.log(diff(3, 5));
console.log(diff(5, 3));
Overlapping 1 time:
x-
x-
Overlapping 1 time:
xx-x-
x-xx-
Overlapping 1 time:
xxx-xx-x-
#!/usr/bin/env python
def count_down_up(max):
countdown = "-".join("x" * (max - i) for i in range(max)) + "-"
countup = "-".join("x" * i for i in range(1, max+1)) + "-"
overlaps = 0
for i in range(min(len(countup), len(countup))):
if countdown[i] == "-" and countup[i] == "-":
overlaps += 1
return overlaps, countdown, countup
class EventQueue {
Queue<nsIRunnable> mQueue;
PRBool mWaiting;
mozilla::Monitor mRarelyUsedMonitor;
public:
EventQueue()
: mQueue()
, mWaiting(0)
, mRarelyUsedMonitor("EventQueue::mRarelyUsedMonitor")
{}
Object.create = function( proto, props ) {
var ctor = function( ps ) {
if ( ps )
Object.defineProperties( this, ps );
};
ctor.prototype = proto;
return new ctor( props );
};
template <typedef T>
class hazard_manager {
template <unsigned Exp = 8>
class zet {
static const PRInt32 sCapacity = 1 << Exp;
hazard* mStore[sCapacity];
PRInt32 sCount;
public:
zet() : sCount(0) {
diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -920,17 +920,17 @@ nsHTMLDocument::StartDocumentLoad(const
"not nsICachingChannel");
rv = cacheDescriptor->SetMetaDataElement("charset",
charset.get());
NS_ASSERTION(NS_SUCCEEDED(rv),"cannot SetMetaDataElement");
}
#define paste(x, y) x##y
#define blah(x) paste(blah, x)
int main()
{
int blahbar = 0;
return blah(FOO);
}