Skip to content

Instantly share code, notes, and snippets.

View meritt's full-sized avatar
🎯
Focusing

Alexey Simonenko meritt

🎯
Focusing
View GitHub Profile
@meritt
meritt / httpdump
Created April 4, 2009 07:52 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
# Ubuntu Server Upgrade
apt-get update
apt-get install update-manager-core
do-release-upgrade -d
# Ubuntu Dist Update
apt-get update
apt-get dist-upgrade
@meritt
meritt / snapper.rb
Created December 2, 2009 13:46
Получение скриншота сайта с помощью MacRuby
macruby -r snapper.rb -e "Snapper.new.save('http://serenity.su', 'serenity.su.png')"
var reader = new FileReader();
reader.onload = function(e) {
var bin = e.target.result;
// bin is the binaryString
};
reader.readAsBinaryString(file);
@meritt
meritt / cache.php
Created December 22, 2009 16:04
Пример использования Zend_Cache_Manager
<?php
$manager = new Zend_Cache_Manager;
$dbCache = array(
'frontend' => array(
'name' => 'Core',
'options' => array(
'lifetime' => 7200,
'automatic_serialization' => true
@meritt
meritt / write-feed.php
Created December 22, 2009 16:17
Пример использования Zend_Feed_Writer
<?php
/**
* Создаю фид
*/
$feed = new Zend_Feed_Writer_Feed;
$feed->setTitle('Заголовок блога');
$feed->setLink('http://www.example.com');
$feed->setFeedLink('http://www.example.com/atom', 'atom');
$feed->addAuthor(array(
@meritt
meritt / textile.php
Created December 22, 2009 16:25
Пример использования Zend_Markup
<?php
$textile = Zend_Markup::factory('Textile');
// <strong>жирный текст</strong> и <em>курсивный текс</em>
echo $textile->render('*жирный текст* и _курсивный текс_');
@meritt
meritt / generate-pdf.php
Created December 22, 2009 16:36
Пример использования Zend_Service_LiveDocx
<?php
$date = new Zend_Date();
$date->setLocale('ru_RU');
$liveDocx = new Zend_Service_LiveDocx_MailMerge();
$liveDocx->setUsername('myUsername')
->setPassword('myPassword');
<?php
// <!DOCTYPE html>
echo $view->doctype('HTML5');
// <meta charset="UTF-8">
echo $view->headMeta()->setCharset('UTF-8');