Skip to content

Instantly share code, notes, and snippets.

Lance Pollard lancejpollard

View GitHub Profile
@rumkin
rumkin / chacha20.js
Last active May 29, 2020
Chacha20-Poly1305.js
View chacha20.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
function U8TO32_LE(x, i) {
return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24);
}
View memcpy.asm
page ,132
title memcpy - Copy source memory bytes to destination
;***
;memcpy.asm - contains memcpy and memmove routines
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
; memcpy() copies a source memory buffer to a destination buffer.
; Overlapping buffers are not treated specially, so propogation may occur.
View Quirks of C.md

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
       int x;
@ryohey
ryohey / vlq.js
Last active Nov 29, 2019
Convert Integer to Variable Length Quantity as an array. JavaScript で整数を可変長数値表現するコードが短く書けた
View vlq.js
function varIntBytes(v) {
const r = [v & 0x7f]
while ((v >>= 7) > 0) {
r.unshift(0x80 + (v & 0x7f))
}
return r
}
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active Jul 6, 2020
Linux: Understanding the Memory Layout of Linux Executables
View memory_layout.md

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@mshr-h
mshr-h / malloc.c
Created Jun 17, 2015
simple malloc implementation
View malloc.c
/* Include the sbrk function */
#include <unistd.h>
int has_initialized = 0;
void *managed_memory_start;
void *last_valid_address;
void malloc_init() { /* grab the last valid address from the OS*/
last_valid_address = sbrk(0);
/* we don't have any memory to manage yet, so
View README.md
@nikAizuddin
nikAizuddin / NASMx86: Allocate heap memory
Created Oct 12, 2014
Example using brk() system call for dynamic memory allocations
View NASMx86: Allocate heap memory
; 1 2 3 4 5 6 7
;01234567890123456789012345678901234567890123456789012345678901234567890
;=======================================================================
;+---------------------------------------------------------------------+
;| |
;| Example using brk() system call for dynamic memory allocations. |
;| |
;| DON'T CONFUSE that brk() used in C Function is different with brk() |
;| systemcall (systemcall 45 for x86 ASM). |
;| |
@kachayev
kachayev / css-parser.md
Last active Jun 3, 2020
Parsing CSS file with monadic parser in Clojure
View css-parser.md
@staltz
staltz / introrx.md
Last active Jul 11, 2020
The introduction to Reactive Programming you've been missing
View introrx.md
You can’t perform that action at this time.