Skip to content

Instantly share code, notes, and snippets.

@oslego
oslego / markup.html
Created January 4, 2012 15:43
codeoff-test
<!DOCTYPE HTML>
<html lang="ru-RU">
<head>
<title></title>
<meta charset="UTF-8">
</head>
<body>
<script src="https://gist.github.com/1560618.js"> </script>
tsk
</body>
@oslego
oslego / list.rb
Created January 4, 2012 16:05
Related Lists
class List < ActiveRecord::Base
has_many :related_lists, :finder_sql => 'SELECT * FROM related_lists WHERE list_a_id = #{id} OR list_b_id = #{id}'
end
@oslego
oslego / counter.css
Created January 11, 2012 15:38
Counter in CSS
body{
counter-reset: region-order;
}
[data-region]::before{
display:block;
color:red;
content: counter(region-order);
counter-increment: region-order;
}
@oslego
oslego / regions-events.js
Created February 20, 2012 16:54
Workaround to make CSS Regions handle click events
// Free to use, reuse and abuse.
// Have fun! razvan.caliman@gmail.com
(function(){
// Hack to make CSS Regions trigger click event handlers.
// Workaround for CSS Regions bug #76454 - https://bugs.webkit.org/show_bug.cgi?id=76454
document.addEventListener("click", function(e){
// get all the regions from the document based on a selector
@oslego
oslego / arraytemplate.js
Created April 20, 2012 10:25
Templates in JavaScript using Array
/*
Neat alternative to JavaScript templating by using an array.
Inspired by Ryan Florence
https://github.com/rpflorence/snack/blob/master/demos/jsonp/demo.js
*/
var h = [],
p = function (){ h.push.apply(h, arguments) },
data = ["one", "two", "three"]
@oslego
oslego / support.js
Created April 30, 2012 11:33
Basic DOM property checking
// based on http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-detect-css-support-in-browsers-with-javascript/
var support = (function() {
var div = document.createElement('div'),
vendors = 'Khtml Ms O Moz Webkit'.split(' '),
len = vendors.length;
return function(prop) {
if ( prop in div.style ) return true;
prop = prop.replace(/^[a-z]/, function(val) {
@oslego
oslego / index.html
Created May 28, 2012 15:12
QUnit and Browserscope boilerplate code.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/jquery.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript">
// To save data in Browserscope do something like the following.
// The syntax is 'test_key': 'value' where test_key is some unique
@oslego
oslego / .gitignore
Created October 9, 2012 22:35
Introduction on CSS FilterLab
Introducing CSS FilterLab.docx
@oslego
oslego / noquery.js
Created October 31, 2012 22:42
Small jquery-like experiment
var $ = function(){
function noQuery() {
var args = Array.prototype.slice.call(arguments, 0)[0],
query = args[0]
qsa = function(q){
return Array.prototype.slice.call(document.querySelectorAll(q), 0)
}
this.el = []
@oslego
oslego / supports.js
Last active November 21, 2022 22:08
Basic feature detection with prefix support.
var Supports = (function(){
// all spaces are important!
var prefixes = ' -webkit- -moz- -o- -ms- ';
function getPrefixedProperties(property, prefixes) {
var properties = prefixes.join(property + " ").split(' ');
// ignore the last string which is empty.
return properties.slice(0, properties.length-1);
}