Skip to content

Instantly share code, notes, and snippets.

@sciolist
sciolist / CorsProxy.swift
Created July 8, 2015 08:07
GCDWebServer Cors proxy
import GCDWebServer
class CorsProxy {
init(webserver : GCDWebServer!, urlPrefix: String) {
var prefix =
(urlPrefix.hasPrefix("/") ? "" : "/")
+ urlPrefix
+ (urlPrefix.hasSuffix("/") ? "" : "/")
let pattern = "^" + NSRegularExpression.escapedPatternForString(prefix) + ".*"
@sciolist
sciolist / build.sh
Created March 17, 2013 00:21
Sectcreate
gcc -Os main.c -sectcreate __TEXT example example.txt
Param(
[string]$sourceRootPath
)
$paths=New-Object System.Collections.Generic.List[System.Object]
$paths.Add("C:\Program Files\nodejs")
$paths.Add("${HOME}\.dotnet\NuGetFallbackFolder")
$paths.Add("${HOME}\.nuget\packages")
$paths.Add("${HOME}\AppData\Local\Yarn")
$paths.Add("${HOME}\AppData\Roaming\npm")
@sciolist
sciolist / pack.js
Created October 9, 2013 23:36
awful browserify transform to pack in client config.
function packConfiguration() {
var config = require('../../client-config.js');
var clientConfig = 'module.exports=exports=(' + JSON.stringify(config) + ');\n';
var clientTransformFile = require.resolve('../../../../public/media/js/config.js');
return function clientConfigTransform(file) {
if(file !== clientTransformFile) return through();
var data = '';
return through(
function(inp) { data += inp; },
@sciolist
sciolist / package.json
Last active December 23, 2015 02:49
simple postgres one-way migration process
{
"name": "pomp",
"version": "0.1.0",
"bin": {
"pomp": "./pomp.sh"
}
}
@sciolist
sciolist / schema.xml
Created September 2, 2013 20:55
basic solr config
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.5">
<uniqueKey>id</uniqueKey>
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="client" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/>
<dynamicField name="*_i" type="tint" indexed="true" stored="true" multiValued="false" />
<dynamicField name="*_txt" type="text_sv" indexed="true" stored="true" multiValued="false" />
var index = new Index([
{ name: 'Moped', flags: ['slow', 'vehicle', 'red'] },
{ name: 'Car', flags: ['fast', 'vehicle', 'blue'] }
]);
index.facet('flags', function(m) { return m.flags });
var query = new BitField(index.items.length, true);
query.and(index.facets.flags.fast);
console.log(index.collect(query)); // [ { name: 'Car' } ... ]
query.or(index.facets.flags.red);
function Grid(w, h, minSize) {
if(w === undefined) w = 16384;
if(h === undefined) h = w;
if(minSize === undefined) minSize = Math.max(1, Math.max(w, h) / 1024);
this.root = {x:0,y:0,w:w,h:h};
this.minSize = minSize;
}
Grid.prototype.get = function(at) {
@sciolist
sciolist / README.md
Created October 16, 2015 06:52
Convert Viewstates to Json, for debugging.

ViewStateToJsonExporter

Hopefully you're free from Webforms and ViewStates by now.. But sometimes bad things happen to good people, and you need to find out why the viewstate of a decade old site is 5mb large. Inspecting the viewstate is all manners of not fun, so this little class could help!

Usage

To use the class, you'll need to overload the 'SavePageStateToPersistenceMedium' of a WebForms page, inside that you can call the Save-function of ViewStateToJsonExporter, and you'll get a nice big json dump!

@sciolist
sciolist / bookmarklet
Created September 3, 2012 08:45
Damn..
javascript:Array.prototype.slice.call(document.getElementsByTagName("*")).forEach(function(x)%20{for(var%20i=0;%20i<x.childNodes.length;%20++i)%20{var%20v%20=%20x.childNodes[i];%20if(v.nodeType%20!=%203)%20continue;%20if(!v.textContent.match(/[^\s]/))%20continue;v.textContent%20=%20v.textContent.replace(/[\w%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96]+/g,%20function(t)%20{var%20up%20=%20t[0].toUpperCase()%20==%20t[0];%20var%20vals%20=%20["fuck",%20"shit",%20"damn",%20"hell",%20"cock",%20"cunt",%20"ass"];%20var%20sel%20=%20vals[Math.floor(Math.random()%20*%20vals.length)];if(up)%20sel%20=%20sel[0].toUpperCase()%20+%20sel.substring(1);return%20sel});}});