Skip to content

Instantly share code, notes, and snippets.

View halfzebra's full-sized avatar

Eduard Kyvenko halfzebra

View GitHub Profile
@halfzebra
halfzebra / 960bookmarklet.js
Last active August 29, 2015 13:58
960px grid overlay bookmarklet
javascript:(function() {var css="body:before { content: ''; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAABCAYAAABJwyn/AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpGNzdGMTE3NDA3MjA2ODExODA4M0VCODNDNjJCRDdDMSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoxRDI5NUJBMkJFOUYxMUUzQjg4QUJDRDZERENEOTdFRiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoxRDI5NUJBMUJFOUYxMUUzQjg4QUJDRDZEREN
$.fn.tooltip = function( method ) {
// decide what to do next...
// if we have a methods[method] then let's try to invoke it
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
// this is an object so we should try to pass it as options
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
@halfzebra
halfzebra / gist:7586cdc5366949ea174a
Created May 20, 2015 10:55
Invisible bold placeholder for :hover { font-weight: bold; }
a {
&:after {
content: attr(title);
color: transparent;
visibility: hidden;
font-weight: bold;
overflow: hidden;
display: block;
height: 1px;
}
@halfzebra
halfzebra / gist:d8b8cfa33d882a949262
Last active August 29, 2015 14:22
SCSS Namespaces
$namespase: 'text';
.#{$namespase} {
display: inline;
&-red {
color: red;
}
&-bold {
@halfzebra
halfzebra / example
Last active August 29, 2015 14:22
Drupal 7: Dynamic term generation for exsisting parent
$vocab_machine_name = 'name';
$vacab = taxonomy_vocabulary_machine_name_load($vocab_machine_name);
if (isset($vacab->vid)) {
$vid = $vacab->vid;
$terms = taxonomy_get_term_by_name('parent', $vocab_machine_name);
$parent_term = array_pop($terms);
// Create terms what needed.
@halfzebra
halfzebra / jquery.createLabels.js
Created July 13, 2015 22:30
jQuery plugin that generates labels for inputs
/**
* A plugin to add labels for any kind of supported elements.
*
* @param settings
* @returns {jQuery}
*/
$.fn.createLabels = function(settings) {
var idAttr,
result,
@halfzebra
halfzebra / SassMeister-input.sass
Created July 15, 2015 17:53
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// Bourbon (v4.2.3)
// Modular Scale (v2.1.1)
// ----
@import "modular-scale"
@import bourbon/bourbon
@halfzebra
halfzebra / gist:3f836902997aa0493fd1
Created July 16, 2015 10:29
An example of incapsulation with constructors in JavaScript
(function () {
'use strict';
function hasOwnProperty(obj, prop) {
var proto = obj.__proto__ || obj.constructor.prototype;
return (prop in obj) && (!(prop in proto) || proto[prop] !== obj[prop]);
}
var Button = function (settings) {
@halfzebra
halfzebra / SassMeister-input.scss
Created July 17, 2015 18:04
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
@for $i from 1 through 6 {
&.front:nth-child(#{$i}), &.back:nth-child(#{$i}) {
$brick-bg: '../image/brick' + random(6) + '.jpg';
background-image: url($brick-bg);
background-size: 100% 100%;
}
@halfzebra
halfzebra / SassMeister-input-HTML.html
Created July 20, 2015 08:13
Generated by SassMeister.com.
<div class="block block-1-1">
<img src="//placehold.it/50x50">
</div>
<div class="block block-1-2">
<img src="//placehold.it/50x50">
</div>
<div class="block block-1-3">
<img src="//placehold.it/50x50">
</div>
<div class="block block-2-1">