Skip to content

Instantly share code, notes, and snippets.

@Makistos
Makistos / .emacs
Last active August 29, 2015 14:07
My .emacs file. #emacs #elisp
(add-to-list 'load-path "~/.emacs.d")
;; Increase window size
(if (window-system)
(set-frame-size (selected-frame) 124 40))
; Add more package sources
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("marmalade" . "http://marmalade-repo.org/packages/")
@Makistos
Makistos / cpri.py
Created October 22, 2014 07:54
Gets as input a file dumped from an oscilloscope that understands CPRI format. File should be csv with each line having a time and data value. Data values look like 'K28.5+' or 'D16.2-" or similar. This script finds some info from that file and prints it such as HFN and BFN. #python #cpri #bitarray
__author__ = 'mep'
import getopt
import sys
from bitstring import BitArray
line_bit_rates = ['614.4', # 0 filling bytes
'1228.8', # 1
'invalid', # 2
'2457.6', # 3
@Makistos
Makistos / pairs.hs
Last active August 29, 2015 14:07
A variation of the LOVE calculator. There are three versions of the actual calculator, they were provided as answers to my question at Quora: http://www.quora.com/How-do-I-sum-numbers-in-lists-by-pairs-until-just-one-pair-is-left. To try them out, replace the function call on line 66. #haskell
-- A variation of the LOVE calculator.
-- There are three versions of the actual calculator, they were provided as
-- answers to my question at Quora:
-- http://www.quora.com/How-do-I-sum-numbers-in-lists-by-pairs-until-just-one-pair-is-left
-- To try them out, replace the function call on line 66.
import Data.Char
import System.IO
import Data.List.Split
@Makistos
Makistos / ack-ubuntu-old.md
Last active August 29, 2015 14:08
Using Ack.vim in Ubuntu 12.04 #vim #vimrc

Command-line

sudo apt-get install ack-grep
sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep

.vimrc

nnoremap <leader>a :Ack 
" Search for word under cursor
nnoremap A :Ack  
@Makistos
Makistos / pairs.erl
Last active August 29, 2015 14:13
Pairs example written in Erlang (see Haskell version as well) #erlang
-module(pairs).
-export([main/0]).
%%%%
%% Counting characters in strings
%%%%
%% Count number of occurences of C in X.
count_char_in_string(C, X) -> length([Ch || Ch <- X,
Ch == C]).
@Makistos
Makistos / repo_heads.sh
Created February 27, 2015 11:33
Get the last commit for every repository under this directory in a nice tabular format #git #repo #git-log #column
# Requires repo tool from https://code.google.com/p/git-repo/
repo forall -p -c "git log -n 1 --pretty=tformat:'%Cblue%an%Creset|%ar|%s'" | column -t -s '|'
@Makistos
Makistos / git-change-summary.sh
Created March 13, 2015 14:28
Get a nice summary of your changes from a Git repo #git #git-log #column
git log --oneline --shortstat --author=Marko --pretty=tformat:'%Cblue%H%Creset|%ar|%s' | column -t -s '|'
@Makistos
Makistos / hiddenwords.py
Created July 14, 2015 19:09
This "oneliner" finds all words that can be created from the characters in the word given as a parameter. The list to match against in this example is a list of official Finnish words. #python #kotus #hidden_words
#!/usr/bin/python
# Create text list from Kotus list with
# sed -ne 's,.*<s>\(.*\)</s>.*,\1,p' kotus-sanalista_v1/kotus-sanalista_v1.xml > kotus_sanat.txt
#
# Kotus is an "official" list of Finnish words found from http://kaino.kotus.fi/sanat/nykysuomi/.
#
# This "oneliner" finds all words that can be created from the characters in the
# word given as a parameter.
@Makistos
Makistos / reading_sysfs_devices.c
Last active December 26, 2015 12:49
This code will print out all sysfs devices under a certain device class (which is supplied as a parameter). #linux #sysfs #c
#include <sysfs/libsysfs.h>
#include <stdio.h>
/**
* @brief Lists all the devices in the given class.
*
* @param className Name of the class (in /sys/class).
*/
void sysFsListDevices(char *className)
{
@Makistos
Makistos / interpolate.c
Created October 25, 2013 12:30
This simple code snippet shows how interpolating can be done in C using signed integers. The for() loop determinest the range to interpolate from. In this case -100 to +100. For loop is here just to work as an example. 12th line is were the work is done. 256.0 is the top end of the range while 201.0 is the number of values in the list to be inte…
#include <stdio.h>
#include <math.h>
int main()
{
int result;
double x;
int i;
for (i=-100;i<101;i++)