Skip to content

Instantly share code, notes, and snippets.

View thomasboyt's full-sized avatar

Thomas Boyt thomasboyt

View GitHub Profile
Sequelize = require("sequelize")
sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'sqlite',
})
Post = sequelize.define('Post', {
title: Sequelize.STRING
date: Sequelize.DATE
body: Sequelize.TEXT
@thomasboyt
thomasboyt / concat.js
Last active March 3, 2022 10:13
grunt post
module.exports = {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
}
macro feature {
case $featureName:ident $block => {
if (Ember.FEATURES.isEnabled("$featureName"))
$block
}
}
feature foo {
var bar = {
"ex": "example"
$ gem install ember-dev-0.1.gem
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: ember-dev requires rake-pipeline (~> 0.8.0)
$ ls `rvm gemdir`/gems
aws-sdk-1.16.1 grit-2.5.0 mime-types-1.25 rake-0.9.6 rb-kqueue-0.2.0
colored-1.2 handlebars-source-1.0.12 multi_json-1.7.9 rake-pipeline-0.7.0 thor-0.18.1
diff-lcs-1.2.4 json-1.8.0 nokogiri-1.5.10 rake-pipeline-web-filters-0.7.0 uglifier-2.2.1
execjs-2.0.1 kicker-2.6.1 posix-spawn-0.3.6 rb-fsevent-0.9.3 uuidtools-2.1.4
ffi-1.9.0 listen-1.3.0 rack-1.5.2 rb-inotify-0.9.1
@thomasboyt
thomasboyt / metadata.md
Created September 13, 2013 00:12
Handling Metadata

Along with the records returned from your store, you'll likely need to handle some kind of metadata. Metadata is data that goes along with a specific model or type instead of a record.

Pagination is a common example of using metadata. Imagine a blog with far more posts than you can display at once. You might query it like so:

this.get("store").findQuery("post", {
  limit: 10,
  offset: 0
});
(venv)➜ thestyleup git:(dev-refactor) ✗ pip install -r requirements.txt
Downloading/unpacking BeautifulSoup==3.2.1 (from -r requirements.txt (line 1))
Downloading BeautifulSoup-3.2.1.tar.gz
Running setup.py egg_info for package BeautifulSoup
Downloading/unpacking Django==1.5.2 (from -r requirements.txt (line 2))
Downloading Django-1.5.2.tar.gz (8.0MB): 8.0MB downloaded
Running setup.py egg_info for package Django
warning: no previously-included files matching '__pycache__' found under directory '*'
concat: {
dev: {
files: {
'core/built/scripts/vendor.js': [
'core/shared/vendor/jquery/jquery.js',
'core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js',
'core/client/assets/lib/jquery-utils.js',
'core/client/assets/lib/uploader.js',
'core/shared/vendor/underscore.js',
'core/shared/vendor/backbone/backbone.js',
@thomasboyt
thomasboyt / angular.js
Last active December 27, 2015 01:29
backbone v. ember v. angular: actions
// controller.js
angular.controller('controller', function($scope, $http) {
$scope.submit = function() {
// set $scope.object
$http.put('/api/objects', $scope.object);
};
});
// view.html
<button ng-click="submit">Submit</button>
@thomasboyt
thomasboyt / base_view.js
Last active December 27, 2015 01:29
simplifying bindAll
var ActionsView = Backbone.View.extend({
delegateEvents: function(events) {
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
if (!(events || (events = _.result(this, 'events')))) return this;
this.undelegateEvents();
for (var key in events) {
var method = events[key];
// !! This is the modified bit !!
if (!_.isFunction(method)) {
@thomasboyt
thomasboyt / observe.js
Created November 13, 2013 16:47
recursive object.observe sadness
var foo = {};
function createObserve(obj) {
Object.observe(obj, function(changeset) {
changeset.forEach(function(change) {
if (typeof change.object[change.name] === "object") {
createObserve(change.object[change.name]);
}
console.log(change.name);
});