Skip to content

Instantly share code, notes, and snippets.

View lifedraft's full-sized avatar

Stanislav lifedraft

View GitHub Profile
@lifedraft
lifedraft / gist:964184
Created May 10, 2011 09:39
SQL Queries to find bad drupal data
We couldn’t find that file to show.
@lifedraft
lifedraft / gist:1019109
Created June 10, 2011 15:49
Alternative to adaptjs (http://adapt.960.gs/)
(function(w,d, ranges) {
var html = document.documentElement
window.onresize = function() {
var width = w.innerWidth || d.documentElement.clientWidth || d.body.clientWidth || 0;
for (var i=0; i < ranges.length; i++) {
if (ranges[i] < width) {
break;
};
@lifedraft
lifedraft / gist:7351155
Created November 7, 2013 08:36
Using drupal's webform_token module to replace values of confirmation message. e.q: Congratulations, [webform:val-salutation]. [webform:val-last_name]
function hook_preprocess_webform_confirmation(&$vars) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
$node = $vars['node'];
$webform = $node->webform;
$submission = webform_get_submission($node->nid, $vars["sid"]);
$confirmation = $node->webform['confirmation'];
$confirmation = token_replace($confirmation, array('webform' => $submission), array('webform_tokens'));
$vars['confirmation_message'] = $confirmation;
@lifedraft
lifedraft / gist:7655319
Last active December 29, 2015 10:09
Debouncing Window Scroll events with requestAnimationFrame #jquery. Source: http://www.html5rocks.com/en/tutorials/speed/animations/
jQuery.request_scroll = (callback) ->
###
Callback for our scroll event - just
keeps a track on the last scroll value
###
onScroll = ->
lastScrollY = window.scrollY
requestTick()
@lifedraft
lifedraft / Gruntfile.js
Last active December 29, 2015 17:29
Compile all coffee and compass files recursively within an project with grunt.
module.exports = function( grunt ) {
// Compile all coffee and compass files recursively within an project with grunt.
// Usage:
// > cd <my-project>
// > npm install grunt-contrib-watch
@lifedraft
lifedraft / gist:9115070
Created February 20, 2014 14:38
Execute some action on click/touchend after the second tap on an element.
if Modernizr.touch
_active = null
$context.bind 'touchend', (event) ->
_active = null
links = $context.find('.contents-item a').bind 'touchend', ->
if _active != this
_active = this
return false
@lifedraft
lifedraft / gist:9250476
Created February 27, 2014 13:55
Update meta viewport tag's content for fit page width. ios and android safe.
viewport = document.getElementById('viewport')
orientationchange = (event) ->
unit = "width"
current_orientation = window.orientation
wider = window.screen.width > window.screen.height
if (current_orientation == 180 and wider) or
(current_orientation == 0 and wider) or
(current_orientation == -90 and !wider) or
@lifedraft
lifedraft / gist:3741b4045f5e78360c46
Created June 5, 2014 09:22
one page scroll implementation. made to work with offset content, eq. header or footer.
sections = jQuery('.dd_skrollr-numbers-section')
wrapper = jQuery('.dd_skrollr-numbers')
page_bottom = document.body.scrollHeight
# leave top
wrapper_position_top = wrapper.offset().top
wrapper_height = wrapper.height()
wrapper_position_bottom = wrapper_height + wrapper_position_top
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../chart-js/chart-js.html">
@lifedraft
lifedraft / machine.js
Created September 11, 2019 12:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions