Skip to content

Instantly share code, notes, and snippets.

@nathanpc
nathanpc / .screenrc
Last active August 29, 2015 14:02
My .screenrc
# Autodetach session on hangup instead of terminating screen completely
autodetach on
# Set the colors to 256 and enable bold.
term screen-256color
attrcolor b ".I"
# 30.000-line scrollback buffer.
defscrollback 30000
@nathanpc
nathanpc / plot_thd.py
Last active August 29, 2015 14:05
THD Plotting Script
#!/bin/env python
### plot_thd.py
### Plot the THD of a circuit over a range of frequencies using ngspice.
###
### Author: Nathan Campos <nathanpc@dreamintech.net>
import os
import sys
import subprocess
@nathanpc
nathanpc / linear_vreg_res.R
Last active August 29, 2015 14:12
Calculates the resistor values to be used in a op-amp based linear voltage regulator according to a specific selection of voltage references.
#' linear_vreg_res.R
#' Calculates the resistor values to be used in a op-amp based linear voltage
#' regulator according to a specific selection of voltage references.
#'
#' @author Nathan Campos <nathanpc@dreamintech.net>
# Generates a E12 series of resistors.
e12_resistors <- function (steps = c(1000, 10000, 100000)) {
base = c(1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2)
e12 = c()
@nathanpc
nathanpc / hello_dlg.asm
Created June 18, 2011 15:55
HelloWorld Dialog For Win32
; Hello world in Assembler for the Win32 architecture
TITLE Hello world in win32. Tasm
VERSION T310
Model use32 Flat,StdCall
start_code segment byte public 'code' use32
begin:
Call MessageBox, 0, offset sHallo, offset caption, 0
@nathanpc
nathanpc / tic-tac-toe.sh
Created June 18, 2011 15:54
Tic-Tac-Toe Game
#!/bin/bash
#
#######################################################
# TIC TAC TOE #
# I WON'T GIVE YOU A CHANCE. YOU'LL NEVER WIN! #
#######################################################
# This program was developed as a funny way to test #
# the compatibility between arrays in ksh and bash. #
# Feel free for develop the module that the opponent #
# start playing, but don't forget to send me the new #
@nathanpc
nathanpc / boot.asm
Created June 18, 2011 15:58
Booting a Kernel In The Middle Of a Floppy
org 7C00h
mov ax, 1000h
mov ss, ax
mov sp, 0 ; Points to the top of the stack
mov ax, cs
mov ds, ax
mov ah, 02h ; Read sub function
mov al, 1 ; Number of sectors to read
@nathanpc
nathanpc / vbe_mouse.asm
Created June 18, 2011 15:51
VBE And Mouse Use
org 100h
main:
call set_video_mode
.main_loop:
call get_mouse_input
call draw_top_bar
call get_keyboard_input
@nathanpc
nathanpc / addb.sh
Created June 18, 2011 15:53
Using Files As Databases
#!/bin/sh
# Access AddressBook file and use it as a database
# Variables
name=$1
number=$2
db=AddressBook
### AddressBook File Example ###
# Maria Daher (27)5564-4392 #
@nathanpc
nathanpc / div_neg.asm
Created June 18, 2011 15:57
Dividing By Negative Numbers
; ********************
; * DIVIDE.ASM *
; ********************
.model small
.stack 512d
.data
a dw -9d
b db 2d
@nathanpc
nathanpc / os.asm
Created June 18, 2011 15:50
OS Hello World Example
[BITS 16] ; 16 bit code generation
[ORG 0x7C00] ; ORGin location is 7C00
JMP short main ; Jump past disk description section
NOP ; Pad out before disk description
; ------------------------------------------------------------------
; Disk description table, to make it a valid floppy
; Note: some of these values are hard-coded in the source!
; Values are those used by IBM for 1.44 MB, 3.5" diskette