Skip to content

Instantly share code, notes, and snippets.

@mjj2000
mjj2000 / get-current-git-tag.sh
Last active Aug 20, 2021
[GIT] Get tag of current branch(that is HEAD) or fallback to short commit hash(7 digits) by single shell command
View get-current-git-tag.sh
git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD
@cferdinandi
cferdinandi / umd-script-boilerplate.js
Last active Jun 7, 2021
A simple boilerplate for UMD JS modules.
View umd-script-boilerplate.js
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@jasdeepkhalsa
jasdeepkhalsa / imageCropAdvanced.php
Created Dec 19, 2012 — forked from anonymous/imageCropAdvanced.php
Using PHP and GD to crop an image proportionally according to its aspect ratio. From: http://stackoverflow.com/questions/1855996/crop-image-in-php
View imageCropAdvanced.php
<?php
$image = imagecreatefromjpeg($_GET['src']);
$filename = 'images/cropped_whatever.jpg';
$thumb_width = 200;
$thumb_height = 150;
$width = imagesx($image);
$height = imagesy($image);
@andyfowler
andyfowler / lessjs.rb
Created Oct 23, 2010
Jekyll plugin to render less.js - fixed for new versions of jekyll
View lessjs.rb
module Jekyll
class LessCssFile < StaticFile
def write(dest)
# do nothing
end
end
# Expects a lessc: key in your _config.yml file with the path to a local less.js/bin/lessc
# Less.js will require node.js to be installed
@gf3
gf3 / jsonp.js
Created Jun 18, 2009
Simple JSONP in vanilla JS
View jsonp.js
/**
* loadJSONP( url, hollaback [, context] ) -> Null
* - url (String): URL to data resource.
* - hollaback (Function): Function to call when data is successfully loaded,
* it receives one argument: the data.
* - context (Object): Context to invoke the hollaback function in.
*
* Load external data through a JSONP interface.
*
* ### Examples