Skip to content

Instantly share code, notes, and snippets.

View alliejones's full-sized avatar

Allie Jones alliejones

View GitHub Profile
@alliejones
alliejones / inline-block.css
Last active December 11, 2015 13:38
Cross-browser inline block (IE7+)
li {
display: inline-block;
vertical-align: top;
zoom: 1;
*display: inline;
}
@alliejones
alliejones / recursion.js
Last active January 21, 2018 22:19
Toy recursion problems
/*
* Warm up: using no loops (for, while, etc.), and no global variables, write a function that returns the sum of a list:
* sum([1, 2, 3, 4, 5]) -> 15
* sum([]) -> 0
*/
function sum (list) {
if (list.length == 0) return 0
else {
var head = list.shift();
return head + sum(list);
@alliejones
alliejones / anonfunctions.php
Last active December 15, 2015 14:09
Anonymous functions in PHP 5.3
<?php
$my_array = array(1, 2, 3);
$new_array = array_map(function($num) { return $num * 2; }, $my_array); // $new_array: [2, 4, 6]
// Why the arguments are in the opposite order, I have no idea ...
$new_array2 = array_filter($my_array, function($num) { return $num % 2 == 0; }); // $new_array2: [2]
@alliejones
alliejones / Gruntfile.js
Last active December 15, 2015 18:49
Gruntfile template. Includes lint, concat, uglify and watch as well as growl notifications of errors and warnings (requires npm growl package to be installed).
module.exports = function(grunt) {
var defaultTasks = ['jshint', 'concat', 'uglify']; // used for watch as well
var files = [ /* your source files */ ];
grunt.initConfig({
jshint: {
all: files.concat(['Gruntfile.js'])
},

Keybase proof

I hereby claim:

  • I am alliejones on github.
  • I am alliejones (https://keybase.io/alliejones) on keybase.
  • I have a public key whose fingerprint is 8637 1116 9D22 31D4 0498 5D18 6C7F 21C2 A919 61D9

To claim this, I am signing this object:

@alliejones
alliejones / gist:022b9d3cc422bdc8bf36
Created January 25, 2015 21:16
AYAB avrdude.conf for OSX
# $Id: avrdude.conf.in 991 2011-08-26 20:50:32Z joerg_wunsch $ -*- text -*-
#
# AVRDUDE Configuration File
#
# This file contains configuration data used by AVRDUDE which describes
# the programming hardware pinouts and also provides part definitions.
# AVRDUDE's "-C" command line option specifies the location of the
# configuration file. The "-c" option names the programmer configuration
# which must match one of the entry's "id" parameter. The "-p" option
# identifies which part AVRDUDE is going to be programming and must match
import sys
import csv
import os
rows = []
input_file = sys.argv[1]
rows.append([ 'Date', 'Payee', 'Category', 'Memo', 'Outflow', 'Inflow' ])
with open(input_file, 'rb') as f:
@alliejones
alliejones / single.php
Last active August 29, 2015 14:25 — forked from lunacodes/single.php
Single Posts Template I'm trying to modify to exclude sidebar based on post-category - refer to the code in section Line 3
<?php get_header(); ?>
<div class="row">
<div class="col-sm-12">
<?php if (!$category_is_press): ?>
<?php get_sidebar(); ?>
<?php endif ?>
</div>
</div>
@alliejones
alliejones / file.md
Created August 14, 2017 20:37
How to extend the web toolkit
  • use classes for everything, seriously everything

    • some html elements will have a ton of classes and that’s okay—-the fewer things a single CSS class does the easier it is to understand
    • in the vast majority of cases you shouldn't write your CSS rules using html tags (like a or li), add a class instead so your rules aren't as tightly coupled to markup (what if you need to swap out that a for a span later? hopefully you shouldn't have to change your CSS)
  • keep the specificity of your CSS rules as low as possible: a single class is the ideal

    • Sass makes it really easy to nest rules, but resist the urge; think about namespacing your classes instead
      It is easy and tempting to match your rule nesting to your DOM nesting:
{
"assetVersion": "1976b95f7620d99923d9",
"locale": "en-US",
"view-id-1": {
"name": "web-toolkit-v2/modules/buttons/react/WtButton",
"data": {
"children": "I am a button"
}
},
"view-id-2": {