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 qualified Data.Text.Lazy as T (Text, lines, unlines) | |
import qualified Data.Text.Lazy.IO as TIO (interact) | |
data Command = Next | |
sed :: T.Text -> T.Text | |
sed t = T.unlines $ concat $ map (runCommands [Print]) $ T.lines t | |
runCommands :: [Command] -> T.Text -> [T.Text] |
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
func (conn *Conn) Connect(host string) (c net.Conn, err error) { | |
log.SetFlags(23) | |
log.Printf("Connecting to host: %s\n", host) | |
// Wrapp the connection with a secure connection | |
if conn.SSL { | |
c, err = tls.Dial("tcp", host, conn.SSLConfig) | |
} else { | |
c, err = net.Dial("tcp", host) | |
} | |
if err != nil { |
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 | |
$s = microtime(true); | |
$c = 0; | |
foreach(range(1, 100000) as $i) { | |
$c++; | |
} | |
$e = microtime(true); | |
printf("Foreach :: Time: %f, count: %d\n", $e-$s, $c); | |
$s = microtime(true); |
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 | |
# Original: http://frexx.de/xterm-256-notes/ | |
# http://frexx.de/xterm-256-notes/data/colortable16.sh | |
# Modified by Aaron Griffin | |
# and further by Kazuo Teramoto | |
FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ') | |
BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT') | |
echo " ┌──────────────────────────────────────────────────────────────────────────┐" |
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 | |
class Foo { | |
public function __construct() { | |
var_dump(get_object_vars($this)); | |
} | |
} | |
class Bar { | |
public function __construct(Array $args) { | |
foreach ($args as $key => $value) { |
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
import os | |
import sys | |
import argparse | |
def parse_arguments(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('file') |
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
location /code/ { | |
try_files $uri $uri/index.html =404; | |
} | |
location ~ /code/(?<uri_path>.*/)(?<page>\d+)$ { | |
try_files $uri $uri_path/index$page.html =404; | |
} | |
location ~ /foo/.*.html { | |
return 404; |
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 | |
$data = array(); | |
$time = array(); | |
for ($i = 97; $i < 173; $i++) | |
$data[chr($i)] = $i; | |
$s = microtime(true); | |
for ($i = 0; $i < 1000000; $i++) { | |
isset($data['g']); |
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 | |
$url = 'http://www.trafiken.nu/TrafikenServices/TraveltimeService.ashx?method=getTraveltime®ion=VST§ionId=3001'; | |
$c = curl_init($url); | |
$options = array( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_HTTPHEADER => array('Content-type: application/json') | |
); | |
curl_setopt_array($c, $options); | |
$data = curl_exec($c); |
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 unittest | |
from flask.ext.script import Manager, Server | |
from project import app, db | |
manager = Manager(app) | |
class Serve(Server): | |
def handle(self, *args, **kwargs): |
NewerOlder