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
<?php | |
session_start(); | |
header("Content-Type: text/html"); | |
$errors = array(); | |
// Reset form. | |
if(array_key_exists('clearForm', $_POST)) | |
{ | |
unset($_SESSION); |
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
// Examples of EINTR handling for reentrant functions. | |
#include <errno.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
//m=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | |
// Open can be interupted when blocked, waiting for a slow device such as a |
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
#include <errno.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
void signal_handler_function(int signo); | |
typedef void (*sighandler_t)(int); | |
int main() |
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
(setq make-backup-files nil) | |
(electric-indent-mode t) | |
(setq auto-save-interval 0) | |
(setq transient-mark-mode nil) | |
(setq visible-bell 1) | |
(iswitchb-mode 1) | |
(auto-compression-mode 1) | |
;; Give buffers unique names when there are 2 with the same name... | |
(require 'uniquify) |
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
" Turn on syntax highlighting... | |
syn on | |
" Turn on file type detection... | |
filetype on | |
filetype plugin indent on | |
" Set up default settings... | |
set autoindent | |
set expandtab |
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 TemplateHaskell #-} | |
module MatrixDemo where | |
import Control.Lens | |
-- | Represents a matrix with the contents stored in row major order. | |
-- Note that we get equality, ability to read a Matrix from a stream | |
-- as well as write it to a stream for free by deriving (Eq,Read,Show). | |
data Matrix = Matrix { _numRows :: Int | |
, _numColumns :: Int |
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
#include <iostream> | |
#include <vector> | |
using std::vector; | |
// Represents a matrix with the contents stored in row major order. | |
struct Matrix { | |
int numRows; | |
int numColumns; | |
vector<vector<int>> contents; |
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
f :: [[a]] -> Bool | |
f matrix = flattenedMatrix == (reverse flattenedMatrix) | |
where flattenedMatrix = concat matrix | |
-- Note that concat (defined in the default environment) simply flattens a list of lists into a list. | |
concat :: [[a]] -> [a] |
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
-- This version runs in ~0.7 seconds due to String actually being a linked list | |
-- of Char. Not super efficient. | |
main = do | |
chars <- head <$> getArgs | |
englishWords <- words <$> readFile "en.txt" | |
mapM_ putStrLn $ sortBy (comparing length) $ findValidWords chars englishWords | |
findValidWords :: String -> [String] -> [String] | |
findValidWords chars englishWords = filter (`canBeMadeWith` chars) englishWords |
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
-- | Timing breakdown: | |
-- Reading: 2.5s | |
-- Sorting: 3.5s | |
module Main where | |
import Control.Applicative | |
import Control.Monad | |
import Data.ByteString.Char8 (pack) | |
import Data.Attoparsec.ByteString.Char8 |
OlderNewer