Skip to content

Instantly share code, notes, and snippets.

View wnstn's full-sized avatar

Winston Hearn wnstn

View GitHub Profile
@wnstn
wnstn / day-1.js
Last active December 3, 2015 22:12
Advent Answers
function stepThrough() {
var instructions = document.getElementsByTagName('pre')[0].textContent;
var regexp = /[()]/g;
var split = instructions.match(regexp);
var floor = 1;
var i = 0;
do {
floor = split[i] === "(" ? floor + 1 : floor - 1;
i++;
} while (floor > 0)
@wnstn
wnstn / transitionqueue.js
Created June 30, 2015 18:29
queue transitions for synchronous firing
// http://davidwalsh.name/vendor-prefix
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
return {
@wnstn
wnstn / newTest.js
Last active August 29, 2015 14:16
LocalStorage Testing
// OLD
function canUseLocalStorage() {
return typeof localStorage === 'object' && localStorage.setItem;
};
// NEW
function canUseLocalStorage() {
var ls = "vox";
@wnstn
wnstn / shipping.js
Created October 2, 2013 23:07
FoxyCart flat rate shipping based on product count
<script type="text/javascript" charset="utf-8">
FC.checkout.config.customShipping = {
onLoad: true, // Set to false if you don't want shipping calculated when the checkout loads
onLocationChange: true // Set to true if your shipping logic relies on updating whenever the shipping location for the order changes
};
function calculateShipping() {
var shippingCost = 0;
/* BEGIN CUSTOM SHIPPING LOGIC */
@wnstn
wnstn / beautiful.scss
Last active December 19, 2015 06:29
I love you Sass
.feed-section-header {
margin: 0;
font-size: 1.1em;
$groups: community $community \70, teams $teams \72, college $college \71, for-you $gray \6b;
@each $group in $groups {
&.#{nth($group, 1)} {
color: #{nth($group, 2)};
.feed-icon {
/etc /usr/local/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log [ruby-1.9.3-p125]
FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=14442496, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce the request size (currently 14442496 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
The PostgreSQL documentation contains more information about shared memory configuration.
@wnstn
wnstn / router.php
Created April 16, 2013 14:27
Wordpress router.php, for using the built in PHP server with WP sites.
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
{
header('location: '.rtrim($path,'/').'/');
@wnstn
wnstn / feed.coffee
Last active December 11, 2015 02:28
PubSub method using coffeescript classes and jquery's callbacks
class @Feed
constructor: (@func)->
@callbacks = $.Callbacks()
init: ->
@subscribe( @func )
subscribe: =>
@callbacks.add( @func )
publish: (args)=>
if args.length < 1
@callbacks.fire @func
@wnstn
wnstn / csextra.module
Last active December 10, 2015 22:38
Module temp
<?php
function csextra_block($op = 'list', $delta = 0, $edit = array())
{
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Send To a Friend Form');
$blocks[1]['info'] = t('Sign Up for Our Newsletter');
$blocks[2]['info'] = t('Event Ticket Button`');
return $blocks;
NoMethodError in Manage/progress_reports#index
Showing /Users/CS_Spare/.rvm/gems/ruby-1.9.3-p125@carecom/gems/datagrid-0.6.2/app/views/datagrid/_row.html.erb where line #3 raised:
undefined method `name' for #<Patient:0x007ffbadc912a0>
Extracted source (around line #3):
1: <tr class="<%= options[:cycle] && cycle(*options[:cycle]) %>">
2: <% grid.columns.each do |column| %>
3: <td class="<%= datagrid_column_classes(grid, column) %>"><%= datagrid_format_value(grid, column, asset) %></td>