Skip to content

Instantly share code, notes, and snippets.

View l3kn's full-sized avatar

Leon l3kn

View GitHub Profile
from xml.dom import minidom
root = minidom.parse("weave.svg")
joinCount = 0
lines = []
for l1 in root.getElementsByTagName("line"):
x1 = l1.attributes['x1'].value
y1 = l1.attributes['y1'].value
@l3kn
l3kn / qr.cr
Created December 19, 2018 21:57
qr.cr
require "qrencode"
require "stumpy_png"
include StumpyPNG
qr = QRencode::QRcode.new("this is my input string")
margin = 20
size_with_margin = 300
size = size_with_margin - (margin * 2)
#include <iostream>
#include <string>
using namespace std;
class Book
{
string m_title;
string m_author;
string m_isbn;
require "./point"
require "./vector"
require "./aabb"
require "./ray"
require "./color"
require "./normal"
require "./materials/*"
require "./hitable"
struct ExtendedRay
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
overflow: hidden;
}
</style>
def test1
puts (1..10).to_a.map { |a| a.to_s }.join
end
def test2
puts((1..10).to_a.map { |a| a.to_s }.join)
end
def test3
puts (1..10).to_a.map do |a|
@l3kn
l3kn / benchmark.rb
Last active August 29, 2015 14:20
Exercism - Hamming Benchmark
require 'benchmark/ips'
require 'ruby-prof'
seq1 = 'GAGCCTACTAACGGGAT'
seq2 = 'CATCGTAATGACGGCCT'
module Allocation
def self.count
GC.disable
before = ObjectSpace.count_objects
@l3kn
l3kn / lazyFizzBuzz.rb
Created April 18, 2015 14:00
Lazy FizzBuzz
fizz = ["","","Fizz"].lazy.cycle
buzz = ["","","","","Buzz"].lazy.cycle
numbers = (1..Float::INFINITY).lazy
fizzbuzz = numbers.zip(fizz,buzz).map do |n,f,b|
(f.empty? && b.empty?) ? n.to_s : f + b
end
puts fizzbuzz.take(20).to_a
import java.util.*;
class MinMax extends Thread
{
int[] data;
boolean computeMin;
public int result = 0;
public MinMax(int[] f, boolean min){
data = f;
defmodule NLP do
def ngrams(0, _), do: []
def ngrams(_, []), do: []
def ngrams(n, list) do
ngrams(n, list, [])
end
def ngrams(n, list, acc) do
ngram = Enum.take(list, n)