Skip to content

Instantly share code, notes, and snippets.

View Bogdaan's full-sized avatar
💭
writing code

Novikov Bogdan Bogdaan

💭
writing code
View GitHub Profile
/**
* Generate keyframe for CSS3 animation
* ios bounce icon effect
* @size = bounce size (sample: 10)
* @onFrames = % time on frames (for delay or other effect 0-100) (sample: 50)
*/
function buildFrames(size, onFrames)
{
var source = ["0", "60", "83", "100", "114", "124", "128", "128", "124", "114", "100", "83", "60", "32", "0", "0", "18", "28", "32", "28", "18", "0"];
@Bogdaan
Bogdaan / gist:0b6dae721f1c9d9b6346
Created September 29, 2015 15:23 — forked from realmyst/gist:1262561
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@Bogdaan
Bogdaan / downgrademysql.md
Created June 12, 2017 16:06 — forked from Voronenko/downgrademysql.md
Downgrade mysql to mysql 5.6 on xenial

Install MySQL 5.6 in Ubuntu 16.04

Ubuntu 16.04 only provides packages for MySQL 5.7 which has a range of backwards compatibility issues with code written against older MySQL versions.

Oracle maintains a list of official APT repositories for MySQL 5.6, but those repositories do not yet support Ubuntu 16.04. However, the 15.10 repos will work for 16.04.

Uninstall existing mysql 5.7 if any

sudo apt remove mysql-client mysql-server libmysqlclient-dev mysql-common
@Bogdaan
Bogdaan / iterm2.md
Created May 18, 2018 06:43 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Fullscreen + Enter
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
@Bogdaan
Bogdaan / gist:8ed956b1c6b44e4cd607cc473823ae05
Created May 22, 2018 16:44 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Bogdaan
Bogdaan / Install AMQP for PHP
Created July 16, 2018 07:20 — forked from TemporaryJam/Install AMQP for PHP
How to install the PHP AMQP library
#install cmake
yum install cmake
#install libtool
yum install libtool
#install a perl pkgconfig requirement
yum install perl-ExtUtils-PkgConfig.noarch
#get rabbitmq-c library
@Bogdaan
Bogdaan / varexport.php
Created September 10, 2018 12:31
PHP var_export() with short array syntax (square brackets) indented 4 spaces
<?php
function varexport($expression, $return=FALSE) {
$export = var_export($expression, TRUE);
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export);
$array = preg_split("/\r\n|\n|\r/", $export);
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
$export = join(PHP_EOL, array_filter(["["] + $array));
if ((bool)$return) return $export; else echo $export;
}
@Bogdaan
Bogdaan / reload-nginx.sh
Created September 21, 2018 07:07 — forked from jrumbut/reload-nginx.sh
Reload nginx process manually by sending HUP signal
#!/bin/bash
kill -HUP `cat /var/run/nginx.pid`
@Bogdaan
Bogdaan / object-to-form-data.js
Created October 30, 2018 20:34 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@Bogdaan
Bogdaan / github_oauth_token.md
Created November 22, 2018 11:45 — forked from ozh/github_oauth_token.md
Get a Github OAuth token from the CLI with curl

At the command line:

curl -u ':USERNAME' -d '{"scopes":["public_repo"],"note":"Google Issues to GH"}' https://api.github.com/authorizations
curl -H "Authorization: bearer :TOKEN" https://api.github.com/users/:USERNAME -I

Replace :USERNAME with your Github username and :TOKEN with the oauth token you get from first curl

After that, the token will be listed in your Applications and you can revoke it from there