Skip to content

Instantly share code, notes, and snippets.

View pixshatterer's full-sized avatar

German Galvis pixshatterer

View GitHub Profile

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
@pixshatterer
pixshatterer / slim-redux.js
Created September 16, 2016 13:32 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@pixshatterer
pixshatterer / protips.js
Last active September 8, 2015 15:34 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@pixshatterer
pixshatterer / riddle.js
Created August 6, 2014 18:30
EXAMINE THIS
parseMolecule=function x(f,r){
for(r=1;r;)
r=0,f=f.replace(/\W(([A-Z][a-z]*\d*)*)[)\]}](\d*)/g,function(m,g,_,c){
_='';for(r in m=x(g))_+=r+m[r]*(c||1);return _
})
for(r={},m=/(\w[a-z]*)(\d*)/g;a=m.exec(f);r[c]+=+a[2]||1)
r[c=a[1]]|=0
return r
}
@pixshatterer
pixshatterer / mq.css
Created October 3, 2012 19:11 — forked from chriscoyier/mq.css
Media query riddle
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),