Skip to content

Instantly share code, notes, and snippets.

View crsaracco's full-sized avatar

Charles Saracco crsaracco

View GitHub Profile
@crsaracco
crsaracco / random-haskell.md
Last active August 29, 2015 14:03
Random Haskell code

List of Primes:

primes = sieve [2..]

where sieve (p:xs) = p : sieve [x | x <- xs, x mod p /= 0]

@crsaracco
crsaracco / irc-bot.py
Created August 10, 2014 19:27
python-irc-bot-skeleton
import socket
#SETTINGS:
settings_server = ""
settings_port = 6667
settings_channel = ""
settings_botnick = ""
settings_botpass = ""
settings_owner = ""
settings_commandprefix = "!"
@crsaracco
crsaracco / tint2rc
Created August 20, 2014 15:13
Configs
# Tint2 config file
# Generated by tintwizard (http://code.google.com/p/tintwizard/)
# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure
# Background definitions
# ID 1
rounded = 0
border_width = 0
background_color = #000000 100
border_color = #000000 100
@crsaracco
crsaracco / colors.py
Created December 16, 2014 06:01
colors.py
def rgb2xyz(r, g, b):
var_r = r * 1.0 / 255
var_g = g * 1.0 / 255
var_b = b * 1.0 / 255
if var_r > 0.04045:
var_r = ((var_r + 0.055) / 1.055) ** 2.4
else:
var_r = var_r / 12.92
@crsaracco
crsaracco / colors.c
Created December 25, 2014 00:27
colors
#include <ncurses.h>
#include <time.h>
#include <stdlib.h>
#include <signal.h>
void print_block(WINDOW *win, int x, int y);
void print_block_color(WINDOW *win, int x, int y, int color);
void print_board(WINDOW *win);
static sig_atomic_t resize;
@crsaracco
crsaracco / arch-infinality.md
Created July 31, 2015 12:57
Arch linux good-looking fonts

https://bbs.archlinux.org/viewtopic.php?id=162098


Although manual building and installation of libraries needed for correct use of Infinality patches does not seem to be extremely difficult, I have realized that it is still confusing for many users as to what should be installed (and where) in order to make fonts render as expected. That is why, in order to simplify the process as much as possible, I decided to create a custom infinality-bundle repository, containing three obligatory packages (x86_64, i686 & multilib) that together should make your screens look way closer to mine.

In order to use the repository, please add the following to your pacman.conf:

[infinality-bundle]

Server = http://bohoomil.com/repo/$arch

@crsaracco
crsaracco / NextHammingWeight
Created February 11, 2014 18:32
NextHammingWeight - a function for finding the next int with the same hamming weight
/* I was searching for an algorithm that gave you the next integer (counting
* upwards) that has the same hamming weight as the current number, and I
* couldn't find anything. So here's a function that does that for you. If
* there is no 'next number' (i.e. this is the largest number that has this
* hamming weight), it simply returns the same number again.
*
* This can probably be optimized; I whipped it up pretty quickly. Relatedly, I
* only tested a few edge cases I could think of, so if you use this, be sure
* to test it more thoroughly.
*
@crsaracco
crsaracco / sine_generator.rs
Created November 15, 2017 00:56
Sine generator
#[macro_use] extern crate vst2;
use vst2::buffer::AudioBuffer;
use vst2::plugin::{Category, Plugin, Info, CanDo};
use vst2::event::Event;
use vst2::api::{Supported, Events};
use std::f64::consts::PI;
/// Convert the midi note's pitch into the equivalent frequency.
@crsaracco
crsaracco / lib.rs
Last active December 4, 2017 20:41
rust-vst segfault
// NOTE: This is the main.rs for the vst PLUGIN
#[macro_use] extern crate vst2;
use vst2::plugin::{Plugin, Info, Category};
use vst2::buffer::AudioBuffer;
struct HighFrequencyToneControl {
parameter: f32,
last_sample_left: f32,
@crsaracco
crsaracco / main.cpp
Last active September 26, 2018 04:06
Functional FizzBuzz
#include <iostream>
#include <functional>
using namespace std::placeholders;
bool ReplaceNumber(int a, int mod, std::string replacement) {
if (a%mod == 0) {
std::cout << replacement;
return true;
}