Skip to content

Instantly share code, notes, and snippets.

View jimmynotjim's full-sized avatar
☀️
Enjoying SoCal "Fall"

Jimmy Wilson jimmynotjim

☀️
Enjoying SoCal "Fall"
View GitHub Profile
@nternetinspired
nternetinspired / gist:7482445
Last active February 24, 2022 17:20
Load Disqus comments only on demand if you give a shit about page weight and your visitors. Even with no comments, i.e. an empty comment form, calling Disqus will load an extra 226Kb. If your page has comments this can be far higher. This Gist accompanies my blog post: http://internet-inspired.com/wrote/load-disqus-on-demand/
// Requires jQuery of course.
$(document).ready(function() {
$('.show-comments').on('click', function(){
var disqus_shortname = 'YOUR-DISQUS-USERNAME'; // Replace this value with *your* username.
// ajax request to load the disqus javascript
$.ajax({
type: "GET",
url: "http://" + disqus_shortname + ".disqus.com/embed.js",
dataType: "script",
@frdmn
frdmn / osx-10-10-virtualbox.md
Last active February 22, 2022 08:39
Install OS X 10.10 Yosemite in VirtualBox
@CaptainN
CaptainN / jquery.mobile.just-touch.js
Created March 29, 2012 20:06
Just touch events for jQuery
// This is a combination of two modified files from jQuery Mobile,
// jquery.mobile.vmouse.js and jquery.mobile.event.js
// They were modified to only provide the touch event shortcuts, and
// avoid the rest of the jQuery Mobile framework.
// The normal jQuery Mobile license applies. http://jquery.org/license
//
// This plugin is an experiment for abstracting away the touch and mouse
// events so that developers don't have to worry about which method of input
// the device their document is loaded on supports.
//
@lorenzopolidori
lorenzopolidori / has3d.js
Last active December 4, 2020 10:52 — forked from webinista/has3d.js
Testing for CSS 3D Transforms Support
function has3d(){
if (!window.getComputedStyle) {
return false;
}
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
@poteto
poteto / _media_queries.sass
Created October 22, 2012 13:54
Sass media queries
// Standard device screen widths
$iphone-portrait: 320px
$iphone-landscape: 480px
$ipad-portrait: 767px
$ipad-landscape: 980px
$desktop: 1224px
$desktop-large: 1824px
// General device targeting
// Use: Only use if you want the style to apply to many devices
@germanny
germanny / vimeo_largest_image
Created October 26, 2012 22:38
Get Vimeo 1280px poster image
// Vimeo serves up poster images in 100, 200 and 640. But there's also size they don't serve: 1280
// https://developer.vimeo.com/apis/simple
$vimeo_value = get_post_meta($post->ID, 'vimeo_value', TRUE);
$vimeo_video_id = substr($vimeo_value, strrpos($vimeo_value, '/')+1); // get just the id
$vimeo_xml_file = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vimeo_video_id.php")); // get the video data from the API
$vimeo_video_width = $vimeo_xml_file[0]['width'];
$vimeo_thumbnail_large = $vimeo_xml_file[0]['thumbnail_large']; // load up one of the image sizes
if($vimeo_video_width < 1280) {
$vimeo_thumbnail = $vimeo_thumbnail_large;
@ericrasch
ericrasch / is_child.php
Last active October 29, 2019 16:18
WordPress conditional function to check if a page is a parent/child/ancestor. In other words, if the page is within a tree of another page, show the code. Other code I've seen either only work with IDs, only check if it's a child, or detect all subpages (even outside of the direct tree).
/* =BEGIN: Check If Page Is Child
Source: http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/
---------------------------------------------------------------------------------------------------- */
function is_child( $page_id_or_slug ) { // $page_id_or_slug = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( !is_numeric( $page_id_or_slug ) ) { // Used this code to change a slug to an ID, but had to change is_int to is_numeric for it to work.
$page = get_page_by_path( $page_id_or_slug );
$page_id_or_slug = $page->ID;
}
@germanny
germanny / inc-state-abbreviations.php
Created October 10, 2012 22:41
Responsive States Map. Includes states listing with abbreviations and AI file of the map. Uses both http://archive.plugins.jquery.com/project/maphilight and https://github.com/stowball/jQuery-rwdImageMaps. Requires the latest version of jQuery or you'll b
<?php
switch ($map_state)
{
case 'Alabama':
$abbr = 'AL';
break;
case 'Alaska':
$abbr = 'AK';
break;
@ascott1
ascott1 / tinfoil.md
Last active February 25, 2019 13:31
The levels of internet privacy

These are some steps that users can take to retain privacy online. These aren't perfect, but aim to strike a balance between privacy and usability.

Level 1

  • Enable Do Not Track in your browser
  • Use a tracker blocking plugin such as Privacy Badger or Ghostery
  • Disable third-party cookies
  • Use the HTTPS Everywhere browser extension