Skip to content

Instantly share code, notes, and snippets.

View ppcano's full-sized avatar

Pepe Cano ppcano

View GitHub Profile
@Kartones
Kartones / postgres-cheatsheet.md
Last active November 15, 2024 21:14
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@slindberg
slindberg / README.md
Last active August 29, 2015 13:56
Model 'Fragments' in Ember Data
@arkadiyk
arkadiyk / aprray-filter-vs-computed-filter.md
Last active January 2, 2016 13:29
Interesting observation on difference between `array.filterBy` and `Ember.Computed.filterBy`

Apparently array.filterBy creates a new array based on the filtered content, whether Ember.Computed.filterBy reuses the same array.

This difference can be very important when you display a filtered list with {{each}} helper.

For eaxample, if you define the propery like this:

  filteredArray: function(){
    return this.get('content').filterBy('isDone', false);
  }.property('[email protected]')
(function (global) {
"use strict";
function empty(obj) {
var key;
for (key in obj) if (obj.hasOwnProperty(key)) return false;
return true;
}
var Ember = global.Ember,
@machty
machty / router-facelift-guide.md
Last active July 10, 2024 15:14
Guide to the Router Facelift

Ember Router Async Facelift

The Ember router is getting number of enhancements that will greatly enhance its power, reliability, predictability, and ability to handle asynchronous loading logic (so many abilities), particularly when used in conjunction with promises, though the API is friendly enough that a deep understanding of promises is not required for the simpler use cases.

anonymous
anonymous / gist:5378663
Created April 13, 2013 14:38
Anonymous Open Letter to the Ember.js Core Team

Anonymous Open Letter to the Ember.js Core Team

Disclaimer: I've been using Ember for quite some time now, about when 0.9.8 was released, which means I'm not a random hater using backbone or angular.

I do believe Ember is the best thing out there, but I want to point out some things which really piss me off.

Most of them are based on the fact that the core team doesn't seem to be organized and doesn't prioritize the right things. Here are couple of examples:

  • Ember Extension was a great idea, there were couple of videos released with it, everyone loved it, but the project has been dead for 2 months now. There are 11 open issues, many of them for a few months without any response from the core team.
@leepfrog
leepfrog / gist:5352059
Created April 10, 2013 05:31
Current WIP of IndexedDB Adapter
# Aliases
get = Ember.get
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB
# Indexed DB Adapter
App.IDBAdapter = DS.Adapter.extend
# Name of the database store we're going to use
dbName: 'myCoolDB'
# Version of the schema
@ppcano
ppcano / store_adaper_test.js
Last active December 10, 2015 15:29
record.loadedData in Run.once async problem
asyncTest("Records loaded multiple times and retrieved in recordArray are ready to send state events", function() {
adapter.findQuery = function(store, type, query, recordArray) {
var self = this;
setTimeout(function() {
Ember.run(function() {
// use different recordArray based on the call
var recordArray = (!!people2) ? people2 : people;
@leepfrog
leepfrog / gist:4284160
Created December 14, 2012 09:48
#EmberJS - Adding support for CSRF from Rails to your Adapter
App.Adapter = DS.RESTAdapter.extend
# Add CSRF Token from Rails to non-get requests
ajax: (url, type, hash) ->
if hash.data and type isnt "GET"
hash.data['authenticity_token'] = jQuery("meta[name='csrf-token']").attr("content")
@_super(url,type,hash)
@ppcano
ppcano / Article.md
Created December 11, 2012 10:29 — forked from Warry/Article.md
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows: