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
def get_last_lines(fp, num, step=10): | |
pos = step | |
lines = [] | |
quit = False | |
while len(lines) < num + 1 and not quit: | |
fp.seek(-pos, 2) | |
if int(fp.tell()) == 0: | |
quit = True | |
lines = fp.readlines() |
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 ftplib | |
import sys | |
import os | |
ftpServer = 'xxx' | |
ftpUser = 'xx' | |
ftpPass = 'xx' | |
#ftpPath = 'FileFlowStatus/' | |
ftpPath = '/' |
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
// outlets | |
IBOutlet UILabel *label; | |
// actions | |
- (IBAction)onChange:(id)sender; | |
// storage | |
[[NSUserDefaults standardUserDefaults] storeFloat: 123 forKey: @"key"]; | |
float value = [[NSUserDefaults standardUserDefaults] floatForKey: @"key"]; |
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
set errorformat=%f:%l:\ error:\ %m,%f:%l:\ warning:\ %m | |
set autowrite | |
au! BufWritePost *.m make! test |
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 | |
final class AddController { | |
public function __construct() { | |
require 'model/WriteModel.php'; | |
} | |
public function newPost($name,$text) { | |
$addModel = new WriteModel($name, $text); | |
return $addModel; |
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
# Run these commands to install PHPUnit | |
# More info @ http://www.phpunit.de/manual/current/en/installation.html | |
pear channel-discover pear.phpunit.de | |
pear channel-discover components.ez.no | |
pear channel-discover pear.symfony-project.com | |
pear install phpunit/PHPUnit | |
# OSX - you may need to upgrade pear before installing PHPUnit |
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
use Test::More; | |
use Module; | |
is($Module::data, undef); | |
$Module::data = 10; | |
done_testing(); |
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
public void testGetTotalPriceReturnsSumOfAllItemsPrices() { | |
basket.addItem(new Item(1)); | |
basket.addItem(new Item(2)); | |
assertThat(basket.getTotalPrice(), is(3)); | |
} | |
public void testClearMakesBasketEmpty() { | |
basket.addItem(new Item()); | |
basket.clear(); |
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
# Perl clone of: | |
# https://github.com/pivotal/jasmine/wiki/Matchers | |
# https://github.com/pivotal/jasmine/wiki | |
use Test::Spec; | |
# usage | |
describe 'Expect' => sub { | |
describe 'implementing matcher' => sub { | |
it toEqual => sub { |
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
nmap P :call <SID>pasteAbove()<CR> | |
nmap p :call <SID>pasteBelow()<CR> | |
fun! s:pasteAbove() | |
let indentDiff = s:detectIndentDiff("O") | |
exe "norm! P" | |
call s:fixPasteIndent(indentDiff) | |
endfun | |
fun! s:pasteBelow() |