Skip to content

Instantly share code, notes, and snippets.

View alexparker's full-sized avatar
♻️
Who → Why → How → What

Alex Parker alexparker

♻️
Who → Why → How → What
View GitHub Profile
@alexparker
alexparker / typetest-hack.js
Last active October 7, 2015 10:37
Javascript exercises
var xi = 0;
var evnt = jQuery.Event('keyup');
evnt.keyCode = evnt.which = 32;
function enterWord(){
$('input#inputfield').val($('.highlight').text());
$('input#inputfield').trigger(evnt);
}
var wpm = prompt("How many words per minute would you like?");
@alexparker
alexparker / current-media-queries.scss
Created November 4, 2012 03:55
SASS Proposition for extending media queries via output buffer style functions
/*
I understand this is how it currently works.
Also there is a little "convenience" way to do it with some control structures and passing an argument to the mixin,
but the resulting code is still the same.
*/
@mixin handhelds() {
@media only screen and (max-width: 479px) { @content; }
}
@alexparker
alexparker / acts_as_paranoid-has_many_through-usage.md
Created January 6, 2013 22:17
acts_as_paranoid for has_many :through

I am using the acts_as_paranoid gem to manage soft deletion

Ah ok. I have an association that is

(in user.rb)
has_many :files, :through => :folders

and i am calling

user.files.select(...).where(...).group(...)
@alexparker
alexparker / gist:6595050
Created September 17, 2013 14:27
unicorn config
# Change paramentres below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/rails
class Thing
attr_accessor :quantity
def initialize
@quantity = 100
end
def decrement(qty)
difference = quantity - qty
quantity = difference
end
@alexparker
alexparker / 0_reuse_code.js
Created April 2, 2014 16:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alexparker
alexparker / groove-widget.md
Created April 5, 2014 00:40
Groove Utility Methods

If you are loading the GrooveWidget code inside your <body>...</body> tag like this:

    ...other body content...
    <script type='text/javascript'>
      //<![CDATA[
        (function() {var s=document.createElement('script');
          s.type='text/javascript';s.async=true;
          s.src=('https:'==document.location.protocol?'https':'http') +
          '://YOURSUBDOMAIN.groovehq.com/widgets/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ticket.js'; var q = document.getElementsByTagName('script')[0];q.parentNode.insertBefore(s, q);})();

//]]>

@alexparker
alexparker / preorders_controller.rb
Created April 5, 2014 16:16
Strange `undefined method model_url` error. Am I missing something with decent exposure? Is the namespace on the controller causing an issue?
class Api::PreordersController < ApplicationController
respond_to :json
expose :preorder, attributes: :preorder_params
def create
preorder.save
respond_with preorder # does not work
# respond_with preorder, location: api_preorder_url(preorder) # works
end
@alexparker
alexparker / debug.sh
Created April 7, 2014 06:12
Failing install of atom git-plus package
> runas@0.5.4 install /private/var/folders/lx/m3dypp4n7hgcf1dssbb31d_00000gp/T/apm-install-dir-11437-47180-2gg269/node_modules/git-plus/node_modules/pathwatcher/node_modules/runas
> node-gyp rebuild
npm http GET https://registry.npmjs.org/pathwatcher
npm http 304 https://registry.npmjs.org/pathwatcher
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/nan/0.8.0
npm http GET https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/emissary
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PAGE_TITLE</title> <!-- this will be replaced automatically -->
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">