Skip to content

Instantly share code, notes, and snippets.

@alepez
alepez / gist:5780966
Created June 14, 2013 10:46
R: hexadecimal sum modulus 256 (samsung rs232 checksum)
sprintf("%02x", (0x11+0xff+0x01+0x01) %% 256)
@alepez
alepez / style.cpp
Last active December 18, 2015 12:18
C++ Style
/********** This begin a section **********/
/** This is short comment */
/**
* This is a long long
* long, but very long comment
*/
/**
@alepez
alepez / xorg.conf
Created June 20, 2013 15:33
nvidia twinview as ONE monitor, fullscreen
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
Option "Xinerama" "true"
EndSection
@alepez
alepez / midentify.rb
Last active December 18, 2015 21:49
midentify output to hash
def midentify(filename)
data = {}
`midentify "#{filename}"`.split("\n").each do |i|
m = i.split('=')
data[m[0]] = m[1]
end
return data
end
@alepez
alepez / alsa.conf
Created June 26, 2013 06:06
/etc/modprobe.d/alsa.conf enable only some devices, by ID or by vendor/product
options snd-usb-audio index=1,15 vid=0x0d8c,0x1d27 pid=0x000c,0x0601 enable=1,0,0
options snd-hda-intel index=0,11,12 id=PCH,NVidia,NVidia_1 enable=1,0,0
@alepez
alepez / Blur.compositor
Last active March 22, 2022 22:05
Ogre3d compositor and glsl shaders for Gaussian blur. It use a combination of horizontal blue and vertical blur.
compositor SceneCameraBlend
{
technique
{
texture scene target_width target_height PF_A8R8G8B8
target scene
{
input previous
}
target scene
@alepez
alepez / led_dim.cpp
Last active December 19, 2015 18:39
// imposta il numero del pin associato al led
int ledPin = 9;
// tiene in memoria il valore
int valore = 0;
void setup() {
// imposta il pin in modalita' OUTPUT
pinMode(ledPin, OUTPUT);
}
require 'open-uri'
require 'json'
album = JSON.parse(open('http://api.deezer.com/2.0/album/302127').read)
album["tracks"]["data"].map { |x| x["preview"] }.join(' ')
@alepez
alepez / 24xx_i2c_address.rb
Last active December 20, 2015 03:19
Calculate 24xx eeprom addresses relationship with A0-A1-A2
8.times { |i| p "0x#{(0x50 + i).to_s(16)} => A0: #{(i & 0x1) == 1 ? "HIGH" : "LOW "}, A1: #{((i & 0x2) >> 1) == 1 ? "HIGH" : "LOW "}, A2: #{((i & 0x4) >> 2) == 1 ? "HIGH" : "LOW "}" }
# "0x50 => A0: LOW , A1: LOW , A2: LOW "
# "0x51 => A0: HIGH, A1: LOW , A2: LOW "
# "0x52 => A0: LOW , A1: HIGH, A2: LOW "
# "0x53 => A0: HIGH, A1: HIGH, A2: LOW "
# "0x54 => A0: LOW , A1: LOW , A2: HIGH"
# "0x55 => A0: HIGH, A1: LOW , A2: HIGH"
# "0x56 => A0: LOW , A1: HIGH, A2: HIGH"
# "0x57 => A0: HIGH, A1: HIGH, A2: HIGH"
@alepez
alepez / redmine_identifier_update.sql
Created July 24, 2013 16:03
Redmine: change project identifier with sql query.
UPDATE projects SET identifier = 'new_identifier' WHERE identifier = 'current_identifier';