Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Roman jeremyroman

View GitHub Profile
@jeremyroman
jeremyroman / setuid.c
Last active Aug 29, 2015
setuid by id
View setuid.c
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[]) {
uid_t uid = (uid_t) atoi(argv[1]);
setuid(uid);
execl("/bin/sh", "sh", (char*) 0);
return 1;
}
@jeremyroman
jeremyroman / index.html
Created Jul 8, 2014
DAOListView + Array = wtf?
View index.html
<!DOCTYPE html>
<script src="foam/core/bootFOAM.js"></script>
<link rel="stylesheet" href="foam/core/foam.css">
<script>
MODEL({
name: 'Widget',
properties: ['gizmo'],
});
@jeremyroman
jeremyroman / README.md
Created Jul 10, 2014
DAOListView + DAOListView = ???
View README.md

Expected: can see three lists of detail views. Actual: can only see the first one; inspecting the DOM reveals that all three of the nested list views have the same ID (in my case, view3)

View index.html
<!DOCTYPE html>
<script src="foam/core/bootFOAM.js"></script>
<link rel="stylesheet" href="foam/core/foam.css">
<script>
MODEL({
name: 'Gadget',
properties: ['id', 'inventor'],
});
@jeremyroman
jeremyroman / textblob-counter.diff
Created Sep 24, 2014
text blob counting patch
View textblob-counter.diff
diff --git a/Source/core/rendering/TextPainter.cpp b/Source/core/rendering/TextPainter.cpp
index 3901813..4133ea0 100644
--- a/Source/core/rendering/TextPainter.cpp
+++ b/Source/core/rendering/TextPainter.cpp
@@ -178,6 +178,8 @@ static bool graphicsContextAllowsTextBlobs(GraphicsContext* context)
return !context->strokeGradient() && !context->strokePattern() && !context->fillGradient() && !context->fillPattern();
}
+static unsigned long g_totalBlobsPainted = 0;
+
View gist:255e8b820c7d64479af1
class TestFontSelector : public FontSelector {
public:
static PassRefPtr<TestFontSelector> create(const String& path)
{
WebUnitTestSupport* unitTestSupport = Platform::current()->unitTestSupport();
String filePath = unitTestSupport->webKitRootDir() + path;
RefPtr<SharedBuffer> fontBuffer = static_cast<PassRefPtr<SharedBuffer>>(unitTestSupport->readFromFile(filePath));
return adoptRef(new TestFontSelector(FontCustomPlatformData::create(fontBuffer.get())));
}
@jeremyroman
jeremyroman / gist:815849
Created Feb 8, 2011
One possible way of describing languages
View gist:815849
languages = {
"C": {
'main_file': "{bot}.c",
'nuke_globs': ["*.o", "{bot}"],
'compile': [
System("gcc -O3 -c {file}", glob="*.c"),
System("gcc -O2 -lm -o {bot}", glob="*.o"),
],
'run': "./{bot}",
},
View gist:1057181
var f = function() {};
f.prototype.food = { apples: 0, bananas: 0 };
var f1 = new f();
f1.food.apples++;
var f2 = new f();
console.log(f2.food.apples); // 1
This is because the food object is modified in-place, and both instances refer to the same object.
View gist:1066483
// a.js
exports.message = 'hello world!';
exports.b = require('./b');
// b.js
var a = require('./a');
module.exports = function() { return a.message; }
View gist:1067452
var http = require('http'),
qs = require('querystring');
var body = qs.stringify({ method: 'system.connect' });
var options = {
host: 'www.goworkit.com',
port: 80,
path: '/services/json/',
method: 'POST',
headers: {