Skip to content

Instantly share code, notes, and snippets.

View joelstein's full-sized avatar

Joel Stein joelstein

View GitHub Profile
@joelstein
joelstein / gist:5482015
Last active December 16, 2015 19:00
Condensed function for injecting arguments into SQL query, properly escaped and quoted. Uses recursive anonymous function for nested arguments.
<?php
/**
* Returns query with escaped args injected into query.
*
* @param string $sql The query string.
* @param array $args The arguments to escape, quote, and inject into the query.
*/
function query($sql, $args = array()) {
$quote = function($value) use (&$quote) {
@joelstein
joelstein / gist:9349638
Last active August 29, 2015 13:57
ESRI Angular directive
// ESRI directive.
angular.module('esri', []).directive('esri', function() {
return {
scope: {
address: '=',
zoomable: '=',
enabled: '='
},
link: function(scope, element, attrs) {
var map;
@joelstein
joelstein / gist:9370369
Last active August 29, 2015 13:57
Angular sticky list (requires jQuery)
// Sticky list directive.
angular.module('stickylist', []).directive('stickyList', function() {
// Stick header by setting the position to fixed, top to 0, and adding a
// "sticky" class so additional CSS can be applied. Padding is added to
// parent <li>.
var stick = function($header) {
$header.css({position: 'fixed', top: 0}).addClass('sticky');
$header.parent().css('paddingTop', $header.outerHeight());
}
@joelstein
joelstein / TODO.md
Last active August 29, 2015 13:57
Vagrant
@joelstein
joelstein / _mixins.scss
Last active February 1, 2017 13:33
Horizontal list mixins
// Standard horizontal list, using word-spacing trick to remove whitespace
// between inline-block elements.
@mixin horizontal-list {
padding: 0;
text-align: center;
word-spacing: -1em;
display: table;
width: 100%;
li {
@joelstein
joelstein / custom.module
Last active August 29, 2015 14:08
Drupal Picture/Breakpoints Image Styles Generator
<?php
/**
* Configure ratios, columns, breakpoints, and other stuff.
*/
function custom_config() {
return array(
'ratios' => array(
'wide' => array('width' => 1, 'height' => .5),
'normal' => array('width' => 1, 'height' => .75),
@joelstein
joelstein / _base.sass
Last active August 29, 2015 14:13
Common Sass stuff
// Responsive images.
img, media
max-width: 100%
// Messages.
.messages
margin: 1em 0
// Tabs.
.tabs
@joelstein
joelstein / README.md
Last active August 29, 2015 14:13
CKEditor custom styles
  • If Advanced Content Filter is enabled, need to configure "extra allowed content" to let elements have classes.
  • A catch all value is *(*), which means any element can have any class added to it.
  • To refine this, you can limit available classes, like *(left, right), which will only let "left" and "right" classes be added.
  • Enhanced Image (image2 plugin) can only be targeted through a "widget" type, by defining type: 'widget' and then widget: 'image'.
@joelstein
joelstein / gist:f110cb412592582f9d44
Last active August 8, 2017 17:59
Angular Drupal Behaviors directive
angular.module('drupalBehaviors', [])
.directive('drupalBehaviors', function($timeout) {
return {
restrict: 'AE',
link: function(scope, element, attrs) {
function attach() {
$timeout(function() {
Drupal.attachBehaviors(element.get(0), drupalSettings);
});
@joelstein
joelstein / Entrust.net_Secure_Server_CA.pem
Last active August 29, 2015 14:16
/etc/ssl/certs/Entrust.net_Secure_Server_CA.pem / ed524cf5.0
-----BEGIN CERTIFICATE-----
MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1
MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE
ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j
b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF
bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg