Skip to content

Instantly share code, notes, and snippets.

@miguelfrmn
miguelfrmn / simpleimage.php
Last active May 9, 2023 11:23
SimpleImage PHP Class
<?php
/**
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@issackelly
issackelly / gist:928783
Created April 19, 2011 16:48
Django Template {{ block.super }} example
# Template: A.html
<html>
<head></head>
<body>
{% block hello %}
HELLO
{% endblock %}
</body>
</html>
@aemkei
aemkei / LICENSE.txt
Last active April 12, 2024 21:27 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@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(){
@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
};
@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);
@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;
@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">
@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))*+)
@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'])