Skip to content

Instantly share code, notes, and snippets.

@lexszero
lexszero / cos_table.h
Last active September 29, 2020 07:37
Simple implementation of fixed point arithmetics with trigonometry functions
/*
* cos_table.h
*
* Table for more accurate computation of cosine function near zero argument
* See Common/fix.c:fix_sincos
*
* Created on: 20.06.2011
* Author: Alex Ignatov
*/
@lexszero
lexszero / pca9685.lua
Created December 26, 2014 03:38
PCA9685 driver for nodemcu firmware for ESP8266 module
local modname = ...
local M = {}
_G[modname] = M
local id = nil
local addr = nil
-- some flags from mode register, low byte is MODE1 and high is MODE2
M.INVERT = 0x1000
/* well, let's see who you are... */
int cmd_allowed(const char *s)
{
const char **c;
/* god is powerful */
if (godmode_active())
return 1;
/* don't hide your thoughts in emptiness */
@lexszero
lexszero / wifi_select.sh
Created April 9, 2015 23:49
Easily connect to WiFi network with just wpa_supplicant and Gentoo.
#!/bin/bash
iface='wlan0'
conf='/etc/wpa_supplicant/wpa_supplicant.conf'
fail() {
echo "Fuck you! $@"
exit 1
}
declare -a a
@lexszero
lexszero / bfx-calc.hs
Last active August 8, 2018 16:33
Bitfinex margin trading calculator
import Control.Monad.State
import Text.Printf
initiallyRequired = 0.3
maintenanceRequired = 0.15
takerFee = 0.002
type Amount = Double
type Price = Double
@lexszero
lexszero / bash_dbg.sh
Last active January 21, 2016 04:12
bash_dbg.sh
#!/bin/bash
file_log=`mktemp`
file_tim=`mktemp`
cleanup_tracing_files() {
rm -f $file_log $file_tim
unset file_log file_tim crt last
}
trap cleanup_tracing_files EXIT
exec 3>&2 2> >(
@lexszero
lexszero / wtfabber-log.pl
Last active February 14, 2016 10:34
A simple colorized pretty printer for Tkabber and MCabber XMPP clients chatlogs.
#!/usr/bin/perl
use strict;
use warnings;
use Term::ANSIColor;
my %nick_colors;
sub unescape($) {
my $x = shift;
$x =~ s/(^\{|\}$)//g;
type Huita struct {
v string
cb chan HuitaCmd
stop chan bool
}
func NewHuita() *Huita {
h := &Huita{
cb: make(chan HuitaCmd),
stop: make(chan bool),
@lexszero
lexszero / bfx.hs
Last active August 29, 2020 02:45
bfx.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.Reader hiding ( asks)
import Control.Monad.State.Lazy
import Control.Monad.Loops
import Text.Printf
--import Formatting
import Data.Aeson
@lexszero
lexszero / hatebot_parser.pl.pl
Created July 11, 2016 21:38
hatebot_parser.pl
#!/usr/bin/perl
use Storable;
use utf8;
use encoding utf8;
%data = %{ retrieve('dict')} if (-e 'dict');
print "Dict loaded\n";
while (<STDIN>) {
@words = split(/ /, clean_string($_));
$w1 = $words[0];
$w2 = $words[1];