Skip to content

Instantly share code, notes, and snippets.

View InPermutation's full-sized avatar

Jacob Krall InPermutation

View GitHub Profile
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(CCircCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CCircCtrl)
DISP_PROPERTY_NOTIFY(CCircCtrl, "CircleShape", m_circleShape, OnCircleShapeChanged, VT_BOOL)
DISP_PROPERTY_NOTIFY(CCircCtrl, "FlashColor", m_flashColor, OnFlashColorChanged, VT_COLOR)
DISP_PROPERTY_EX(CCircCtrl, "CircleOffset", GetCircleOffset, SetCircleOffset, VT_I2)
DISP_PROPERTY_EX(CCircCtrl, "Note", GetNote, SetNote, VT_BSTR)
DISP_STOCKPROP_BACKCOLOR()
if (a[o + 22 | 0] << 24 >> 24 == 24) {
if (!(Vp(d, o | 0) | 0)) {
break
}
p = (c[m >> 2] | 0) + (((c[h >> 2] | 0) - 1 | 0) * 40 & -1) + 12 | 0;
q = o + 28 | 0;
c[p >> 2] = c[q >> 2] | 0;
c[p + 4 >> 2] = c[q + 4 >> 2] | 0;
c[p + 8 >> 2] = c[q + 8 >> 2] | 0;
c[p + 12 >> 2] = c[q + 12 >> 2] | 0;
@import <foundation>
@implementation Person : CPObject
{
CPString name;
}
+ (id)personWithName:(CPString)aName
{
return [[self alloc] initWithName:aName];
}
- (id)initWithName:(CPString)aName
@InPermutation
InPermutation / Applet.java
Created June 13, 2013 02:39
The example applet from Wikipedia
import java.applet.Applet;
import java.awt.*;
// Applet code for the "Hello, world!" example.
// This should be saved in a file named as "HelloWorld.java".
public class HelloWorld extends Applet {
// This method is mandatory, but can be empty (i.e., have no actual code).
public void init() {
}
@InPermutation
InPermutation / gravataresponsive.js
Created May 13, 2013 22:26
gravatar.com URL resizing on DPI change (this is stupid)
setInterval(function(){
if(window.devicePixelRatio > 1) {
jQuery('img.profilePic').each(function(){
var el=this;
if(!el.src.contains('gravatar.com')) return;
el.src = el.src.replace(/\bs=(\d+)/,
function(match, px) {
return "s="+Math.round(window.devicePixelRatio*jQuery(el).innerWidth());
});
});
@InPermutation
InPermutation / negzero.js
Created March 29, 2013 20:45
Negative zero is not actually identical to positive zero.
// [true, true, true]:
[
0 === -0,
Math.atan2(0, -0) === Math.PI,
Math.atan2(0, 0) === 0
]
// [false, false]:
[
-0 < 0,
- return HttpResponse(simplejson.dumps(data), mimetype="application/json")
+
+ # The Django Session middleware helpfully adds 'Cookie' to the Vary header if request.session.accessed is true
+ # Firefox won't cache JSON if the response varies by cookie.
+ # Since we mark Cache-Control: private and max-age:60, the attack vector here is very very small:
+ # People on the same machine as the victim, who read the cache within 60 seconds
+ # So, let's fake out the session middleware to not send the Vary: Cookie header, just Vary: Accept-Encoding.
+ request.session.accessed = False
+
+ response = HttpResponse(simplejson.dumps(data), mimetype="application/json; charset=utf-8")
@InPermutation
InPermutation / evenness.js
Last active December 14, 2015 13:48
Show how to optimize corecursive functions using …exceptions?!
var throwup = require('throw').throwup, makecallable = require('throw').makecallable;
var even = throwup(_even),
odd = throwup(_odd);
var r = makecallable(_even)(parseInt(process.argv[2], 10) || 5000, 0);
console.log('found2', r);
function _even(n,j) {
if(n>0) return odd(n-1, j+1);
@InPermutation
InPermutation / tco.js
Last active December 14, 2015 12:38
Using throw.js, show how to tail-call optimize a recursive function using ...exceptions?!
var throwup = require('throw').throwup, makecallable = require('throw').makecallable;
var recurse = throwup(_recurse);
var callable_recurse = makecallable(_recurse);
var result = callable_recurse(parseInt(process.argv[2], 10) || 5000, 0);
console.log('found', result);
function _recurse(n, j) {
if(n>0) return recurse(n-1, j+1);
else return j;
@InPermutation
InPermutation / throw.js
Last active December 14, 2015 12:38
throwup(fxn) -> creates the inductive case of exception-tail-call-optimization makecallable(fxn) -> creates the trampoline for exception-tail-call-optimization
function throwup(fxn) {
return function() {
throw [fxn, Array.prototype.slice.call(arguments)];
}
}
function makecallable(fxn) {
return function() {
var params = Array.prototype.slice.call(arguments);
while(params) {