Skip to content

Instantly share code, notes, and snippets.

@iksecreeet
iksecreeet / ObjectSize.php
Created December 9, 2020 13:43 — forked from mathiasschopmans/ObjectSize.php
Sort various (clothing) sizes in an array
<?php
class ObjectSize {
protected static $sizes = [
'xxxxl',
'xxxl',
'xxl',
'xl',
'l',
/**
* @param mixed $a
* @param mixed $b
*
* @return int
*/
protected function _sortSizes($a, $b)
{
$aUpper = strtoupper($a);
$bUpper = strtoupper($b);
@iksecreeet
iksecreeet / GetWeeksInMonth.js
Created June 13, 2020 10:20 — forked from markthiessen/getWeeksInMonth.js
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(month, year){
var weeks=[],
firstDate=new Date(year, month, 1),
lastDate=new Date(year, month+1, 0),
numDays= lastDate.getDate();
var start=1;
var end=7-firstDate.getDay();
while(start<=numDays){
@iksecreeet
iksecreeet / getLastInMap.js
Created May 7, 2020 11:46 — forked from tizmagik/getLastInMap.js
ES6 Last Item in Map()
// Since ES6 Map()'s' retain their order of insertion, it can sometimes be useful to get the last item or value inserted:
export const getLastItemInMap = map => Array.from(map)[map.size-1]
export const getLastKeyInMap = map => Array.from(map)[map.size-1][0]
export const getLastValueInMap = map => Array.from(map)[map.size-1][1]
// Obviously getLastKey and getLastValue can reuse getLastItem, but for maximum portability I opted for verbosity.
@iksecreeet
iksecreeet / gist:3969c8a0d2539fc56a5412b475c5a4fc
Created October 7, 2019 00:00 — 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, ['найдена', 'найдено', 'найдены']);
@iksecreeet
iksecreeet / firebase_snapshot_parent.js
Created September 30, 2019 12:07 — forked from anantn/firebase_snapshot_parent.js
Firebase: Get the parent of a snapshot.
function getParent(snapshot) {
// You can get the reference (A Firebase object) from a snapshot
// using .ref().
var ref = snapshot.ref();
// Now simply find the parent and return the name.
return ref.parent().name();
}
var testRef = new Firebase("https://example.firebaseIO-demo.com/foo/bar");
testRef.once("value", function(snapshot) {
@iksecreeet
iksecreeet / js-task-1.md
Created February 23, 2019 20:22 — forked from codedokode/js-task-1.md
Задания на яваскрипт (простые)
@iksecreeet
iksecreeet / gist:dc7856a1ed978595eb5c9ce315ccd0b8
Created September 29, 2018 07:20 — forked from splittingred/gist:4689218
Example of modRest, a REST Client, in MODX 2.3.
$config = array(
'baseUrl' => rtrim('http://mywebsite.com/rest/api/','/'),
'format' => 'json', // json or xml, the format to request
'suppressSuffix' => false, // if false, will append .json or .xml to the URI requested
'username' => 'myuser', // if set, will use cURL auth to authenticate user
'password' => 'mypass',
'curlOptions' => array(
'timeout' => 30, // cURL timeout
'otherCurlOption' => 1,
@iksecreeet
iksecreeet / php7_2_upgrade.sh
Created September 28, 2018 16:02 — forked from fazni/php7_2_upgrade.sh
Installing PHP 7.2 Ubuntu 14.04, 16.04, 17.04, & 17.10
#!/bin/sh
# Installing PHP 7.2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-cli
sudo apt-get install php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2-xsl
# For developer drupal 8 apply patch https://www.drupal.org/files/issues/php_7_2_fatal_error-2894884-3.patch
@iksecreeet
iksecreeet / Instructions.sh
Created September 28, 2018 15:57 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa