This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <errno.h> | |
#include "iconv.h" | |
int main(void) { | |
size_t inbytesleft, outbytesleft; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/bnoordhuis/node-iconv/issues/16 | |
gc = require('iconv').gc; | |
Iconv = require('iconv').Iconv; | |
function randomIndex(a) { | |
return a[Math.floor(a.length * Math.random())]; | |
} | |
sourceEncodings = 'ascii iso-8859-1 utf-8'.split(' '); | |
targetEncodings = 'ascii iso-8859-1 utf-8 utf-16le utf-16be utf-32le utf-32be'.split(' '); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <pthread.h> | |
#include "markdown.h" | |
#include "xhtml.h" | |
#ifndef N_THREADS | |
#define N_THREADS 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP_STATUS_CODES = { | |
100: "Continue", | |
101: "Switching Protocols", | |
200: "OK", | |
201: "Created", | |
202: "Accepted", | |
203: "Non-Authoritative Information", | |
204: "No Content", | |
205: "Reset Content", | |
206: "Partial Content", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import sys | |
host, port = sys.argv[1:] | |
host = socket.gethostbyname(host) | |
port = int(port) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('http').createServer(function(req, res) { | |
console.error('Request', req.headers); | |
req.on('data', function(chunk) { | |
console.error('Received chunk', chunk, chunk.toString()); | |
}); | |
setTimeout(function() { | |
var body = "Hello World\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# normalize Accept-Encoding header | |
if (req.http.Accept-Encoding) { | |
if (req.url ~ "\.(jpeg|jpg|png|gif|gz|tgz|bz2|tbz|zip|flv|pdf|mp3|ogg)$") { | |
remove req.http.Accept-Encoding; # already compressed | |
} | |
elsif (req.http.Accept-Encoding ~ "gzip") { | |
set req.http.Accept-Encoding = "gzip"; | |
} | |
elsif (req.http.Accept-Encoding ~ "deflate") { | |
set req.http.Accept-Encoding = "deflate"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2011 by Ben Noordhuis <[email protected]> | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var host = '********'; | |
host += host; | |
host += host; | |
host += host; | |
host += host; | |
host += host; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres' | |
.split('') | |
.map(function(c) { return c.charCodeAt(0); }) | |
.map(String.fromCharCode); // corrupts data | |
.join(''); | |
// produces 'W\u0000\u0000i\u0001\u0000l\u0002\u0000l\u0003\u0000s\u0004\u0000t\u0005\u0000 \u0006\u0000d\u0007\u0000u\b\u0000 \t\u0000d\n\u0000i\u000b\u0000e\f\u0000 \r\u0000B\u000e\u0000l\u000f\u0000ü\u0010\u0000t\u0011\u0000h\u0012\u0000e\u0013\u0000 \u0014\u0000d\u0015\u0000e\u0016\u0000s\u0017\u0000 \u0018\u0000f\u0019\u0000r\u001a\u0000ü\u001b\u0000h\u001c\u0000e\u001d\u0000n\u001e\u0000,\u001f\u0000 \u0000d!\u0000i"\u0000e#\u0000 $\u0000F%\u0000r&\u0000ü\'\u0000c(\u0000h)\u0000t*\u0000e+\u0000 ,\u0000d-\u0000e.\u0000s/\u0000 0\u0000s1\u0000p2\u0000ä3\u0000t4\u0000e5\u0000r6\u0000e7\u0000n8\u0000 9\u0000J:\u0000a;\u0000h<\u0000r=\u0000e>\u0000s?\u0000' |