Skip to content

Instantly share code, notes, and snippets.

View vlrmprjct's full-sized avatar
🎹
Boing boom tschak!

Thomas vlrmprjct

🎹
Boing boom tschak!
View GitHub Profile
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@vlrmprjct
vlrmprjct / javascript aspect ratio calculation (with GCD)
Last active August 29, 2015 14:27 — forked from phobeo/javascript aspect ratio calculation (with GCD)
javascript aspect ratio calculation algorithm (take the GCD and divide both elements of resolution)
/* euclidean GCD (feel free to use any other) */
function gcd(a,b) {if(b>a) {temp = a; a = b; b = temp} while(b!=0) {m=a%b; a=b; b=m;} return a;}
/* ratio is to get the gcd and divide each component by the gcd, then return a string with the typical colon-separated value */
function ratio(x,y) {c=gcd(x,y); return ""+(x/c)+":"+(y/c)}
/* eg:
> ratio(320,240)
"4:3"
> ratio(360,240)
@vlrmprjct
vlrmprjct / svg.js
Created August 7, 2016 11:42 — forked from schmidt1024/svg.js
Replace all SVG images with inline SVG using jQuery
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@vlrmprjct
vlrmprjct / .htaccess
Created January 5, 2017 11:18 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@vlrmprjct
vlrmprjct / WP_secondary_editor.php
Last active November 8, 2017 08:18 — forked from dcondrey/WP_secondary_editor
Add a second TinyMCE editor to Wordpress post editor page. #php #wordpress
/* Second Post Editor TinyMCE Editor */
class SubContentEditor {
public $meta_key = 'subcontent';
public $meta_label = 'Right Side'; // Headline above editor
public $post_type = array( 'page' ); // The post type in which the editor should display
public $wpautop = true; // Automatically create paragraphs?
function __construct() {
add_action( 'edit_form_after_editor', array( &$this, 'edit_form_after_editor' ) );
@vlrmprjct
vlrmprjct / sshKeyGen.sh
Last active November 8, 2017 08:11 — forked from wilcollins/sshKeyGen.sh
SSH KeyGen+Copy Bash Script (quick ssh key setup) #ssh #linux
#!/bin/bash
#
# Creates an SSH key on a client machine, applies the appropriate file permissions,
# copies to the local ~/.ssh directory, & copies to specified server
#
# parameters:
# ..1 newKeyFileName
# ..2 user@server
#
# usage :
@vlrmprjct
vlrmprjct / pre-push.sh
Created October 23, 2017 07:00 — forked from vlucas/pre-push.sh
Prevent Pushes Directly to Master
#!/bin/bash
# @link https://gist.github.com/mattscilipoti/8424018
#
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
@vlrmprjct
vlrmprjct / autoload.php
Last active November 13, 2017 07:51 — forked from cheich/autoload.php
PSR-4 class autoloader #php #class #autoloader
<?php
namespace MyProjectNamespace;
/**
* PSR-4 class autoloader
*
* @param string $class The fully-qualified class name.
*
* @return void
@vlrmprjct
vlrmprjct / composer.json
Created February 9, 2018 12:09 — forked from mfurlend/composer.json
composer require git repository
{
"name": "my_vendor_name/my_package",
"description": "My Package Description",
"license": "GPL-3.0",
"autoload": {
"classmap": [ // search these directories for classes
"lib/"
]
},
"repositories": {
@vlrmprjct
vlrmprjct / package.json
Created March 11, 2018 11:05 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",