Skip to content

Instantly share code, notes, and snippets.

View dimayakovlev's full-sized avatar

Dmitry Yakovlev dimayakovlev

View GitHub Profile
@dimayakovlev
dimayakovlev / README.md
Created March 20, 2016 09:46
GravExampleAddVariableToTwig

Create a new plugin folder in user/plugins/example, and add those files:

user/plugins/example/example.php user/plugins/example/example.yaml

Then in your twig, you'll have the users object available:

{{ dump(users) }}

/**
* @desc Функция получения русскоязычного варианта окончания для переданного числа
* @param float $value Число, для которого надо подобрать окончание
* @param array $names Массив имён вида [0]имя одного; [1]имя от 2 до 4; [2]имя 0 и от 5 до 20
* @return string Возвращает соответствующее числу слово
* @link https://habrahabr.ru/post/51887/#comment_1375421
*/
function getNumberWord($value,$names){
$temp = strval($value);
$temp = $temp[utf8_strlen($temp)-1];
@dimayakovlev
dimayakovlev / datauri.php
Created December 9, 2016 12:42 — forked from rodneyrehm/datauri.php
PHP: datauri.php - convert image to data-uri
#!/opt/local/bin/php
<?php
/*
1) replace the shebang (first line) with the path to your php binary
(probably something like /usr/bin/php)
2) move the file to /usr/local/bin/datauri.php
(this should be in your PATH)
3) chmod ugo+rx /usr/local/bin/datauri.php
(make the script executable for everyone)
$(window).scroll(function() {
var st = $(this).scrollTop() /10;
$(".object").css({
"transform" : "translate3d(0px, " + st + "%, .01px)",
"-webkit-transform" : "translate3d(0px, " + st + "%, .01px)"
});
});
<!-- I got these buttons from simplesharebuttons.com -->
<div id="share-buttons">
<!-- Buffer -->
<a href="https://bufferapp.com/add?url=https://simplesharebuttons.com&amp;text=Simple Share Buttons" target="_blank">
<img src="https://simplesharebuttons.com/images/somacro/buffer.png" alt="Buffer" />
</a>
<!-- Digg -->
<a href="http://www.digg.com/submit?url=https://simplesharebuttons.com" target="_blank">
@dimayakovlev
dimayakovlev / smashingmagazine.js
Created August 5, 2017 14:41 — forked from luruke/smashingmagazine.js
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
<?php
/**
* GS 'Routing' demonstration module
*
* Demonstrates how to use "data_index" to modify the page data
* and how to use url segments to control process flows in your
* scripts.
*
* Required:
* --------------------------------------------------------------
@dimayakovlev
dimayakovlev / discography-the-beatles.json
Last active October 8, 2018 18:30
The Beatles Discography
[
{
"artist": "The Beatles",
"date": "22.03.1963",
"album": "Please Please Me",
"cover": "https://is4-ssl.mzstatic.com/image/thumb/Music/v4/63/11/dc/6311dc1f-f8cb-6cfb-36c1-21dcfd143da7/source/600x600bb.jpg"
},
{
"artist": "The Beatles",
"date": "22.11.1963",
@dimayakovlev
dimayakovlev / semantic-layout.html
Last active October 18, 2018 14:56 — forked from thomd/semantic-layout.html
Standard HTML5 Semantic Layout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
<link href="stylesheets/main.css" rel="stylesheet">
</head>
<body>
<header>
<h1>Header</h1>
@dimayakovlev
dimayakovlev / index.html
Created March 17, 2021 22:18
:not(:last-of-type) example
<div class="card">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
</div>