Skip to content

Instantly share code, notes, and snippets.

View alenm's full-sized avatar

Alen Mujkic alenm

View GitHub Profile
@njvitto
njvitto / deploy.rake
Created April 11, 2010 16:56 — forked from RSpace/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@robhurring
robhurring / app.rb
Created November 23, 2010 17:03
ActiveRecord query caching with Sinatra
# ActiveRecord refuses to enable query caching _unless_ you have the following setup
# 1) you _must_ use ActiveRecord::Base.configurations to store your auth details
# 2) you _must_ include the ActiveRecord::QueryCache middleware
# 3) you _must_ inherit from the _Base_ connection -- abstract models don't
# cache without a bit of hacking, it only query caches anything from AR::Base
require 'sinatra'
require 'active_record'
# query caching requires that you use AR::Base.configurations to store your
@metaskills
metaskills / gist:977846
Created May 18, 2011 01:52
If your not returning ruby primitives and other objects that know how to respond to #as_json from #as_jons - Your doing it wrong.
class User < ActiveRecord::Base
has_many :columns
def as_json(options={})
attributes.slice(:id, :email, :uuid).merge(:columns => columns)
end
end
class Column < ActiveRecord::Base
belongs_to :user
has_many :boxes
@dkubb
dkubb / .gitignore
Created December 5, 2011 18:26
Test Feedzirra w/VCR using an HTTP proxy
cassettes
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@jpo
jpo / progress_indicators.rb
Created July 31, 2012 02:23
Ruby CLI Progress Indicators
# Terminal Progress Indicators. Four examples are included: percentage,
# spinner, progress bar, and combined. This script has been tested on
# Mac OS X 10.8 with Ruby 1.8.7, 1.9.1, 1.9.2, and 1.9.3
class Spinner
include Enumerable
def each
loop do
yield '|'
yield '/'
//
// OLD AND BUSTED
//
if ([self.zoomingDelegate respondsToSelector:@selector(zoomingWindow:didZoomOutViewController:)] == YES)
{
// Do something important.
}
//

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@poteto
poteto / search.js
Last active January 24, 2017 19:52
simple text search computed property macro
// utils/computed/search.js
import Ember from 'ember';
var computed = Ember.computed;
export default function search(dependentKey, propertyKey, searchQueryKey, returnEmptyArray) {
returnEmptyArray = (typeof returnEmptyArray === "undefined") ? false : returnEmptyArray;
return computed("" + dependentKey + ".@each." + propertyKey, searchQueryKey, function() {
var items, query;
if (returnEmptyArray && !this.get(searchQueryKey)) {
return Ember.A([]);
@stevedomin
stevedomin / create_post.exs
Last active July 12, 2023 01:32
Using UUIDs as primary key with Ecto
defmodule MyBlog.Repo.Migrations.CreatePost do
use Ecto.Migration
def change do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :body, :string
add :word_count, :integer
timestamps