Skip to content

Instantly share code, notes, and snippets.

View webolizzer's full-sized avatar

webolizzer

  • Germany
View GitHub Profile
@webolizzer
webolizzer / gist:e46df4ba49dfb146384380db8eecb01f
Created March 30, 2017 16:55 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@webolizzer
webolizzer / remove elements from array.js
Last active March 28, 2017 10:56
How to iterate over an array and remove elements in JavaScript
var elements = [1, 5, 5, 3, 5, 2, 4];
for(var i = 0; i < elements.length; i++) {
if (elements[i] == 5) {
// delete item from array & decrement i
elements.splice(i--, 1);
}
}
@webolizzer
webolizzer / lzw_encoder.js
Created March 17, 2017 21:21 — forked from revolunet/lzw_encoder.js
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@webolizzer
webolizzer / size of the screen current web page and browser window
Last active March 11, 2017 15:14
Get the size of the screen, current web page and browser window
// @author http://stackoverflow.com/a/3437825/2337281
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document (same as pageHeight in screenshot)
$(window).width(); // returns width of browser viewport
$(document).width(); // returns width of HTML document (same as pageWidth in screenshot)
@webolizzer
webolizzer / prevent-zooming-cross-browser-with-jquery.js
Last active March 10, 2017 13:55
prevent zooming cross-browser with jquery
// prevent zooming cross-browser with jquery
// @author http://stackoverflow.com/a/31131948/2337281
$(document).keydown(function(event) {
if (event.ctrlKey === true && (event.which == '61' || event.which == '107' || event.which == '173' || event.which == '109' || event.which == '187' || event.which == '189' ) ) {
//alert('disabling zooming k');
event.preventDefault();
// 107 Num Key +
// 109 Num Key -
// 173 Min Key hyphen/underscor Hey
@webolizzer
webolizzer / onchange.sh
Created February 9, 2017 15:17 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@webolizzer
webolizzer / gist:30f78d5650048690b63a3787ac033788
Created October 18, 2016 17:56
simple PHP wrapper around wkhtmltopdf
<?php
/**
* @version 0.1
* @author github.com/webolizzer
* If you find it useful, you can buy me a coffee and a Kit-Kat @ paypal.me/webolizzer
* Thank you! :)
*/
class pdfGenerator {