Skip to content

Instantly share code, notes, and snippets.

View steppefox's full-sized avatar
🦥

Eldar Amantay steppefox

🦥
View GitHub Profile
@steppefox
steppefox / mongo_yii.md
Created October 29, 2013 11:07
PHP MongoYii Snippets
$c = new EMongoCriteria();
$c->addCondition('is_visible',(int)1);
$c->sort = array('publicated_at'=>-1); // ASC:1, DESC:-1

$pages = new CPagination(Feedback::model()->count($c));
$pages->pageSize = 6;
$pages->applyLimit($c);

$models = Feedback::model()->find($c);
@steppefox
steppefox / php_json_encode_cyr.php
Created October 28, 2013 11:45
json encode with cyrillic characters
json_encode($info,JSON_UNESCAPED_UNICODE); //available since php 5.4.0
@steppefox
steppefox / php_string_to_ascii.php
Created October 28, 2013 06:12
String to Ascii
function string_to_ascii($string)
{
$ascii = array();
for ($i = 0; $i < strlen($string); $i++)
{
$ascii[] =$string[$i].':'.ord($string[$i]);
}
return(implode(' ', $ascii));
@steppefox
steppefox / php_headers.md
Created October 26, 2013 05:52
PHP Headers

XLS (Excel) headers in php

header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment;filename='.$fileName);
header('Content-Transfer-Encoding: binary');

301 Header

@steppefox
steppefox / html_utf8_symbols.txt
Created October 24, 2013 18:22
UTF-8 symbols
&#x25BE; - arrow down
@steppefox
steppefox / js_plural_ru.js
Created October 24, 2013 18:05
Plural function for russian language
function plural_str(i, str1, str2, str3){
function plural (a){
if ( a % 10 == 1 && a % 100 != 11 ) return 0
else if ( a % 10 >= 2 && a % 10 <= 4 && ( a % 100 < 10 || a % 100 >= 20)) return 1
else return 2;
}
switch (plural(i)) {
case 0: return str1;
case 1: return str2;
@steppefox
steppefox / html_center_elements.html
Created October 24, 2013 16:42
Methods for the placing element at the center
<!-- OLD SCHOOL METHOD FROM 2000 -->
<style>
div.center-2 { position: relative; float: left; left: 50%; margin: 0; padding: 0; z-index:2}
div.center-2 div.center-3 { position: relative; float: left; right: 50%;z-index:2 }
div.center-1 {overflow: hidden;}
</style>
<div class="center-1"><div class="center-2"><div class="center-3">
...
</div></div></div>
@steppefox
steppefox / js_lazy_loading_images.md
Created October 23, 2013 17:57
Lazy loading images
@steppefox
steppefox / imp_link_list.md
Created October 23, 2013 16:49
IMPORTANT links list
@steppefox
steppefox / pomodorro.sh
Created October 23, 2013 06:16
Little script like pomodorro
sleep 25m; notify-send -u critical "O_O"; mocp --pause;