Skip to content

Instantly share code, notes, and snippets.

Image to gameboy tile conversion

Mix.install([
  {:ex_png, "~> 1.0"},
  {:kino, "~> 0.11.2"},
  {:nx, "~> 0.6.3"}
])
# Here's a more advanced method that leverages the CIE 1931 XYZ color space
# and CIE Lab* color space to convert RGB to RGBW. This approach considers the color
# temperature of the white LED and takes into account human perception of color.
def gamma_correction(value):
if value <= 0.04045:
return value / 12.92
else:
return ((value + 0.055) / 1.055) ** 2.4
@lukad
lukad / sort.rb
Created September 23, 2022 09:25
#!/usr/bin/env ruby
# frozen_string_literal: true
array = [
'Selfie Stick,98,29',
'iPhone Case,90,15',
'Fire TV Stick,48,49',
'Wyze Cam,48,25',
'Water Filter,56,49',
'Blue Light Blocking Glasses,90,16',
pub fn sing(from: i32, to: i32) -> String {
(to..(from+1))
.rev()
.map(|i| verse(i) ).collect::<Vec<_>>()
.join("\n")
}
pub fn verse(n: i32) -> String {
let amount = bottles_of_beer(n);
@lukad
lukad / 0x07e43Ad3B70aa46A1Fe04bAc9072d0d0759C1479
Created October 16, 2017 13:29
0x07e43Ad3B70aa46A1Fe04bAc9072d0d0759C1479
0x07e43Ad3B70aa46A1Fe04bAc9072d0d0759C1479
@lukad
lukad / keybase.md
Last active February 5, 2016 09:19

Keybase proof

I hereby claim:

  • I am lukad on github.
  • I am lukad (https://keybase.io/lukad) on keybase.
  • I have a public key ASAKYuAXigzjI-t3cXeaNWFmh8Jr7SozhHaa21TQCLlmgwo

To claim this, I am signing this object:

@lukad
lukad / hello.dasm
Last active January 18, 2024 09:58
My hello world program in DCPU-16 ASM.
JSR main
; Main
:main
JSR setup ; Setup the hardware
SET A, msg ; Store msg in A for print_message
JSR print_message ; Print our message
SET PC, end ; End the program
@lukad
lukad / permute.go
Created November 14, 2012 15:00
permutations in go
package main
import (
"fmt"
"os"
"strconv"
)
func intRangeSlice(start, stop int) []int {
if start > stop {
@lukad
lukad / dna.go
Created November 9, 2012 14:12
rosalind.info problem #1 parallel solution
package main
import (
"fmt"
"io/ioutil"
"runtime"
)
func baseCountWork(data []byte, baseChan chan [4]int64) {
var bases [4]int64
@lukad
lukad / domain.rb
Created May 22, 2012 08:36
Glorius domain regex
/\A(?:[\w-]+(?<!-)\.){1,}[\w]{2,}\z/