Skip to content

Instantly share code, notes, and snippets.

Lance Pollard lancejpollard

View GitHub Profile
@lancejpollard
lancejpollard / binary-addition.js
Created Jul 6, 2020 — forked from nealfennimore/binary-addition.js
Binary addition in javascript
View binary-addition.js
/**
* Add two bits together and get resulting bits
*
* @param {Number} a bit a
* @param {Number} b bit b
* @returns {Array<Number, Number>} Carry and sum as a result of addition
*/
function addBits(a, b){
return [ +( a && b ), +( a !== b ) ];
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.
@lancejpollard
lancejpollard / chacha20.js
Created May 29, 2020 — forked from rumkin/chacha20.js
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);
}
@lancejpollard
lancejpollard / libuv-overview.c
Created Apr 11, 2020
High level overview of libuv looping.
View libuv-overview.c
int uv_run(uv_loop_t* loop, uv_run_mode mode) {
int timeout;
int r;
int ran_pending;
r = uv__loop_alive(loop);
if (!r)
uv__update_time(loop);
while (r != 0 && loop->stop_flag == 0) {
@lancejpollard
lancejpollard / client.c
Created Apr 5, 2020 — forked from suyash/client.c
TCP echo client-server in C
View client.c
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
const char* server_name = "localhost";
const int server_port = 8877;
@lancejpollard
lancejpollard / malloc.c
Created Dec 10, 2019 — forked from mshr-h/malloc.c
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
@lancejpollard
lancejpollard / Folder-Structure-for-Modern-Frontend-JavaScript-Apps.md
Last active Dec 9, 2019
Folder Structure for Modern Frontend JavaScript Apps
View Folder-Structure-for-Modern-Frontend-JavaScript-Apps.md

I have thought about folder structures for many years. What I've found is that there is no standard way to represent all things, you have to decide on something and either stick with it, or adopt an evolutionary development mindset (EDM). An EDM is one where you're free to test out new ideas and your code (or in this case, folder structure) is free to evolve into a better and better form as you uncover the mysteries of what is best in your case. You let your team create whatever folder structures they like, without enforcing it, and see what sticks. This will lead to variations in style, but you can then go through and change it again to be even better. Stuff like that.

What I've decided on for the frontend is something like this.

action

That's it! Now, everything in code in reality is an action if you boil it down. That is what assembly is if you take a look, just a bunch of actions. Every action can be composed into more and more complex action

@lancejpollard
lancejpollard / readme.md
Last active Dec 9, 2019
System Call List for Windows, Mac, and Linux
@lancejpollard
lancejpollard / memory_layout.md
Created Dec 8, 2019 — forked from CMCDragonkai/memory_layout.md
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
@lancejpollard
lancejpollard / curses.md
Created Nov 24, 2019
Curses Reference by N. Matloff
View curses.md

Introduction to the Unix Curses Library

Norman Matloff

Department of Computer Science

University of California at Davis

c 1997-2011, N. Matloff April 8, 2011

Contents

1 History 2 1.1 Purpose of the Curses Library 1.2 Evolution of the Role of Curses

You can’t perform that action at this time.