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 / tar_untar.sh
Created June 18, 2015 07:23
tar and untardirectory
# tar directory
tar -czvf Output_File_Name.tar.gz Directory_Name
tar -zcvf demo.tar.gz demo
# which will create a tar file named "demo.tar.gz"
# to untar directory
tar -xzvf Input_File_Name.tar.gz
@vlrmprjct
vlrmprjct / numericonly.js
Created July 16, 2015 08:07
Input Numeric only
// Numeric only control handler
jQuery.fn.ForceNumericOnly =
function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
@vlrmprjct
vlrmprjct / randomkeys.php
Created July 20, 2015 08:49
Get a random alphanumeric string.
/**
* @param $prefix
* @param $suffix
* @param $size
*
* @return string
*/
private function randomKey($prefix, $suffix, $size)
{
$key = "";
@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 / 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 / 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 cod3cow/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 / task.json
Last active January 21, 2022 05:39
VSCode run multiple build task
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// **************************************************
// USING:
// npm install node-sass -g
// npm install uglify-js -g
// npm install html-minifier -g
// **************************************************
{
"version": "2.0.0",