Skip to content

Instantly share code, notes, and snippets.

View ajmalafif's full-sized avatar
💻

Ajmal Afif ajmalafif

💻
View GitHub Profile
@ajmalafif
ajmalafif / gist:14a7eae3ac540610743d
Created November 1, 2015 14:11 — forked from nternetinspired/gist:7482445
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",
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input type="text" id="growthrate" placeholde="edit growth">
@ajmalafif
ajmalafif / prawndown.coffee
Created July 14, 2016 08:07 — forked from henrik/prawndown.coffee
Prawndown! Super-tiny subset of Markdown for use with the Prawn PDF lib.
class Prawndown
constructor: (@text) ->
toPrawn: ->
@text.
replace(/\n/g, "<br>\n").
replace(/^# (.+)/gm, "<b>$1</b>")
# Use:
console.log (new Prawndown("# Foo\nbar")).toPrawn()
@ajmalafif
ajmalafif / README-Template.md
Created July 17, 2016 07:07 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisities

var b = document.documentElement;
b.setAttribute('data-useragent', navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
// Source: http://rog.ie/blog/html5-boilerplate-addon
@ajmalafif
ajmalafif / service-workers.md
Created August 23, 2016 05:29 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

Auto-Didactism: Part 1 — Principles

I want to write a bit about how I've approached learning and how to learn effectively. I don't claim to be the world's foremost expert in learning but I've generalized my process to things like:

  • Fortune 100 R&D Engineering at a global leader — (Resume)
  • Handwalking — Watch me do stairs HERE
  • Web Development — (Github)
  • Zero to Backflip in 3 hours
  • Guitar self-accompaniment for songs
  • West Coast Swing (Just started with the GF!)
@ajmalafif
ajmalafif / CharacterMotorC.cs
Created December 22, 2016 01:49 — forked from zephjc/CharacterMotorC.cs
Fixed C# replacements of CharacterMotor.js and FPSInputController.js via http://forum.unity3d.com/threads/93527-FPSInputController-and-CharacterMotor-in-Csharp Changes from above link: FPSInputController: Removed "Event.laddertrigger" code which is not part of the original JS file CharacterMotor: Lets the various inner properties classes show up…
using UnityEngine;
using System.Collections;
//#pragma strict
//#pragma implicit
//#pragma downcast
// Require a character controller to be attached to the same game object
// I had to initally comment out the following RequireComponent
// line to make it compile and allow attaching to my Main Camera;

How to replace Bootstrap with Foundation for Roots/Sage

1. Clone, clean and install

  • Clone repo: git clone https://github.com/roots/sage.git
  • Remove Bootstrap: bower uninstall bootstrap-sass -S
  • Install Foundation: bower install foundation -S
  • Install NPM packages: npm install

2. Add Foundation overrides to bower.json like this:

@ajmalafif
ajmalafif / get-first-image.liquid
Created February 24, 2017 15:07 — forked from dominikwilkowski/get-first-image.liquid
This snippet takes HTML content from the Shopify editor and parses out the first image in all sizes.
{% comment %}
This snippet takes HTML content from the Shopify editor and parses out the first image in all sizes.
Usage:
{% include 'get-first-image' with page.content %}
Return:
{{ FirstImagePico }}
{{ FirstImageIcon }}
{{ FirstImageThumb }}