Skip to content

Instantly share code, notes, and snippets.

View alfanick's full-sized avatar
💭
I may be slow to respond.

Amadeusz Leonardo Juskowiak alfanick

💭
I may be slow to respond.
View GitHub Profile
module TLC5947
class << self
def upscale(i)
(i / 255.0 * 4095.0).to_i % 4096
end
def compress(data)
data.map{|v|upscale(v).to_s(2).rjust(12, '0')}.join.scan(/.{8}/).map{|v|v.to_i(2)}
end
end
@alfanick
alfanick / .vimrc
Created February 24, 2013 14:26
Vim configuration
set nocompatible
set number
set ruler
syntax on
" Set encoding
set encoding=utf-8
" Whitespace stuff
@alfanick
alfanick / cache.rb
Created September 18, 2012 09:01
Simple Haml content caching
# Amadeusz Juskowiak <[email protected]> 2012 - MIT License
# 1. Put inside helpers do .. end
# 2. Set CACHE_DIR to somewhere writable and private (like CACHE_DIR=File.dirname(__FILE__) + '/tmp'
# 3. Use it! You can use fragment_expire to remove cache with given name.
#
# Example:
# %h1 foo
# = cache_fragment(:report, 300) do
# - data = get_data_slowly
@alfanick
alfanick / ra_li.cpp
Created April 30, 2012 19:51
Reprezentacje grafów
#include <cstdio>
#include <cstdlib>
#include "timer.h"
int main()
{
int n, k, x, y, r = 0, mockup = 0;
srand(time(0));
require "sinatra"
get '/' do
'Hello world!'
end
get '/hello/:name' do
"Hello #{params[:name]}"
end
PALETTE pal;
PACKFILE *file;
/* Open file */
file = pack_fopen(filename, "rb");
if (!file) some_error_func();
/* Read header before palette ... */
/* ... Some header reading code here ;) */
/* Read palette */
pack_fread(&pal, 1024, file);
@alfanick
alfanick / quotes.sh
Created June 6, 2011 19:57
Random quotes from Forismatic
#!/bin/bash
curl "http://api.forismatic.com/api/?method=getQuote&lang=en&format=text" | sed -e 's/(/\
\
/g' | sed -e 's/ )//g' | sed -e 's/)//g'
int ws = 640;
int st = 20;
int ed = 1;
int sd = 10;
void setup() {
size (ws, ws);
noStroke();
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define abs(x) (x>0?x:-x)
double f(double x)
{
$ gem list
** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0.beta3)
actionpack (3.0.0.beta3)
activemodel (3.0.0.beta3)
activerecord (3.0.0.beta3)
activeresource (3.0.0.beta3)
activesupport (3.0.0.beta3)