Skip to content

Instantly share code, notes, and snippets.

View aredridel's full-sized avatar
💭
See my social media for status.

Aria Stewart aredridel

💭
See my social media for status.
View GitHub Profile
buffer = new Buffer(1024 * 1024);
buffer.readFrom(socketA);
buffer.writeTo(socketB);
... is this sys.pump, with a one megabyte buffer?
Make write throw an error when it would block (making sure people handle writes in the wouldblock case, not blocking nor throwing data away)
Make an enlargeable buffer for cases where you want the old growing-memory behavior of write()
@aredridel
aredridel / upload.js
Created December 19, 2010 04:25
Form file upload
var http = require('http')
var cl = http.createClient(80, 'dinhe.net');
var req = cl.request('POST', '/~aredridel/t.php',
{ host: 'dinhe.net', 'Content-Type': 'multipart/form-data; boundary=----asd123' })
req.write('------asd123\r\nContent-Disposition: form-data; name="file"; filename="test.txt"\r\nContent-Type: application/octet-stream\r\n\r\n')
req.write("Testing 123\r\n")
req.write("------asd123--r\n")
req.end()
typetable = Account.reflections[@input.type.intern].table_name
@accounts = @accounts.joins(@input.type)
@accounts.where(Contact.p(:id)).where(
Arel::Nodes::Grouping.new @accounts = [:first, :last, :company, :name].inject(@accounts) { |a,e|
Arel::Nodes::Or.new(a, Contact.p(e).matches("%#{@input.q}%"))
})
@aredridel
aredridel / codePage.patch
Created January 1, 2011 23:12
Fix for code page error
Index: Classes/PHPExcel/Shared/CodePage.php
===================================================================
--- Classes/PHPExcel/Shared/CodePage.php (revision 66289)
+++ Classes/PHPExcel/Shared/CodePage.php (working copy)
@@ -45,6 +45,7 @@
*/
public static function NumberToName($codePage = '1252')
{
+ if($codePage == 0) $codePage = 1252;
switch ($codePage) {
@aredridel
aredridel / gist:774092
Created January 11, 2011 06:07
Exception inheritance from jsdom
core.DOMException = function(code, message) {
this._code = code;
Error.call(this, core.exceptionMessages[code]);
this.message = core.exceptionMessages[code];
if(message) this.message = this.message + ": " + message;
if(Error.captureStackTrace) Error.captureStackTrace(this, core.DOMException);
};
core.DOMException.prototype = {
get code() { return this._code;},
aredridel@host ~/working ls testsparse
-rw-r--r-- 1 aredridel users 1000000001 Apr 24 00:27 testsparse
aredridel@host ~/working$ stat testsparse
File: `testsparse'
Size: 1000000001 Blocks: 32 IO Block: 4096 regular file
Device: fd02h/64770d Inode: 2408452 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 500/aredridel) Gid: ( 1000/ users)
Access: 2011-04-24 00:26:56.000000000 -0600
Modify: 2011-04-24 00:27:04.000000000 -0600
@aredridel
aredridel / Diagram.txt
Created September 4, 2011 03:48
Simple request/action/response and template example
Post
+-----+
| |
+-----------+-+ | +------------+
+--------------+ | | +-v------------+ | |
| | | Register | | | | Logged in |
| | | Template | | Do | | Template |
| Register | | | | Register | | |
| | | | | | | |
| | +-------^-----+ | | +--^---------+
@aredridel
aredridel / ifcfg-ppp0
Created October 28, 2011 02:17
PPP configuration for CentOS and PPPoA
# this file goes in /etc/sysconfig/networking/profiles/default
NAME=ppp0
BOOTPROTO=dhcp
TYPE=Modem
AC=off
BSDCOMP=off
VJCCOMP=off
CCP=off
PC=off
VJ=off
@aredridel
aredridel / action.js
Created November 6, 2011 22:34
jsviews demo
var image = {thumbnail: "/path/to/thumbnail", caption: "My really awesome image"}
$('thingtoactivateon').click(function() {
$($('#photoDetailsEdit').render(image)).dialog()
})
Rubinius Crash Report #rbxcrashreport
Error: signal SIGSEGV
[[Backtrace]]
0 rake 0x0000000100054a50 _ZN8rubiniusL12segv_handlerEi + 160
1 libsystem_c.dylib 0x00007fff90242cfa _sigtramp + 26
2 rake 0x00000001001f86ba _ZN8rubinius11CodeManager12add_resourceEPNS_12CodeResourceE + 74
3 rake 0x000000010005defb _ZN8rubinius11InlineCache11empty_cacheEPNS_2VMEPS0_PNS_9CallFrameERNS_9ArgumentsE + 91
4 rake 0x0000000100068597 _ZN8rubinius8VMMethod11interpreterEPNS_2VMEPS0_PNS_20InterpreterCallFrameE + 5447