Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
@roman01la
roman01la / animLoopX.js
Created July 28, 2012 14:41 — forked from louisremi/animLoopX.js
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@roman01la
roman01la / resize.js
Created July 31, 2012 16:16 — forked from robtarr/resize.js
Google Analytics Resize Tracking
(function() {
var resizeTimer;
// Assuming we have jQuery present
$( window ).on( "resize", function() {
// Use resizeTimer to throttle the resize handler
clearTimeout( resizeTimer );
resizeTimer = setTimeout(function() {
@roman01la
roman01la / index.html
Created June 17, 2013 01:32
THREE.js scene setup with JSONLoader for OSM2WebGL demo
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="viewport"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min.js"></script>
<script src="//threejs.org/examples/js/controls/OrbitControls.js"></script>
@roman01la
roman01la / index.html
Created September 29, 2013 20:06
Web Component Example
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="import" href="components/my-element.html">
</head>
<body>
@roman01la
roman01la / scroll_perf.js
Created October 1, 2013 10:48
How to handle scroll event properly
function updatePage() {
// do stuff
scheduleAnimationFrame = false;
}
function onScroll() {
lastScroll = window.scrollY;
@roman01la
roman01la / singleton.js
Created October 26, 2013 05:08
JS Singleton
var Singletone = (function () {
var instance;
return function Construct_singletone () {
if (instance) {
return instance;
}
if (this && this.constructor === Construct_singletone) {
(function() {
window.Class = function() {};
Class.extend = function (props, staticProps) {
var mixins = [];
if ({}.toString.apply(arguments[0]) == "[object Array]") {
var message = "hello, how are you Tal?";
if (~message.indexOf('Tal')) {
console.log('found matching text');
}
// Boring
if (isThisAwesome) {
alert('yes'); // it's not
}
// Awesome
isThisAwesome && alert('yes');
// Also cool for guarding your code
var aCoolFunction = undefined;
@roman01la
roman01la / recursion.coffee
Created January 26, 2014 02:32
JS Recursion vs Trampoline
countDown = (n) ->
console.log(n)
if n > 0
countDown(n-1)
else
console.log('DONE!')
countDown(1000000)