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 / 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');
var reader = new FileReader();
reader.onload = function(e) {
var bin = e.target.result;
// bin is the binaryString
};
reader.readAsBinaryString(file);
@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(
<?php
// <!DOCTYPE html>
echo $view->doctype('HTML5');
// <meta charset="UTF-8">
echo $view->headMeta()->setCharset('UTF-8');
@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 / language.rb
Created December 30, 2009 12:00
Определение языка строки
framework 'Foundation'
class String
def language
CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0, self.size))
end
end
puts "Happy new year!".language
# => "en"
puts "С новым годом!".language
# This is how you can get a user's location using MacRuby and CoreLocation
framework 'CoreLocation'
def locationManager(manager, didUpdateToLocation: new_location, fromLocation: old_location)
puts "location: #{new_location.description}"
exit
end
loc = CLLocationManager.alloc.init
loc.delegate = self
// Если localStorage доступен, используем его
if (('localStorage' in window) && window.localStorage !== null) {
localStorage.taglist = '["#html5","#css3","#simonenko"]';
} else {
// если старый браузер, используем Cookie.
var date = new Date();
date.setTime(date.getTime() + (365*24*60*60*1000));
document.cookie = 'taglist=["#html5","#css3","#simonenko"]; expires=' + date.toGMTString() + '; path=/';
}
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
(function () {
function each(list, fn) {
var l = list.length;
@meritt
meritt / async.coffee
Created July 19, 2011 06:04 — forked from tcr/async.coffee
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0