Skip to content

Instantly share code, notes, and snippets.

Thomas Løcke ThomasLocke

Block or report user

Report or block ThomasLocke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ThomasLocke / passgen.hs
Created Jul 30, 2015
A Haskell noob trying to create sorta-kinda random passwords
View passgen.hs
import Control.Applicative
import System.Environment
import System.Exit
import System.Random
main = getArgs >>= parseArgs
-- Exit with success.
exit :: IO a
exit = exitWith ExitSuccess
ThomasLocke / countSomething.hs
Created Jul 3, 2015
Lad os tælle ting i lister af ting!
View countSomething.hs
-- Skriv en funktion der returnerer strengen:
-- This is an amazingly interesting sentence!
-- Skriv en funktion der returnerer hvor mange gange a findes i [a]
countSomething :: Eq a => a -> [a] -> Int
countSomething ???
-- Skriv ovenstående funktion i 3 udgaver:
-- 1. En der løser opgaven med list comprehension
ThomasLocke / sniplet.dart
Created Jun 30, 2015
En lille Dart sniplet
View sniplet.dart
import 'dart:convert';
import 'dart:io';
main(Args args) {
print(UTF8.decode(new File(args[0]).readAsBytesSync())
.map((s) => s.trim())
.join(' AND\n'));
ThomasLocke / haskell180615.hs
Created Jun 18, 2015
Haskell udfordringer 180615
View haskell180615.hs
-- Alle steder i ser ??? skal i skrive noget.
-- For bonuspoint:
-- Læs mere om List Comprehension her (langt nede på siden)
-- Opgave 1
-- Definer to type synonymer kaldet Name og Names.
-- Name skal være et synonym for String og Names for liste af Name.
ThomasLocke / printBook.hs
Created May 22, 2015
Playing around with Haskell type/data and a couple of simple functions
View printBook.hs
-- Lets pretty print a Book!
-- A couple of type synonyms for readability.
type Title = String
type Authors = [String]
-- Our Book data type.
-- A book consists of an isbn number, a title and a list of authors.
View gist:1e6b6e6ae344c099cef3
library shelfmiddleware.checktoken;
import 'headers.dart';
import 'token.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf_path/shelf_path.dart';
final shelf.Middleware checkToken = shelf.createMiddleware(requestHandler: _passOrForbid);
ThomasLocke / gist:8a64b8487e95f4c34555
Created Oct 12, 2014
View gist:8a64b8487e95f4c34555
library shelfmiddleware.headers;
import 'dart:io' show HttpHeaders;
const Map<String, String> textHtmlHeader = const {HttpHeaders.CONTENT_TYPE: 'text/html'};
const Map<String, String> CORSHeader = const {'Access-Control-Allow-Origin': '*'};
ThomasLocke / gist:5ba07e9ffbd689399fd4
Created Oct 12, 2014
View gist:5ba07e9ffbd689399fd4
library shelfmiddleware.token;
final List<String> _validTokens = new List<String>();
bool isValid(String token) => _validTokens.contains(token);
String getToken() {
final String token = new;
ThomasLocke / gist:a79096f4a369d8c310c6
Created Oct 12, 2014
View gist:a79096f4a369d8c310c6
library shelfmiddleware.handlers;
import 'headers.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf_path/shelf_path.dart';
shelf.Response app(shelf.Request request) {
final String myToken = getPathParameter(request, 'token');
ThomasLocke / gist:491c357a21082078b2ab
Created Oct 12, 2014
View gist:491c357a21082078b2ab
library shelfmiddleware.routes;
import 'handlers.dart' as handler;
import 'package:shelf_route/shelf_route.dart';
final Router routes = new Router()
You can’t perform that action at this time.