Skip to content

Instantly share code, notes, and snippets.

View flavius's full-sized avatar

Flavius Aspra flavius

View GitHub Profile
145750 flavius │ Hi. How to count the number of files in a directory (for a conditional "if there are any files in the directory, do │ Chiku|dc
│ this"), without spawning a subprocess like ls? │ chris2
145938 ccxCZ │ > files=( *(N) ); echo $#files │ Chryyz
145939 SweetieBot │ ccxCZ: 0 │ chutzpah
150011 ccxCZ │ though that doesn't get .files │ cinch
150111 flavius │ ccxCZ: and where do I put the path to the directory? │ claytron
150114 Mikachu │ (DN)
" HJKL repetition trap
" Barry Arthur, 2013-03-14
" depends on your :help 'updatetime setting
let g:cursor_moving = 0
function! TrapMovementKeys(key)
augroup CursorMoving
au!
autocmd CursorMoved * let g:cursor_moving = 1
<?php
/**
* File: database.class.php
* Super simple PDO class
*
* Author: Jeremy Morgan
* Author: Flavius Aspra <[email protected]>
*
* This is just a start. No error handling or parameterization yet
*/
<?php
$url = 'http://forum.antichat.ru/thread20301.html';
function getfile($url,$num) {
echo "$url";
$content = file_get_contents($url);
echo nl2br($content);
$fp = fopen($num.".txt", 'write');
fwrite($fp, nl2br($content));
fclose($fp);
return $content;
function! ToggleFlagOptionValue(option, flag)
exe "set " . a:option . eval("&" . a:option . " =~# '" . a:flag . "' ? '-=" . a:flag . "' : '+=" . a:flag . "'")
endfunction
echo &go
call ToggleFlagOptionValue('go', 'T')
call ToggleFlagOptionValue('go', 'r')
echo &go
# for flag in ['T', 'r'] | call ToggleFlagOptionValue('go', flag) | endfor
@flavius
flavius / primul
Created February 15, 2012 16:55
Solutii_yet_another_project
tioiutou
<?php
namespace demo;
class Bar {
protected $options;
public function __construct($options = null) {
$this->options = $options;
}
}
<?php
return array(
'modules' => array(
'Application',
),
'module_listener_options' => array(
'config_cache_enabled' => false,
'cache_dir' => 'data/cache',
'module_paths' => array(
'./modules',
<?php
$createLink = function($var) {
$ret = '<a style="color: red" href="' . $var . '">' . 'Link' . '</a>';
return $ret;
};
$format = array();
$format['Link'] = 'createLink';