Skip to content

Instantly share code, notes, and snippets.

@keeprock
keeprock / info.md
Last active August 29, 2015 14:17
Place thumbnail accordionally and proportionally its width and height.

It's a three (actually 4) step process:

  • Install Image Cache Actions

Settings inside image styles screen:

  • Масштабирование 150x150
  • Define canvas 150x150 (center, center) #ffffff under image
  • Обрезка 150x150
@keeprock
keeprock / module.php
Last active August 29, 2015 14:18
Fix translation issue with taxonomy terms displayed via views module http://ggordan.com/post/localising-taxonomy-terms-in-views.html
/*
* Implementation hook_views_api()
*/
function CUSTOM_views_api() {
return array(
'api' => 3,
);
}
/*

Filter criteria is essential. Must use Filter: Language (Current user's language)

div {
position: absolute;
left: 50%;
top: 50%;
-o-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
@keeprock
keeprock / style.js
Last active August 29, 2015 14:18
Create tooltip on click using marker
var point = new google.maps.LatLng(COORDS);
var data = "SOME_TEXT";
var infowindow = new google.maps.InfoWindow({
content: data
});
var marker = new google.maps.Marker({
position: point,
title:"SOME_TEXT"
});
google.maps.event.addListener(marker, 'click', function() {
@keeprock
keeprock / script.js
Created April 9, 2015 07:39
Successful Ajax XHR
var success = Drupal.ajax.prototype.success;
Drupal.ajax.prototype.success = function (xmlhttprequest, options) {
success.apply(this, arguments);
// do stuff here
}
@keeprock
keeprock / regex.php
Last active August 29, 2015 14:22
Use Regex to replace text between HTML tags
preg_match('/>([^<]*)/i', $bread_item, $text);
$bread_item_text = preg_replace("/&#?[a-z0-9]+;/i", "", $text[1]);
$bread_item_text = '>' . truncate_utf8($bread_item_text, 50, TRUE, TRUE, 1) . '<';
$bread_item_text = preg_replace('/>[^<]*</i', $bread_item_text, $bread_item);
$breadcrumb[$key] = $bread_item_text;
@mixin fontFace($family,$src,$style: normal,$weight: normal) {
@font-face {
font-family: $family;
src: url('#{$src}.eot'); // IE9 compat
src: url('#{$src}.eot?#iefix') format('embedded-opentype'), // IE8 and below
url('#{$src}.woff') format('woff'), // standards
url('#{$src}.ttf') format('truetype'), // Safari, Android, iOS
url('#{$src}.svg##{$family}') format('svg'); // legacy iOS
font-style: $style;
@keeprock
keeprock / request.js
Created October 10, 2015 22:03
Request Animation Frame
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
@keeprock
keeprock / app.js
Created October 19, 2015 13:51 — forked from kevinSuttle/app.js
Gulp, BrowserSync, Sass, Autoprefixer, Nodemon
var express = require('express');
var app = express();
var router = express.Router();
var hbs = require('hbs');
app.set('view engine', 'html');
app.engine('html', hbs.__express);
app.use(express.json());
app.use(express.urlencoded());