Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
chrisjlee / drupal-views-share-global-text-field
Last active April 23, 2024 04:07
share url's for facebook, twitter, pinterest with just get variables
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>
@mattheu
mattheu / HM-Debug.php
Last active December 19, 2015 17:19
Human Made debugging functions
<?php
/**
* Intelligently replacement for print_r & var_dump.
*
* @param mixed $code
* @param bool $output. (default: true)
* @return $code
*/
function hm( $code, $output = true ) {
@joyrexus
joyrexus / README.md
Last active June 19, 2024 09:35 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@didats
didats / nationality.html
Created December 28, 2013 00:00
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
@liamr
liamr / gist:9104020
Created February 19, 2014 23:48
Open external links in a new window
$("a[rel=external], a[href^='http:']:not([href*='" + window.location.host + "']), a[href^='https:']:not([href*='" + window.location.host + "'])").each(function(){
$(this).attr("target", "_blank");
});
@richgcook
richgcook / gist:7ec0dec2a5b8e25b964f
Created June 4, 2014 10:43
Find unicode of glyph/symbol (useful for CSS content)
'➜'.charCodeAt(0).toString(16); //enter in console – outputs '279c'
// Then add \ at the front, so the full code would be:
ul li:before {
content: '\279c';
}
@richgcook
richgcook / gist:7ba48ed3f4704db6aca8
Created June 18, 2014 13:53
jQuery – hide the container when clicked outside
$(document).mouseup(function(e) {
var container = $('YOUR CONTAINER SELECTOR');
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.fadeOut('fast');
}
});
@bgarrant
bgarrant / ValetSwitchPHP.md
Last active September 30, 2022 08:08
How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

Valet switch PHP version with these commands

Install PHP 5.6 and switch Valet to PHP 5.6

valet stop
brew unlink php71
brew install php56
brew install php56-mcrypt
@chaance
chaance / menu.js
Created September 12, 2018 14:24
Recursive menu component (React + Next.js)
import React, { Component } from 'react';
import Link from 'next/link';
import { uniqueId } from 'lodash';
import PropTypes from 'prop-types';
class Menu extends Component {
renderSubMenu = (children) => {
if (children && children.length > 0) {
return (
<ul className="menu__submenu">{this.renderMenuItems(children)}</ul>
@terryupton
terryupton / modal.twig
Created April 9, 2020 18:18
Ajax Loading a page into a modal with Alpine JS
<section x-data="{showModal: false, html: ''}">
<button
@click="html='loading...'; showLoading = true; showModal = !showModal;
fetch('{{ entry.url }}', {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
})