Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
/*
Simple styles to have section elements skew at one end
*/
.section {
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
}
/**
* Prefix an integer with 0-s (zeros), resulting in the specified length
*
* @param num int integer to prepend
* @param length int length of the desired number
*/
function prefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length);
}
// Simple check so we could use a single button for different mobile OS-s
var operatingSystem, userAgentString = navigator.userAgent;
var link = $("#store");
if (userAgentString.indexOf("iPhone") > -1 || userAgentString.indexOf("iPod") > -1 || userAgentString.indexOf("iPad") > -1) {
operatingSystem = "iOS";
link.attr("href", "http://store.apple.com/us/browse/app");
} else if (/Android/.test(userAgentString)) {
operatingSystem = "Android";
link.attr("href", "https://play.google.com/store/apps?hl=en");
/**
* author: andreas johan virkus
* snippet url: https://gist.github.com/andreasvirkus/bfaedc839de0d46ffe4c
*
* Remove classes that have given prefix
* Example: You have an element with classes "apple juiceSmall juiceBig banana"
* You run:
* $elem.removeClassPrefix('juice');
* The resulting classes are "apple banana"
*/
// v1
$.ajax({
url: path,
xhrFields: {
onprogress: function (e) {
if (e.lengthComputable) {
// Progress..
console.log(e.loaded / e.total * 100 + '%');
}
}
// Custom jQuery select element
// Iterate over each select element
$('select').each(function() {
// Cache the number of options
var $this = $(this),
numberOfOptions = $(this).children('option').length;
// Hides the select element
$this.addClass('s-hidden');
$(window).on('mousewheel DOMMouseScroll touchmove', function (e) {
var direction = (function () {
var delta,
compareEvent;
if (e.type ==='touchmove') {
compareEvent = 'touchmove';
} else {
compareEvent = 'DOMMouseScroll';
function caesarShift(text, shift) {
var codes = [];
for (var i = 0; i < text.length; i++) {
var c = text.charCodeAt(i);
if (c >= 65 && c <= 90) {
c = (c - 65 + shift) % 26 + 65; // Uppercase
} else if (c >= 97 && c <= 122) {
c = (c - 97 + shift) % 26 + 97; // Lowercase
// ==UserScript==
// @name Twitch.tv - force old flash player
// @namespace ajvtwitchold
// @description Replaces default twitch player with old Flash player.
// @description original author - 420foxbot
// @description link to original script - https://gitlab.com/foxbot/Twitch5ForAll/raw/master/twitch5.user.js
// @version 1
// @grant none
// @match http://*.twitch.tv/*
// ==/UserScript==
/**
* If the screen width is greater than the RV breakpoint, then make the sub-menu toggle
* act as a regular link based on the <a> tag's title attribute, otherwise toggle
* the sub menu's visibility.
*
* This found use in a WP theme
*/
$subMenuToggle = domCache('.sub-menu-toggle'),
$subMenuToggle.on('click', function (event) {