// add all the elements inside modal which you want to make focusable | |
const focusableElements = | |
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; | |
const modal = document.querySelector('#exampleModal'); // select the modal by it's id | |
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal | |
const focusableContent = modal.querySelectorAll(focusableElements); | |
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal | |
import React from 'react'; | |
export class StateDispatcher extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = props.state || {}; | |
this._dispatch = this.dispatch.bind(this); | |
} | |
dispatch(action) { |
# the instructions from here: https://stackoverflow.com/questions/3704919/installing-rmagick-on-ubuntu/31089915#31089915 | |
# worked, but only after I added in line 8 | |
sudo apt-get purge graphicsmagick graphicsmagick-dbg imagemagick-common imagemagick imagemagick-6.q16 libmagickcore-6-headers libmagickwand-dev graphicsmagick-libmagick-dev-compat | |
sudo apt-get autoremove | |
sudo apt-get install imagemagick libmagickwand-dev | |
sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config | |
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig | |
gem install rmagick |
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
NOTE: This is outdated. Check the comments below for more up-to-date forks of this gist.
Improved YARD CHEATSHEET http://yardoc.org
forked from https://gist.github.com/chetan/1827484 which is from early 2012 and contains outdated information.
{ | |
:ar => "Argentina", | |
:au => "Australia", | |
:au_act => "Australia - Capital Territory", | |
:au_nsw => "Australia - New South Wales", | |
:au_nt => "Australia - Northern Territory", | |
:au_qld => "Australia - Queensland", | |
:au_qld_brisbane => "Australia - Queensland, Brisbane", | |
:au_qld_cairns => "Australia - Queensland, Cairns", | |
:au_sa => "Australia - South Australia", |
I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.
In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.
While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.
Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio
The MIT License (MIT) | |
Copyright (c) 2014 Tomas Kafka | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |