Skip to content

Instantly share code, notes, and snippets.

View kylefox's full-sized avatar
🥊
programming

Kyle Fox kylefox

🥊
programming
View GitHub Profile
jQuery.fn.shake = function(intShakes, intDistance, intDuration) {
this.each(function() {
$(this).css({position:"relative"});
for (var x=1; x<=intShakes; x++) {
$(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)), "swing")
.animate({left:intDistance}, ((intDuration/intShakes)/2), "swing")
.animate({left:0}, (((intDuration/intShakes)/4)), "swing");
}
});
return this;
$spacing-scale: (
0,
0.3125rem,
0.625rem,
0.9375rem,
1.25rem,
1.5625rem,
3.125rem,
4.688rem,
6.25rem,
$(document).on('click', '.modal button.yes', function() {
console.log('You clicked yes!');
$.modal.close();
});
$(document).on('click', '.modal button.no', function() {
console.log('You clicked no!');
$.modal.close();
});
@kylefox
kylefox / gulpfile.js
Created January 15, 2016 17:28
I moved bower dependencies in my Ionic app from `./www/lib` to `./bower_modules` in order to slim down the resulting "www" package. Here are the gulp settings/tasks I use to compile/concatenate everything into `./www/js/libs.js`
var paths = {
// Manually specify the bower resources we actually need.
// This way our index simply has: <script src="js/libs.js"></script>
bower: {
scripts: [
"./bower_modules/ionic/js/ionic.bundle.js",
"./bower_modules/angular-resource/angular-resource.js",
],
fonts: [
"./bower_modules/ionic/fonts/**.*",

A proposal for a framework-agnostic way of building Javascript configuration objects based on different environments.

This proposal focuses on the conventions that will allow for the creation of a plain old JavaScript object. For example:

var environment = new Environment("development");
environment.name; // "development"
environment.config.API_ROOT; // "http://localhost:3000/"
<!-- in head -->
<style>
body.clicked {
background: #7f1d26;
}
.smiley {
position: fixed;
top: 1rem;
right: 1rem;
width: 1rem;
from rest_framework_jwt.serializers import JSONWebTokenSerializer
from rest_framework.serializers import ValidationError
from rest_framework.authtoken.serializers import AuthTokenSerializer
from .models import LoginLockout
class LockableTokenSerializer(object):
"""
In addition to the normal token auth validation,
@kylefox
kylefox / external.vanilla-forEach.js
Last active February 6, 2016 16:33 — forked from bastianallgeier/external.js
For those "external links should open in new tabs" clients…
// Array.forEach potentially faster than loop
// http://jsperf.com/testing-foreach-vs-for-loop
var links = document.querySelectorAll('a[href*="//' + window.location.host +'"]');
[].slice.call(links).forEach(function(a) {
a.target = '_blank';
});
@kylefox
kylefox / ubuntu_setup.sh
Created September 24, 2011 17:16
Automated setup for a Ubuntu server with git, ruby, rvm, nginx.
#!/usr/bin/env bash
# ----------------------------------------------------
#
# Automated setup for a Ubuntu server with git, ruby, rvm, nginx.
# (Used at Carbonmade)
#
# Usage:
# - SCP this file to your server: scp ubuntu_setup.sh you@server:~
# - Make it executable: chmod +x ubuntu_setup.sh
# - Run it: bash ubuntu_setup.sh
@kylefox
kylefox / 3-completed-orders.html
Last active December 16, 2015 03:09
How to integrate Granify onto any website using the JavaScript API. (3 of 3)
<!--
Insert this snippet on the page shown to users after an order has been completed.
Place this code immediately before the closing </body> tag to ensure it's run last.
-->
<script type="text/javascript">
Granify.trackOrder({
"created_at": "2013-01-30 14:31:54",
"currency": "USD",
"total_line_items_price": 150.00,
"total_discounts": 25.00,