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 clj | |
(ns foo) | |
(prn "Hello") |
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
neutron!ieure:~/Projects/clojure/foo/src$ ./foo.clj | |
"Hello" | |
Exception in thread "main" java.io.FileNotFoundException: --./foo.clj (No such file or directory) | |
at java.io.FileInputStream.open(Native Method) | |
at java.io.FileInputStream.<init>(FileInputStream.java:106) | |
at java.io.FileInputStream.<init>(FileInputStream.java:66) | |
at clojure.lang.Compiler.loadFile(Compiler.java:4821) | |
at clojure.main$load_script__5833.invoke(main.clj:206) | |
at clojure.main$init_opt__5836.invoke(main.clj:211) | |
at clojure.main$initialize__5846.invoke(main.clj:239) |
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
(defun php-lint () | |
"Performs a PHP lint-check on the current file." | |
(interactive) | |
(require 'compile) | |
(let* ((compilation-error-regexp-alist '(php)) | |
(compilation-error-regexp-alist-alist ()) | |
(tramp (tramp-tramp-file-p (buffer-file-name))) | |
(file (or (and tramp | |
(aref (tramp-dissect-file-name (buffer-file-name)) 3)) | |
(buffer-file-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
# -*- coding: utf-8 -*- | |
# | |
# Author: Ian Eure <ian@digg.com> | |
# | |
"""Star function.""" | |
from functools import partial | |
import unittest |
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 functools import partial | |
from itertools import imap | |
from operator import or_ | |
def retry(ntimes=3, ignore=None, trap=None): | |
"""Retry an operation some number of times. | |
The ignore and trap arguments may be a sequence (or a single) | |
exception class. If the decorated function raises an exception | |
matching ignore, it will be raised. |
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
# -*- coding: utf-8 -*- | |
# foo()'s a_value is unmodified. | |
def foo(): | |
a_value = "Hello" | |
def bar(): | |
a_value = "Goodbye" | |
bar() |
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
# -*- coding: utf-8 -*- | |
import threading | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker, scoped_session | |
engine = create_engine("mysql://testing:testing@10.0.0.1/testing", | |
pool_size=20, strategy="threadlocal") | |
Session = scoped_session(sessionmaker(bind=engine)) |
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
# -*- coding: utf-8 -*- | |
import threading | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker, scoped_session | |
def query(): | |
engine = create_engine("mysql://testing:testing@10.0.0.1/testing", | |
pool_size=20, strategy="threadlocal") | |
Session = scoped_session(sessionmaker(bind=engine)) |
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 contextlib import contextmanager | |
@contextmanager | |
def save(obj, attrs=None): | |
"""Save attributes of an object, then restore them. | |
Example: | |
import breakfast | |
with save(breakfast, ('eggs', 'bacon')): | |
breakfast.Eggs = lambda: "Eggs" |
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 | |
error_reporting(E_ALL | E_STRICT); | |
class Foo | |
{ | |
public static function test() | |
{ | |
echo "Hi!\n"; | |
} |