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
-- Before: | |
commentForm :: EntryId -> Form Comment | |
commentForm entryId = renderDivs $ Comment | |
<$> pure entryId | |
<*> aformM (liftIO getCurrentTime) | |
<*> aformM requireAuthId | |
<*> areq textField (fieldSettingsLabel MsgCommentName) Nothing | |
<*> areq textareaField (fieldSettingsLabel MsgCommentText) Nothing | |
-- Adding the ReCAPTCHA form, we just append "<* recaptchaAForm": |
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
######### blah.py ######### | |
from time import sleep | |
from celery import Celery | |
from celery.task import Task | |
import logging | |
import traceback | |
import time |
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
-- Easiest way to run this with ghci: | |
-- | |
-- ghci -XDataKinds -XGADTs -XEmptyDataDecls -XKindSignatures -XScopedTypeVariables -XTemplateHaskell | |
-- Natural numbers, e.g. | |
-- 0 == Z | |
-- 1 == S Z | |
-- 2 == S (S Z) | |
-- 3 == S (S (S Z)) | |
-- etc |
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 getpass | |
import hashlib | |
import random | |
import string | |
password = getpass.getpass('password (not echoed): ') | |
salt = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for x in range(32)) | |
password_hash = hashlib.md5(password + salt).hexdigest() | |
print "update CHANGEME_users set password='" + password_hash + ':' + salt + "' where id = ...;" |
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
""" | |
Carlo Hamalainen <carlo.hamalainen@gmail.com> | |
Given a directory of shapefiles, e.g. | |
$ ls /path/to/shapefiles/ | |
Project_Name.dbf | |
Project_Name.prj | |
Project_Name.sbn | |
Project_Name.sbx |
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
#!/bin/bash | |
# Author: Carlo Hamalainen <carlo.hamalainen@gmail.com> | |
# Use at your own risk :) | |
set -e | |
set -x | |
sudo yum -y install vim |
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
# IO actions on integers: | |
# | |
# data IOAction = Return Int | |
# | Put Int (IOAction Int) | |
# | Get (Int -> IOAction Int) | |
# | |
# Implement using nested lists, e.g. | |
# | |
# [Return, 3] == Return 3 | |
# |
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 FlexibleContexts #-} | |
import Text.Parsec | |
import Control.Applicative hiding ((<|>),many) | |
-- Example input: | |
{- | |
top 1: |
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 Control.Applicative hiding ((<|>),many) | |
import Control.Monad | |
import Control.Monad.State | |
import Text.Parsec | |
import Text.Parsec.String | |
import Data.Functor.Identity | |
import Safe (headMay) | |
data Network = Network { networkCell :: String | |
, networkIP :: String |
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
(defn create-session [hostname username password] | |
(doto (. (new JSch) getSession username hostname 22) | |
(.setPassword password) | |
(.setConfig "StrictHostKeyChecking" "no") | |
(.connect) | |
(.setServerAliveInterval 1000) | |
(.setServerAliveCountMax 30))) | |
(defn sleep [seconds] | |
(. Thread (sleep (* 1000 seconds)))) |