Skip to content

Instantly share code, notes, and snippets.

@kuzminT
kuzminT / html5-games-tips.md
Last active May 29, 2023 04:39
Tips for phaser.js and html5 game development
@zmts
zmts / tokens.md
Last active April 23, 2024 09:58
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@MarcL
MarcL / phaser-speedup.md
Created March 10, 2017 09:19
Tips on speeding up Phaser games
@pranid
pranid / compare-images.php
Last active January 24, 2023 07:01 — forked from akosnikhazy/compare-images-class
Compare two images with PHP
<?php
class compareImages
{
private function mimeType($i)
{
/*returns array with mime type and if its jpg or png. Returns false if it isn't jpg or png*/
$mime = getimagesize($i);
$return = array($mime[0],$mime[1]);
switch ($mime['mime'])
@iksi
iksi / minify-kirby.php
Last active June 2, 2018 23:40
Minify Kirby’s HTML output
/**
* Uses Alan Moore's regexp:
* http://stackoverflow.com/questions/5312349/minifying-final-html-output-using-regular-expressions-with-codeigniter
*
* Replace `echo $kirby->launch();` in Kirby’s index.php by
* the following code to minify the HTML output
* (it leaves whitespace within `<pre>` and `<textarea>` tags untouched)
*/
echo preg_replace(
'/(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!\/?(?:textarea|pre)\b))*+)
@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active August 10, 2023 17:16
SVG Icons with mithril.js

Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.

They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.

A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  
  <symbol id="beaker" viewBox="214.7 0 182.6 792">
@AmyStephen
AmyStephen / Files.php
Last active July 5, 2017 17:47
General purpose folder and file processing for copy, move, delete, and size calculation
<?php
/**
* File class
*
* @package Molajo
* @copyright 2013 Amy Stephen. All rights reserved.
* @license MIT, GPL v2 or later
*/
namespace Molajo;
@inadarei
inadarei / base64.js
Created January 6, 2013 04:11
base64 encode/decode in Node.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@jaydson
jaydson / gist:1780598
Created February 9, 2012 15:11
How to detect a click event on a cross domain iframe
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){