Skip to content

Instantly share code, notes, and snippets.

View pbojinov's full-sized avatar

Petar Bojinov pbojinov

View GitHub Profile
@pbojinov
pbojinov / tapp.ascii.html
Last active August 29, 2015 14:06
Tapp ascii logo simple
<!--
________ _______ ______ ________ ___ ___
|__ __| /\ | _ \| _ \ |__ __|\ \ / /
| | / \ | |_| | |_| | | | \ \/ /
| | / \ | ___/| ___/ | | \ /
| | / /\ \ | | | | | | \ /
|__|/__/ \__\|__| |__| |__| \/
-->
/**
* The Page Visibility API adds two new properties to the document object.
*
* document.hidden
* document.visibilityState
*
* The hidden property is a boolean representing the current visibility of the page.
*
* The visibilityState property is a string that gives more information about the current page state. This property has four possible values:
*
@pbojinov
pbojinov / framekillers.html
Created September 24, 2014 20:15
frame jacking frame killers
// Most common
<script type="text/javascript">
if (top != self) top.location.replace(location);
</script>
// Modern Framekiller
// http://seclab.stanford.edu/websec/framebusting/framebust.pdf
<style> html{display:none;} </style>
<script>
if (self == top) {
@pbojinov
pbojinov / each.js
Created October 21, 2014 23:25
jQuery's each method with a shim to check if passed in value is an array
// jQuery's each method
// https://github.com/jquery/jquery/blob/master/src/core.js#L279
function each(obj, callback, args) {
var value,
i = 0,
length = obj.length,
isArray = isArraylike(obj);
if (args) {
if (isArray) {
@pbojinov
pbojinov / jquery.string.template.js
Created October 30, 2014 23:37
jquery string template
var $template = $([
'<div class="tappification tappification-dismissible" data-position="" role="alert">',
' <div class="container">',
' <div class="tappification-icon">',
' <i class="fa"></i>',
' </div>',
' <div class="tappification-message"></div>',
' <div class="tappification-link">',
' <a class="primary"></a>',
' </div>',
@pbojinov
pbojinov / dispatch-table.js
Created November 3, 2014 19:25
using dispatch tables - aka avoid using switch
// http://designpepper.com/blog/drips/using-dispatch-tables-to-avoid-conditionals-in-javascript
// avoid this, switch blah
function processUserInput(command) {
switch (command) {
case "north":
movePlayer("north");
break;
case "east":
movePlayer("east");
@pbojinov
pbojinov / parallax.js
Last active August 29, 2015 14:09
parallax techniques
// ------------------------------------------------------
// set background image to fixed
parallax-bg {
background-image: url('...');
background-size: cover;
background-attachment: fixed;
}
// ------------------------------------------------------
// set whole container fixed or absolute and allow other content to go over it
@pbojinov
pbojinov / requestAnimationFrame.shim.js
Created November 17, 2014 22:11
requestAnimationFrame Shim
/**
* Paul Irish on RequestAnimFrame
*
* http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
*/
// shim layer with setTimeout fallback
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
@pbojinov
pbojinov / readme.txt
Created November 30, 2014 01:06
stop sublime text from crashing on startup
Just go to this path delete all the files. Sublime will start working fresh.
cd ~/.config/sublime-text-3/Local
rm *
var transforms = ["transform",
"msTransform",
"webkitTransform",
"mozTransform",
"oTransform"
];
var transformProperty = getSupportedPropertyName(transforms);
var imageContainer = document.querySelector(".featured__image");