Skip to content

Instantly share code, notes, and snippets.

View hydroid7's full-sized avatar

hydroid7

  • Bayern, Germany
View GitHub Profile
@hydroid7
hydroid7 / mme.jl
Last active August 7, 2022 18:24
Montgomery Modular Multiplication and Exponentiation in Julia
const N = 32
"""
Montgomery Modular Multiplication.
"""
function MMM(a::UInt32, b::UInt32, n::UInt32)::UInt32
s::UInt64 = 0
q::UInt32 = 0
for i::UInt32 in 0:N-1
# i-th bit of a shifted to the least significant position
@hydroid7
hydroid7 / board.lpf
Created June 9, 2022 12:33
Colorlight I5 Hardware constraint lpf file
SYSCONFIG CONFIG_IOVOLTAGE=3.3 COMPRESS_CONFIG=ON MCCLK_FREQ=62 SLAVE_SPI_PORT=DISABLE MASTER_SPI_PORT=ENABLE SLAVE_PARALLEL_PORT=DISABLE;
# 25 MHZ clock on the i5 board
LOCATE COMP "clk_i" SITE "P3";
IOBUF PORT "clk_i" IO_TYPE=LVCMOS33;
FREQUENCY PORT "clk_i" 25 MHZ;
# Built in LED
LOCATE COMP "led0" SITE "U16";
IOBUF PORT "led0" IO_TYPE=LVCMOS25;
@hydroid7
hydroid7 / .bash_aliases
Last active October 20, 2020 12:05
Multiple Project Environments for the Atom Editor without using the portable mode.
# So you've read this: https://github.com/atom/atom/pull/8442 but you don't want to use the Atom Portable version.
# The workaround is to alias the atom command :)
# Put this into your ~/.bash_aliases
alias atom-local='ATOM_HOME=$PWD/.atom atom $PWD'
# Starting Atom with the provided command above each directory conatains its own styles, plugins, etc.
# This way you can use Juno when you're working with Julia and use your standard js/vue/react plugins
# when doing some frontend development.
@hydroid7
hydroid7 / quicksort.hs
Last active November 18, 2019 08:59
The quicksrt algorithm in haskell
module Sorting (main) where
quicksort :: [Integer] -> [Integer]
quicksort [] = []
quicksort (x:xs) = quicksort smaller ++ [x] ++ larger
where
smaller = [a | a <- xs, a <= x]
larger = [b | b <- xs, b > x]
@hydroid7
hydroid7 / git-stats.jl
Last active April 22, 2019 19:50
Git stats with Julia. It uses the awesome package UnicodePlots.jl to draw some stats about the Git repository where this file is executed.
using UnicodePlots
const points = 20
function command(from, to)
start = "HEAD" * "^"^from
last = "HEAD" * "^"^to
`git diff --numstat $start $last`
end
data = zeros(points, 3)
@hydroid7
hydroid7 / generate_stop_motion.sh
Last active February 19, 2019 20:56 — forked from scips/generate_stop_motion.sh
Stop motion for hackers using Image Magick and ffmpeg
## Rename file
j=1;for i in `ls | grep -E ".png|.jpg|.jpeg|.PNG|.JPG|.JPEG"`; do prt=$(printf '%04d' $j);j=$((j + 1));mv -v $i "$prt.JPG"; done
mogrify -crop 1920x1080+362+628 *.jpg
## or resize
mogrify -resize 1920x1080 *.jpg
## morph if necessary !!! takes time
convert *.jpg -delay 10 -morph 10 %05d.morph.jpg
## create movie
ffmpeg -r 25 -i %05d.morph.jpg output.mp4
## or