Skip to content

Instantly share code, notes, and snippets.

@tausen
tausen / gist:1517302
Created December 24, 2011 13:02
MATLAB fancy plotting
%% FANCY PLOTTING %%
% Code by Mathias Tausen, 2011 %
% Contact: [email protected] %
% Version: beta 0.5 rev1, 191211 %
%----------------------------------------------------------%
% Eases the process of plotting data with MATLAB %
% %
% How to use: %
% - Specify the data files in the files cell, syntax: %
% files = {'file1';'file2';'file3'}; %
@tausen
tausen / gist:1547052
Created January 1, 2012 11:18
MATLAB fourier series test
syms n t;
% Set d to the series, using symsum()
d=1+symsum(sin(n/2*t)*(sin(((n+2)*pi)/(2))*4/(pi^2*n^2)+(-1)^n*2/(n*pi)),n,1,100);
% Prep an x-axis
t=linspace(-10,10,1000);
% Evaluate the values accordingly
data=eval(d);
% And plot it
plot(t,data);
@tausen
tausen / gist:1547398
Created January 1, 2012 13:58
MATLAB implicit plot
% Credits to Vincent Morio
% http://www.mathworks.com/matlabcentral/newsreader/view_thread/152947
% Limits
xlims = [-5 5];
ylims = [-5 5];
zlims = [-5 5];
steps = 30;
noedge = true;
@tausen
tausen / pstcustomshapes.tex
Created April 3, 2012 18:34
Custom pstricks/pst-circ shapes/components
\makeatletter
\def\tor(#1){%
\rput(#1){%
\pnode(0,0){or2}
\pnode([nodesep=0.5,angle=90]or2){or1}
\pnode([nodesep=0.25,angle=90]or2){ormid}
\pnode([nodesep=1]ormid){or3}
\psbezier[showpoints=false]{-}([nodesep=0.25,angle=100]or1)([nodesep=0.25,angle=5]ormid)([nodesep=0.25,angle=-5]ormid)([nodesep=0.25,angle=-100]or2)
\psline([nodesep=0.1]or2)([nodesep=-0.5]or2)
\psline([nodesep=0.1]or1)([nodesep=-0.5]or1)
@tausen
tausen / quicktest.c
Created May 17, 2012 14:57
AVR GCC UART Tx using interrupts
#define STRLEN 32
#define F_CPU 1843200UL
#define USART_BAUDRATE 115200
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#include <util/delay.h>
@tausen
tausen / truthtable-example
Created July 21, 2012 20:44
Simple command-line truth table generator example output
$truthtable "A&(B+C)&~D"
Evaluating: A&(B+C)&~D
A B C D R
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
1 1 0 0 1
0 0 1 0 0
1 0 1 0 1
@tausen
tausen / gist:3871013
Created October 11, 2012 08:35
Pstricks & pst-circ example
\begin{figure}[h!]
\begin{centering}
\begin{pspicture}(5,3)
%\psgrid % uncomment to show grid :)
\resistor[dipolestyle=zigzag,labeloffset=0.6](1,2)(3,2){$R_1$}
\newcapacitor[arrows=*-](3,2)(3,1){$C_1$}
\newground[connectingdot=false](3,1)
\wire[arrows=-o,arrowscale=1.5](1,2)(0.5,2)
\wire[arrows=-o,arrowscale=1.5](3,2)(4,2)
\rput(0,2){$V_i$}
@tausen
tausen / gist:4261887
Created December 11, 2012 20:30
pthread, sem_wait, sem_post example
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <semaphore.h>
sem_t semaphore;
void threadfunc() {
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Actions.SpawnOn
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
import XMonad.Actions.GridSelect
#!/bin/bash
case $1 in
0) xloadimage -zoom 70 -onroot ~/Pictures/emergence_by_alexiuss-d4n7gur.jpg ;;
1) xloadimage -zoom 100 -onroot ~/Pictures/emergence_by_alexiuss-d4n7gur.jpg ;;
2) xloadimage -fullscreen -onroot ~/Pictures/Metro_wallpaper2_1280x800.jpg 100 ;;
3) xloadimage -fullscreen -onroot ~/Pictures/Metro_wallpaper2_1920x1200.jpg 100 ;;
4) xloadimage -fullscreen -onroot ~/Pictures/Metro_wallpaper_1280x800.jpg 100 ;;
5) xloadimage -fullscreen -onroot ~/Pictures/Metro_wallpaper_1920x1200.jpg 100 ;;
*) echo 'Bad number'