Skip to content

Instantly share code, notes, and snippets.

View geekingfrog's full-sized avatar
💭
🐸

Grégoire Charvet 黑瓜 geekingfrog

💭
🐸
View GitHub Profile
{-
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
@geekingfrog
geekingfrog / main.rs
Created May 26, 2020 12:37
simple load testing
#[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;
{-# 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 (..) )
{-# 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
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))
@geekingfrog
geekingfrog / bot-aoc.cabal
Last active December 18, 2016 10:12
aoc custom leaderbord
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: example@example.com
copyright: 2016 Author name here
@geekingfrog
geekingfrog / slack_history.py
Last active December 9, 2016 10:41
Get a slack team history
import sys
import traceback
import os
import aiohttp
import asyncio
import datetime
API_URL = 'https://slack.com/api'
print('args: ', sys.argv)
@geekingfrog
geekingfrog / http_duplicate.js
Last active October 15, 2015 08:44
simple http duplicator
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');
@geekingfrog
geekingfrog / gist:9aba1a96b81eb1afcbd6
Last active August 29, 2015 14:14
Trello hash haskell
-- 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 ()
@geekingfrog
geekingfrog / gist:cf90cf52d2e645b4a53c
Created November 16, 2014 07:06
Basic recursive call
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++);
})
}