Skip to content

Instantly share code, notes, and snippets.

#
# Validate dates of type DD.MM.YYYY
# consider number of days in month and leap years
# also year span is from 1900 to 2999
#
my $re = qr{
^(?:(?:31\.(?:0?[13578]|1[02]))\.|(?:(?:29|30)\.(?:0?[1,3-9]|1[0-2])\.))(?:(?:19|2\d)?\d{2})$
|
^(?:29\.0?2\.(?:(?:(?:19|2\d)?(?:0[48]|[2468][048]|[13579][26]))))$
|
import './index.css'
createCanvas = (el, width, height) ->
c = document.createElement 'canvas'
ctx = c.getContext('2d')
c.setAttribute 'width', width
c.setAttribute 'height', height
ctx.fillStyle = '#FFFFFF'
ctx.fillRect 0, 0, width, height
el.appendChild c
@deflexor
deflexor / poolMetadata.json
Created September 23, 2021 13:45
Cardano pool metadata
{
"name": "PuppyPool",
"description": "Puppy pool",
"ticker": "PUPS",
"homepage": "https://teststakepool.com"
}
0x481fff417ab8b8fd554a373bd462128560909fc4
@deflexor
deflexor / expo.js
Created February 12, 2017 22:47
Write a recursive exponential backoff service (ping) check.
const http = require('http');
const RetryIntervals = [500, 1000, 4000];
const retryTries = 4;
function pingService(retryInterval, retryTry) {
if(retryTry >= retryTries) {
console.log(`ping not ok after ${retryTries} retries, giving up.`);
@deflexor
deflexor / bind.js
Created February 12, 2017 22:36
Rewrite the bind method from scratch.
function mybind(f, o) {
return function() {
return f.apply(o, arguments);
};
}
<script src="https://vk.com/js/api/xd_connection.js?2" type="text/javascript"></script>
<script type="text/javascript">
function onInit() {
console.log("Post ID");
}
VK.init(function() {
// API initialization succeeded
@deflexor
deflexor / Main.hs
Created November 14, 2015 10:09
stack runghc Main.hs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Debug.Trace (trace, traceM, traceStack, traceShowM)
import Control.Applicative
import Control.Monad (unless, forM_, forM, void, mzero)
import Data.Char (isAlpha, isAlphaNum)
import qualified Text.Parsec as P
import Text.Parsec.Text
@deflexor
deflexor / app.elm
Last active October 14, 2015 07:33
Elm-lang app that needs speed boost
import Html exposing (..)
import Debug exposing (..)
import Array exposing (Array, repeat, set, get, toList, initialize)
import Html.Attributes exposing (..)
import Html.Events exposing (on, onClick, targetChecked)
import Signal exposing (Address)
import StartApp.Simple as StartApp
main =
/** @jsx React.DOM */
var MyComponent = React.createClass({
render: function() {
// Defaults in case the props are undefined. We'll have a solution for this
// soon that is less awkward.
var perMinute = this.props.perMinute || '-';
var perDay = this.props.perDay || '-';
return (
<div>
<h3>Clickouts</h3>