Skip to content

Instantly share code, notes, and snippets.

@jtwalters
jtwalters / pixel-border-workaround.css
Last active August 29, 2015 14:15
CSS Workaround: 1 pixel border with percentage width columns
.parent {
position: relative;
}
.parent:before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
# Don't cache anything
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
</ifModule>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Form</title>
</head>
<body>
<form>
@jtwalters
jtwalters / d7-remote-file-save.php
Created January 20, 2015 17:52
Save a remote file URI in Drupal 7
<?php
$file = remote_stream_wrapper_file_create_by_uri($uri);
$file_result = file_save($file);
@jtwalters
jtwalters / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jtwalters
jtwalters / SassMeister-input-HTML.html
Created December 11, 2014 17:31
Generated by SassMeister.com.
<div class="gallery-item">1</div>
<div class="gallery-item">2</div>
<div class="gallery-item">3</div>
<div class="gallery-item">4</div>
<div class="gallery-item">5</div>
<div class="gallery-item">6</div>
<div class="gallery-item">7</div>
<div class="gallery-item">8</div>
<div class="gallery-item">9</div>
<div class="gallery-item">10</div>
// Cross-scope compatible placeholder boilerplate.
@mixin my-mixin($extend: true) {
@if $extend {
@extend %my-mixin;
}
@else {
// Mixin core
}
}
@jtwalters
jtwalters / cross-browser-window-load-function.js
Last active November 16, 2016 22:04
Cross browser addEvent function (window load, ready, etc.)
(function () {
//////////////////////////////
// Add event (cross browser)
// From http://stackoverflow.com/a/10150042
//////////////////////////////
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent('on' + event, function() {
@jtwalters
jtwalters / SassMeister-input-HTML.html
Created November 12, 2014 20:34
Generated by SassMeister.com.
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
<?php
//assuming $node exists
$my_collection = entity_create('field_collection_item', array('field_name' => 'field_my_collection'));
$my_collection->setHostEntity('node', $node);
$my_collection->field_text_data[LANGUAGE_NONE][0]['value'] = "hello";
$my_collection->field_term_ref[LANGUAGE_NONE][0]['tid'] = 123;
$my_collection->field_node_ref[LANGUAGE_NONE][0]['target_id'] = 345;
$my_collection->save();
node_save($node);