This file contains hidden or 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 | |
/** Prepare a string for use with wordwrap by hyphenate words longer that $width | |
* | |
* Example: | |
* echo prep("1 12 123 1234 12345 123456 1234567 12345678", 4), PHP_EOL; | |
* Outputs: | |
* 1 12 123 123-4 123-45 123-456 123-4567 123-456-78 | |
* XXX: DO NOT USE THIS UNLESS YOU KNOW YOU CAN(See for example preg_quote()). | |
*/ | |
function prep($str, $width=72) { |
This file contains hidden or 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 | |
function a { | |
return "/$1" | |
} | |
function b { | |
print $1 | |
} | |
b $(a "some_file") |
This file contains hidden or 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 nose.plugins import Plugin | |
class PyVersion(Plugin): | |
"""Nose plugin that excludes files based on python version and file name | |
If a filename has the format NAME.pyVERSION.py and VERSION doesn't match | |
[major][minor][micro], [major][minor] or [major] the file will be excluded | |
from tests. |
This file contains hidden or 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
if (true) { | |
function declaration() { | |
return "first"; | |
} | |
} else { | |
function declaration() { | |
return "second"; | |
} | |
} | |
declaration(); |
This file contains hidden or 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
;; add marmalade to ELPA | |
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/")) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/")) | |
(package-initialize) | |
This file contains hidden or 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
# vim: set fileencoding=utf-8 : | |
from __future__ import absolute_import, division | |
from sqlalchemy import ( | |
create_engine, | |
Column, | |
Integer, | |
) | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base |
This file contains hidden or 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
"""How to crash syslog.syslog | |
File: crash_syslog.py | |
Running this will product this output: | |
Traceback (most recent call last): | |
File "./crash_syslog.py", line 12, in <module> | |
syslog(LOG_INFO, base64.b64decode(b64)) | |
TypeError: [priority,] message string |
This file contains hidden or 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 | |
$str =<<<XML | |
<?xml version="1.0"> | |
<books> | |
<book/> | |
</books> | |
XML; | |
$parts = explode("\n", $str, 2); |
This file contains hidden or 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
DISTFILE=$(shell realpath ./build)/minimal-linux-home.tgz | |
dist: FORCE | |
rm -f $(DISTFILE) && cd home/ && tar -zcf $(DISTFILE) .* | |
FORCE: | |
Output: |
This file contains hidden or 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
DISTFILE=$(shell realpath ./build)/minimal-linux-home.tgz | |
dist: FORCE | |
rm -f $(DISTFILE) && cd home/ && tar -zcf $(DISTFILE) .* | |
FORCE: | |