Skip to content

Instantly share code, notes, and snippets.

View lancejpollard's full-sized avatar
🐢
Code

Lance Pollard lancejpollard

🐢
Code
View GitHub Profile
@lancejpollard
lancejpollard / dnsmasq_setup_osx.md
Created July 26, 2020 18:16 — forked from eloypnd/dnsmasq_setup_osx.md
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@lancejpollard
lancejpollard / binary-addition.js
Created July 6, 2020 02:40 — forked from nealfennimore/binary-addition.js
Binary addition in javascript
/**
* 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 ) ];
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 10:50 — forked from rumkin/chacha20.js
Chacha20-Poly1305.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 / client.c
Created April 5, 2020 02:43 — forked from suyash/client.c
TCP echo client-server in 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 December 10, 2019 09:02 — forked from mshr-h/malloc.c
simple malloc implementation
/* 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 / memory_layout.md
Created December 8, 2019 23:13 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@lancejpollard
lancejpollard / curses.md
Created November 24, 2019 10:36
Curses Reference by N. Matloff

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

@lancejpollard
lancejpollard / main.c
Created March 22, 2019 15:07 — forked from josephg/main.c
kqueue network & file example
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/event.h>
#include <netdb.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
@lancejpollard
lancejpollard / encryption.js
Created December 14, 2017 03:59 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv);