Skip to content

Instantly share code, notes, and snippets.

View KristofferK's full-sized avatar

Kristoffer KristofferK

View GitHub Profile
import pprint
class CountryCoordinateParser:
def __init__(self, path):
self.path = path
def parse(self):
countries = self.__getCountryAndCoordinates()
for country in countries:
countries[country] = self.__coordinateToTupleList(countries[country])
const isPalindrome = s => {
if (s.length < 2) return true;
if (s[0] !== s[s.length - 1]) return false;
return isPalindrome(s.substr(1, s.length - 2));
}
const testPalindrome = palindromeMethod => s => {
const result = palindromeMethod(s) ? "er et palindrom" : "er IKKE et palindrom";
console.log(s, result);
}
@KristofferK
KristofferK / index.html
Created November 17, 2017 20:44
debounceTime using setTimeout, rxjs and value matching
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Hej</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.5.0/Rx.min.js"></script>
</head>
<body>
<input id="input" type="text"/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<pre>Output 1: <span id="keystrokeOutput1"></span></pre>
@KristofferK
KristofferK / Program.cs
Created December 7, 2017 11:20
Example usage of .Except in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DistinctTest
{
class Program
{
interface IGrowthInformation {
angleInDegrees: number;
growth: number;
}
interface ICoordinate {
x: number;
y: number;
}
@KristofferK
KristofferK / Program.cs
Last active January 5, 2018 15:15
Formatting numbers
using System;
using System.Linq;
namespace NumberFormatter
{
class Program
{
private static Formatter formatter = new Formatter();
static void Main(string[] args)
{
@KristofferK
KristofferK / number-formatter.cs
Last active January 5, 2018 15:32
Formatting numbers alternative
using System;
using System.Collections.Generic;
using System.Linq;
namespace NumberFormatter
{
class Program
{
private static Formatter formatter = new Formatter();
static void Main(string[] args)
@KristofferK
KristofferK / ImgurDownloader.py
Last active July 30, 2019 20:42
Simple script to download images and videos from a Imgur category
import os
import re
import hashlib
import urllib.request
class ImgurDownloader:
destinationFolder = 'D:\\imgur-downloads\\'
pattern = re.compile('<img alt="" src="//([^"]+)"')
def __init__(self, category):
@KristofferK
KristofferK / Palindrome.cs
Created January 25, 2018 19:44
Simple palindrome checker
namespace Palindrome
{
class Program
{
static void Main(string[] args)
{
var palindromeChecker = new PalindromeCheckerImpl();
Console.WriteLine(palindromeChecker.IsPalindrome("den laks skal ned"));
Console.WriteLine(palindromeChecker.IsPalindrome("den laks skal ikke ned"));
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MatrixMultiplying
{
class Program
{