Skip to content

Instantly share code, notes, and snippets.

View netzpirat's full-sized avatar

Michael Kessler netzpirat

View GitHub Profile
@netzpirat
netzpirat / form_basic.coffee
Created June 23, 2011 23:15
Model based form validation and row editor for Ext JS 4
# The form adds model based validation to the form
# and it updates the 'reset' and 'save' buttons from the owning
# form panel according to the dirty and validity status of the form.
#
# @author Michael Kessler
#
Ext.define 'Ext.ux.form.Basic',
extend: 'Ext.form.Basic'
config:
@netzpirat
netzpirat / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@netzpirat
netzpirat / resize.rb
Created March 18, 2010 20:46
A simple ruby rmagick resize script
#!/usr/bin/env ruby
# A simple ruby rmagick resize script.
#
# Example: ./resize.rb /user/joe/mypics 400 533
#
# Searches /user/joe/mypics recursively for all files ending with 'jpg'; the search is case
# insensitive. The found image will be proprtinaly scaled to a max width of 400 pixesl and
# a max height of 533 pixels. The resized image will be written to a new file with the extension 'preview.jpg'
#
@netzpirat
netzpirat / deploy.rb
Created May 14, 2009 10:06
Capistrano recipe to sync rails database and files within a multi stage environment
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
@netzpirat
netzpirat / env.rb
Created November 18, 2009 19:22
Cucumber ActiveResource faking
require 'fakeweb'
require 'fake_resource'
ActiveResource::Base.send :include, ActiveResource::FakeResource
Before do
FakeWeb.allow_net_connect = false
end
After do |scenario|
ActiveResource::FakeResource.clean
@netzpirat
netzpirat / mass_mailer.rb
Created March 18, 2010 23:56
Send email to all email addresses from a MySQL table
#!/usr/bin/env ruby
#
# Send mass emails to the users of my small private email server
# with TLS.
#
# Queries the MySQL database for my vhost users and sends an
# email with ActionMailer to them.
#
# Install dependencies with `gem install mysql actionmailer`
#
angular.module('project', ['projectServices'])
.config ($routeProvider) ->
$routeProvider
.when('/login',
templateUrl: 'partials/login.html',
controller: LoginCtrl)
.when('/assignments',
templateUrl: 'partials/assignments.html',
controller: AssignmentListCtrl)
.otherwise(redirectTo: '/login')
@netzpirat
netzpirat / fs_change.rb
Created December 29, 2011 09:37
Listen to file changes with Guard
require 'guard/listener'
listener = Guard::Listener.select_and_init({
watchdir: '/tmp',
watch_all_modifications: true
})
listener.on_change do |files|
puts "File change: #{ files.join(',') }"
end
@netzpirat
netzpirat / gist:1497369
Created December 19, 2011 14:03
Create promotion code per collection for Shopify
# Save your promotion codes in code.csv
require 'capybara'
require 'csv'
session = Capybara::Session.new(:selenium)
session.visit 'https://YOURSHOP.myshopify.com/admin/auth/login'
session.fill_in 'login', :with => 'YOURLOGIN'
session.fill_in 'password', :with => 'YOURPASSWORD'
session.click_button 'Sign In'
@netzpirat
netzpirat / validation.js
Created September 12, 2011 22:25 — forked from mikeolivieri/validation.js
Backbone Model Validation
_.extend(Backbone.Model.prototype, Backbone.Events, {
errors: [],
validate: function (attrs) {
//reset
this.errors = [];
var model = this;