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
from django.test.simple import DjangoTestSuiteRunner | |
from django.test import TransactionTestCase | |
from mongoengine import connect | |
class TestRunner(DjangoTestSuiteRunner): | |
def setup_databases(self, **kwangs): | |
db_name = 'testsuite' | |
connect(db_name) | |
print 'Creating test-database: ' + db_name |
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 python2 | |
# -*- coding: utf-8 -*- | |
import logging | |
from mpd import MPDClient, CommandError | |
from tornado.httpserver import HTTPServer | |
from tornado.ioloop import IOLoop | |
from tornado.web import Application | |
from tornado.websocket import WebSocketHandler |
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): |
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
<?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
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
#!/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
<?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
#!/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 | |
$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); |
OlderNewer