Skip to content

Instantly share code, notes, and snippets.

View hjr3's full-sized avatar

Herman J. Radtke III hjr3

View GitHub Profile
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active May 24, 2024 09:48
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@cedelmaier
cedelmaier / comm_simple.rs
Created June 14, 2015 17:51
comm_simple
extern crate comm;
extern crate rand;
use std::{thread};
use comm::{spmc};
use rand::{Rng};
fn main() {
let (send, recv) = spmc::unbounded::new();

Web app development entails:

  • interacting with data
  • syncing ui and data
  • responding to user interaction (dom events)
  • user flow (navigating screens)
  • url (de)serialization
@karthick18
karthick18 / memcp.c
Last active October 20, 2022 16:48
A test case for overlapping memcpy which is unsafe as glibc resorts to a downward direction memcpy for anything >200 bytes (actually around 222 bytes) Strange as it makes no sense since it ends up impacting apps which don't use memmove for such cases and wasting debugging cycles on obscure data corruption bugs.
/*
* Test glibc overlapping memcpy.
* glibc resorts to a downward direction memcpy for anything exceeding ~200 bytes.
* No clue for the so-called optimization that breaks apps resorting to memcpy
* for overlapping boundaries instead of using memmove.
* This is only specific to x86_64/64 bit as for 32 bits, it always uses a forward memcpy.
*
* Try this --
* gcc -o memcp memcp.c -DHAVE_MEMCPY
* ./memcp
@postmodern
postmodern / comment.md
Last active January 11, 2024 15:37
Crypto Privacy Copy Pasta
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@lkuper
lkuper / fizzbuzz.rs
Last active December 10, 2015 10:48
October 14, 2013: Updated to work with Rust 0.8.
// FizzBuzz revisited
// This is a follow-up to the "FizzBuzz" chapter of "Rust for
// Rubyists" (http://www.rustforrubyists.com/book/chapter-06.html).
// We're going to take the code from there and refactor it to use
// pattern matching.
// Here's the original code from the book. The only change I've made
// is to comment out the original main() function so that we can write
// a few versions of our own.
@scoates
scoates / timeline
Last active December 10, 2015 09:29
Times each line of stdin
#!/usr/bin/env python
import time
from sys import stdin, stdout, argv, exit
try:
if argv[1] == 'help' or argv[1] == '--help' or argv[1] == '-h':
print "%s: times each line of stdin.\n Optional parameter is a float of a threshold. (defaults to 2.0)" % argv[0]
exit(255);
else:
@dergachev
dergachev / README.md
Created October 10, 2012 16:49
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM