Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / dynamically-load.js
Last active March 1, 2021 16:02
JavaScript: dynamically loading (include) JavaScript and CSS
// Code snippets for dynamically loading JavaScript and CSS
// Copyright : This script has been placed in the public domain.
// Gist : https://gist.github.com/livibetter/5211293
// Blog post : http://blog.yjl.im/2013/03/dynamically-loading-javascript-and-css.html
// Last update : 2013-03-21T07:35:25Z
// Author : Yu-Jie Lin
// Website : http://yjl.im
function load_CSS(src, cb) {
var link = document.createElement('link');
@vyspiansky
vyspiansky / support-posfixed.js
Created March 27, 2014 21:11 — forked from scottjehl/support-posfixed.js
jQuery: test for CSS position: fixed support
/* jQuery-based feature test for CSS position: fixed support.
Modified from Kangax's test (http://kangax.github.com/cft/#IS_POSITION_FIXED_SUPPORTED) in two ways: 1) uses jQuery API, 2) remove document.body dependency.
Method changes aside, the required workaround for dropping document.body use was to set scroll using window.scrollTo instead of body.scrollTop.
//Testing notes:
iOS4.3: false (expected)
iOS5: true (expected)
Chrome latest: true (expected)
...more soon
*/
@vyspiansky
vyspiansky / random-record-from-model.php
Last active November 10, 2016 06:44 — forked from hugodotlau/gist:4031109
Yii: how can I get random values from model
<?php
// Source: http://goo.gl/NOCJKM
$max = Table::model()->count(array(
'condition' => 'status<:status',
'params' => array('status' => Table::STATUS_A)
));
$offset = rand(0, $max);