Skip to content

Instantly share code, notes, and snippets.

View deoxxa's full-sized avatar

Conrad Pankoff deoxxa

View GitHub Profile
mysql> SHOW CREATE TABLE files\G
*************************** 1. row ***************************
Table: files
Create Table: CREATE TABLE `files` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`size` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`hash` char(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`time` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
<div id="offerblock">
<div class="offer">
<div class="offerleft">
<div class="showoffertitle">
<a href="<?php echo $json[$value]['url']; ?>"><?php echo $json[$value]['name']; ?></a>
</div>
<div class="showofferdescription">
<?php echo $json[$value]['description']; ?><br />
<?php if($json[$value]['user_reqs'] !== '') : ?><font color="red">*</font><?php echo $json[$value]['user_reqs']; ?><br /><?php endif; ?>
<?php if($json[$value]['conv_notes'] !== '') : ?><font color="red">*</font><?php echo $json[$value]['conv_notes']; ?><br /><?php endif; ?>
@deoxxa
deoxxa / gist:974163
Created May 16, 2011 09:48
Torrent Entry Markup
<!-- Torrent 9959f5af071ab200f34156303d0d412c521db9cb -->
<div id="torrent-9959f5af071ab200f34156303d0d412c521db9cb" class="torrent odd category-default">
<a class="title" href="/web/app_dev.php/indexer/view/9959f5af071ab200f34156303d0d412c521db9cb">[AniDub]_Naruto_Shippuuden_-_203_[1280_720_h264]_[Ancord].mp4</a>
<span class="comment">Comment: 日本 万歳! Михалков, ты ёбаная усатая сука! Гори а Аду! (комент от Weiss-куна)</span>
<ul class="stats">
<li>Size: <abbr title="315311313 bytes">315311313</abbr></li>
<li>Time: <abbr title="2011-03-19 09:18:42">2011-03-19 09:18:42</abbr></li>
</ul>
<ul class="links">
<li><a href="/web/app_dev.php/indexer/view/9959f5af071ab200f34156303d0d412c521db9cb">Details</a></li>
$rows = array_map(function($row) use ($data, $key_order, $post) {
return new DataObject(array(
'Fields' => new DataObjectSet(array_map(function($i) use ($data, $row, $post) {
return new DataObject(array(
'Name' => $data->keys[$i],
'Title' => $post[$data->keys[$i]],
'Value' => $row[$i],
));
}, $key_order)),
));
@deoxxa
deoxxa / presenter.js
Created June 26, 2011 07:57
Odd behaviour with mongodb-native
#!/usr/bin/env node
console.warn();
console.warn('==============================');
console.warn(' Buffered Information Gateway');
console.warn(' Presenter v0.0.1 ');
console.warn('==============================');
console.warn();
/**
mysql> SELECT * FROM Torrent WHERE hash = '66C3BB0B2CC2A97D6FC39AC2B60469C3B91E72C3'\G
*************************** 1. row ***************************
id: 2203
title: (成年コミック) [もりたかたかし] なかだしされたい [2009-07-10].zip
size: 105152320
hash: 66C3BB0B2CC2A97D6FC39AC2B60469C3B91E72C3
time: 2009-12-18 08:45:08
website: http://bigtorrent.dtiblog.com
comment:
1 row in set (0.00 sec)
@deoxxa
deoxxa / gist:1196540
Created September 6, 2011 03:57
CamelCase conversions in PHP
function hyphenToCamel($text)
{
return preg_replace_callback('#-([a-z])#', function($m) { return strtoupper($m[1]); }, $text);
}
function camelToHyphen($text)
{
return preg_replace_callback('#([A-Z])#', function($m) { return '-'.strtolower($m[1]); }, $text);
}
<?php
$ip = "192.168.1.190"; // Minecraft IP
$port = "25566"; // Minecraft port
$fp = fsockopen($ip, $port, $errno, $errstr, 5); // Socket for connecting to server
if (!$fp) {
echo "Error";
} else {
$out = "\xFE"; // Hex needed for server info
@deoxxa
deoxxa / stream.js
Created October 15, 2011 00:46
node http streaming
var server = require("http").createServer(function(srequest, sresponse) {
require("http").get({host: "host2", port: 80, path: "/xyz"}, function(cresponse) {
sresponse.writeHead();
cresponse.on("data", function(chunk) {
sresponse.write(chunk);
});
cresponse.on("end", function() {
sresponse.end();

I want to process multiple clients concurrently, but within each client I want to process their requests serially.

Say there's client A, client B and server S; below is an example of the communication flow I'm after:

D | A --(Q1)-(Q3)-(Q4)----------------> S
a | A <----------------(R1)-(R3)-(R4)-- S
t | B --(Q2)--------------------------> S
a | B <--------------------------(R2)-- S
   `_____________________________________