Skip to content

Instantly share code, notes, and snippets.

View sashabeep's full-sized avatar

Sasha Beep sashabeep

View GitHub Profile
@fomigo
fomigo / gist:2382775
Created April 14, 2012 07:59
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@iMoses
iMoses / jquery.plugin.wrapInGroups.js
Created July 26, 2012 12:21
jQuery Plugin wrapInGroups
/**
* Takes a jQuery collection and wraps each 'groupSize' items with 'wrapHtml'
* Example: $('#Example span').wrapInGroups('<div/>', 4);
* Will wrap every 4 span's inside #Example with a div
* See for yourself: http://jsfiddle.net/M9ZFh/
* Author: iMoses (imoses.g@gmail.com)
*/
(function($) {
$.fn.wrapInGroups = function(wrapHtml, groupSize) {
var selector = this.selector;
@Neolot
Neolot / gist:3964380
Last active September 19, 2023 12:52
PHP Склонение числительных
<?php
/**
* Функция склонения числительных в русском языке
*
* @param int $number Число которое нужно просклонять
* @param array $titles Массив слов для склонения
* @return string
**/
$titles = array('Сидит %d котик', 'Сидят %d котика', 'Сидит %d котиков');
function declOfNum($number, $titles)
@olimortimer
olimortimer / ral_colours.php
Last active April 22, 2023 16:19
PHP: RAL Colours as RGB
<?php
// Includes text RGB to show text as white or black. This value was calculated using;
// $brightness = sqrt( (R * R * .299) + (G * G * .587) + (B * B * .114) )
// If $brightness was greater than 130, then the text was set to white
$ral_colours => array(
'RAL 1000' => array(
'rgb' => '190,189,127',
'name' => 'Green Beige',
@wpscholar
wpscholar / jquery.external-links-new-window.js
Last active August 15, 2020 07:23
Open all external links in a new window
@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
@argnist
argnist / msorderbyphonehandler.class.php
Created July 4, 2013 10:22
Minishop2 OrderHandler с привязкой к телефону вместо емейла
<?php
class msOrderByPhoneHandler extends msOrderHandler {
public function getCustomerId() {
$order = $this->ms2->order->get();
if (empty($order['phone'])) {return false;}
if ($this->modx->user->isAuthenticated()) {
$profile = $this->modx->user->Profile;
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@dopsmain
dopsmain / function.phpthumb.php
Created April 1, 2016 05:29
phpthumb for smarty
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*
* Smarty {phpthumb} function plugin
*
* Type: function<br>