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
@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 / simple_web_server.txt
Created August 18, 2013 07:59
Simple Webserver
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; \
cat Dateiname; } | nc -l 8080; done
@vlrmprjct
vlrmprjct / apache2
Created April 12, 2016 07:04
apache2 enable/disable sites
# enable site
sudo a2ensite
# disable site
sudo a2dissite
# enable an apache2 module
sudo a2enmod
# e.g. a2enmod php4 will create the correct symlinks in mods-enabled to allow the module to be used. In this example it will link both php4.conf and php4.load for the user
@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 / yt_embed.html
Created April 11, 2017 10:26
Responsive embeding youtube video
<div class="videoWrapper">
<iframe width="560" height="349" src="http://www.youtube.com/embed/n_dZNLr2cME?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
</div>
<style>
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
@vlrmprjct
vlrmprjct / push-multiple-git.sh
Last active April 24, 2017 06:29
Push to multiple git repositories
git config --add remote.all.url ssh://user@server/repos/g0.git
git config --add remote.all.url ssh://user@server/repos/g1.git
git push all
@vlrmprjct
vlrmprjct / formatNumber.js
Last active May 4, 2017 09:20
Number Formatting Using string.replace in JavaScript
// SOURCE: http://blog.tompawlak.org/number-currency-formatting-javascript
function formatNumber (num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
}
console.info(formatNumber(2665)); // 2,665
console.info(formatNumber(102665)); // 102,665
console.info(formatNumber(111102665)); // 111,102,665
console.info(formatNumber(1240.5)); // 1,240.5
@vlrmprjct
vlrmprjct / date.php
Created July 25, 2017 09:38
Collection of some date functions
// Calc current date + 7 days
print date('M d, Y', strtotime('+7 days') );
@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...