Skip to content

Instantly share code, notes, and snippets.

@rlingineni
rlingineni / cavasHelper.ts
Created February 4, 2020 02:10
Aligning Guidelines with Fabric.js + Typescript. This is a modifed version of the code here: https://github.com/fabricjs/fabric.js/blob/master/lib/aligning_guidelines.js
import { fabric } from "fabric";
import { ILineOptions } from "fabric/fabric-impl";
/**
* Should objects be aligned by a bounding box?
* [Bug] Scaled objects sometimes can not be aligned by edges
*
*/
@itchief
itchief / get_pageviews_from_ga.php
Created December 15, 2019 12:52
How to get pageviews of resource from Google Analytics Reporting API v4 and save them to file in JSON format
<?php
// Загрузим PHP клиентскую библиотеку для Google API.
require_once __DIR__ . '/vendor/autoload.php';
$analytics = initializeAnalytics();
$response = getReport($analytics);
//printResults($response);
printResultInFile($response);
@itchief
itchief / get_top_pages_from_ga.php
Last active February 28, 2021 06:51
How to get top 7 pageviews from Google Analytics Reporting API v4
<?php
// Загрузим PHP клиентскую библиотеку для Google API.
require_once __DIR__ . '/vendor/autoload.php';
$analytics = initializeAnalytics();
$response = getReport($analytics);
printResults($response);
//printResultsAsJson($response);
@zmts
zmts / tokens.md
Last active October 29, 2025 08:59
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
<?php
class Item
{
private $cost = 100;
public function getTotal($discount = 7) {
return $this->cost *(100+$discount)/100;
}
}
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];