Skip to content

Instantly share code, notes, and snippets.

View wieczorek1990's full-sized avatar

Łukasz Wieczorek wieczorek1990

View GitHub Profile
@wieczorek1990
wieczorek1990 / solemnisation.rb
Last active March 27, 2017 20:27
Solemnisation
funcs = %w(do re mi fa so la si 𝕕o)
# funcs = %w(Do Re Mi Fa So La Si do re mi fa so la si 𝕕o)
intervals = funcs.permutation(2)
puts "Functions count: #{funcs.length}"
puts "Permutation count: #{intervals.to_a.length}"
last = nil
intervals.each do |a, b|
if last != a then
last = a
@wieczorek1990
wieczorek1990 / random.fish
Created January 9, 2017 13:36
Random text fetcher
#!/usr/bin/fish
# Pulls random text from given directory.
set argc (count $argv)
if [ $argc -ne 1 ]
set d (pwd)
else
set d $argv[1]
end
@wieczorek1990
wieczorek1990 / main.sh
Last active August 21, 2017 03:42
Klavaro on Mac OS
GDK_PIXBUF_MODULEDIR=/usr/local/Cellar/gdk-pixbuf/2.36.0_2/lib/gdk-pixbuf-2.0/2.10.0/loaders
GDK_PIXBUF_MODULE_FILE=${GDK_PIXBUF_MODULEDIR}.cache
(export GDK_PIXBUF_MODULEDIR && export GDK_PIXBUF_MODULE_FILE && gdk-pixbuf-query-loaders --update-cache)
brew install gnome-icon-theme
brew upgrade homebrew/gui/klavaro
brew tap beeftornado/rmtree && brew install beeftornado/rmtree/brew-rmtree
@wieczorek1990
wieczorek1990 / circular_imports.txt
Last active May 20, 2016 09:00
Circular imports in Python & Ruby
./ruby/a.rb
require_relative 'b'
class B; end
class A
@b = B.new
end
./ruby/main.rb
@wieczorek1990
wieczorek1990 / Main.java
Last active May 5, 2016 22:04
Linked List in Java
class Book {
private int mPages;
public Book(int pages) {
mPages = pages;
}
public String toString() {
return String.format("This book has %d pages.", mPages);
}
@wieczorek1990
wieczorek1990 / r.sh
Last active August 29, 2015 14:07
Safe symbolic links removal
#!/bin/bash
# Useful when using `set mark-symlinked-directories on` in inputrc
# Install trash-cli first or replace `trash` with `rm -rf`
r() {
for arg
do
s=${#arg}
arg2=${arg:0:s-1}
if [ -L "$arg2" ]
@wieczorek1990
wieczorek1990 / mapt.sh
Last active August 29, 2015 14:07
Manually manage apt-get packages
#!/bin/bash
# Information is stored in ~/.packages
# Usage: install [-a|--as filename] packages
# uninstall filename | packages
install() {
mkdir -p ~/.packages
as=
force=
set -- `getopt -l as: a:f $@`
@wieczorek1990
wieczorek1990 / hapt.sh
Last active August 29, 2015 14:07
apt-get manually installed packages history
#!/bin/bash
# This will list all manually installed packages without: dependencies, uninstalled packages, packages installed during system installation.
unopts() {
echo "`cat`" | sed -r 's/ --[^ ]+//g;s/ -[^ ]+//g'
}
list() {
cat '/var/log/apt/history.log' |
grep --color=never -v '\-o APT::Status-Fd=4 \-o APT::Keep-Fds::=5 \-o APT::Keep-Fds::=6' |
@wieczorek1990
wieczorek1990 / simple-dft.cpp
Created October 6, 2014 20:38
Simple Discrete Fourier Transform
// Based on: http://nayuki.eigenstate.org/page/how-to-implement-the-discrete-fourier-transform
#include <iostream>
#include <vector>
#include <complex>
#include <cmath>
#include <cstdlib>
using namespace std;
vector<complex<double> > compute_dft(vector<complex<double> > in) {
int n = in.size();