Skip to content

Instantly share code, notes, and snippets.

@nathanpc
nathanpc / .screenrc
Last active Aug 29, 2015
My .screenrc
View .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 Aug 29, 2015
THD Plotting Script
View plot_thd.py
#!/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 Aug 29, 2015
Calculates the resistor values to be used in a op-amp based linear voltage regulator according to a specific selection of voltage references.
View linear_vreg_res.R
#' 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 Jun 18, 2011
HelloWorld Dialog For Win32
View hello_dlg.asm
; 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
View tic-tac-toe.sh
#!/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 Jun 18, 2011
Booting a Kernel In The Middle Of a Floppy
View boot.asm
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 / div_neg.asm
Created Jun 18, 2011
Dividing By Negative Numbers
View div_neg.asm
; ********************
; * DIVIDE.ASM *
; ********************
.model small
.stack 512d
.data
a dw -9d
b db 2d
@nathanpc
nathanpc / vbe_mouse.asm
Created Jun 18, 2011
VBE And Mouse Use
View vbe_mouse.asm
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 Jun 18, 2011
Using Files As Databases
View addb.sh
#!/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 / ajax.js
Created Jun 18, 2011
Compatible AJAX Object Initialization
View ajax.js
function initAjax() {
var objXml = false;
if(window.XMLHttpRequest) {
objXml = new XMLHttpRequest(); // All modern browsers
} else if(window.ActiveXObject) {
try {
objXml = new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer 6
} catch(e) {
try {
objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 5