Skip to content

Instantly share code, notes, and snippets.

@MatejLach
MatejLach / razer-bwu13-macro.py
Created December 20, 2013 12:36
Razer BlackWidow keyboard - enable macro keys on Linux - updated for the 2013 Ultimate version.
#!/usr/bin/env python2
# blackwidow_enable.py
#
# Enables the M1-5 and FN keys to send scancodes on the Razer BlackWidow
# and BlackWidow Ultimate keyboards.
#
# You can use 'xev' and 'xbindkeys' to assign actions to the macro keys.
#
# Requires the PyUSB library.
@MatejLach
MatejLach / .vimrc
Last active August 29, 2015 14:01
Basic ViM setup for Go development - see https://github.com/MatejLach/vim for the full setup & updates
"" The Absolute Must ""
syntax on
set encoding=utf-8
set fileformats=unix,dos,mac " UNIX first
filetype plugin indent on
" pathogen
execute pathogen#infect()
@MatejLach
MatejLach / .zshrc_May14
Last active August 29, 2015 14:01
My (oh-my)-zsh config as of May 2014
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="bira"
# aliases
@MatejLach
MatejLach / init.el
Created May 28, 2014 19:14
Basic emacs setup for almost every programming language in mainstream use
;; Matej Lach's Emacs config...
;; DO NOT BYTE-COMPILE THIS FILE!
;; This config is released under the terms of 'MIT' license, but Emacs itself is licensed under the GPLv3.
;; For package-specific licenses, see the details for each individual project...
;; See the 'LICENSE' file for MIT license text.
;; Also see https://gnu.org/licenses/gpl.html for the full text of GPLv3.
;; Basics
@MatejLach
MatejLach / rust_expression.rs
Created July 18, 2014 13:34
Showcasing how expressions can be used in Rust
fn main() {
let x = 10i;
let y = if x < 5 {"x is less than 5"} else if x == 5 {"x is equal to 5"} else if x > 5 {"x is more than five!"} else {"x is unknown!"};
println!{"{}", y};
}
@MatejLach
MatejLach / hello_world.rs
Created July 20, 2014 10:59
Hello World in Rust...
fn main() {
println!("Hello Rust!");
}
@MatejLach
MatejLach / euler1.rs
Created July 21, 2014 13:58
Demonstrates a case where one has to use mutable variables in Rust
// Solution to Project Euler problem 1,
// https://projecteuler.net/problem=1
fn main() {
let (i, result) = (0i, 0i);
while i < 1000 {
if i%3 == 0 || i%5 == 0 { result += i }
i += 1
}
println!("{}", result);
@MatejLach
MatejLach / patternmatch.rs
Created July 23, 2014 12:35
Pattern matching in Rust...
fn main() {
let x = 3.75f64;
match x {
1.0..1.99 => println!("x is between one and two"),
2.0..2.99 => println!("x is between two and three"),
3.0..3.99 => println!("x is between three and four"),
4.0..4.99 => println!("x is between four and five"),
5.0..5.99 => println!("x is between five and six"),
_ => println!("x is bigger than five") // catches all other possible values of `x`
@MatejLach
MatejLach / ifelse.rs
Created July 29, 2014 14:06
if/else Rust example...
fn main() {
let lang = "Rust";
if lang == "Rust" {
println!("The next-gen systems programming language!");
} else if lang == "Haskell" {
println!("A high-level, purely functional programming language.");
} else if lang == "Elixir" {
println!("Another aspiring, functional language.");
} else {
@MatejLach
MatejLach / for_while.rs
Created July 29, 2014 15:35
An example of a nested for/while loop in Rust...
fn main() {
let lang = "Rust";
let rust_is_amazing = true;
let mut count = 0i;
for _ in range(0i, 5) {
while count < 10 && rust_is_amazing == true {
println!("Is, {} amazing? {}", lang, rust_is_amazing);
count += 1;
}