This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
The idea is to have a way to handle user settings | |
in an IRC bot. Something like | |
Set UserTimezone SomeTimeZone | |
Unset UserTimezone | |
Set UserDoB (1990, 1, 1) | |
Unset UserDoB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate log; | |
extern crate crossbeam_channel; | |
extern crate crossbeam_utils; | |
extern crate reqwest; | |
extern crate simple_logger; | |
use crossbeam_channel::bounded; | |
use crossbeam_utils::thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module Main where | |
import Data.Valor ( Validatable, Validate ) | |
import Data.Text ( Text ) | |
import Data.Functor.Identity ( Identity (..) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Orphan where | |
import qualified Hedgehog as H | |
import qualified Hedgehog.Gen as Gen | |
import qualified Hedgehog.Range as Range | |
import qualified Crypto.PubKey.Curve25519 as Curve25519 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data MyState s a = MyState (s -> (a, s)) | |
get :: MyState s s | |
get = MyState (\s -> (s, s)) | |
put :: s -> MyState s () | |
put s = MyState (const ((), s)) | |
modify :: (s -> s) -> MyState s () | |
modify f = MyState (\s -> ((), f s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bot-aoc | |
version: 0.1.0.0 | |
synopsis: Simple project template from stack | |
description: Please see README.md | |
homepage: https://github.com/githubuser/bot-aoc#readme | |
license: BSD3 | |
license-file: LICENSE | |
author: Author name here | |
maintainer: [email protected] | |
copyright: 2016 Author name here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import traceback | |
import os | |
import aiohttp | |
import asyncio | |
import datetime | |
API_URL = 'https://slack.com/api' | |
print('args: ', sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const forward = {host: 'duckduckgo.com', port: 80}; | |
const duplicates = [{host: 'google.com', port: 80}]; | |
const trace = console.trace.bind(console); | |
process.on('uncaughtException', console.trace.bind(console, 'uncaught exception:')); | |
const http = require('http'); | |
const request = require('request'); | |
const dns = require('dns'); | |
const Promise = require('bluebird'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- the "hash" is actually a number in base 37, starting at 7 | |
-- and digits are less than 15 | |
data Letter = A | C | D | E | G | I | L | M | N | O | P | R | S | T | U | W deriving (Eq, Ord, Bounded, Enum, Show, Read) | |
-- point free and obfuscated version for demo purpose | |
reverseHash :: Int -> [Letter] | |
reverseHash = tail . reverse . map (toEnum . (`mod` 37)) . takeWhile (/= 0) . iterate (`div` 37) | |
main :: IO () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parsePage(url, depth) { | |
if(!depth) depth = 1; | |
if(depth > 3) return; | |
// here, fetch the page and save it to disk | |
// then process each links | |
extractLinksFromPage(body).forEach(function(link) { | |
parsePage(link, depth++); | |
}) | |
} |
NewerOlder