Skip to content

Instantly share code, notes, and snippets.

@zilkey
zilkey / composer.json
Last active July 5, 2017 15:39
Bluemix Wordpress Configuration
{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:ibmjstart/wp-bluemix-sendgrid.git"
},
{
"type": "vcs",
"url": "git@github.com:ibmjstart/wp-bluemix-objectstorage.git"
},
@zilkey
zilkey / save_objects.rb
Created December 16, 2013 22:00
save or destroy multiple objects in a transaction and return false if any one of them doesn't work
def save_objects(*objects)
success = false
ActiveRecord::Base.transaction do
results = objects.map do |object|
if object && !object.marked_for_destruction?
object.save
elsif object
object.destroy
else
true
@zilkey
zilkey / .gitignore
Last active September 14, 2018 20:05
curry example - a way to do dependency injection using lambdas
Gemfile.lock
junk.*
@zilkey
zilkey / private_constant.rb
Created October 22, 2013 22:40
Ruby's private_constant example
module Foo
class Bar
end
private_constant :Bar
end
module Foo
p Bar.new # => works fine because we're scoped to Foo
@zilkey
zilkey / application layout
Created August 27, 2012 05:17 — forked from davidott/application layout
application layout
<!DOCTYPE html>
<html>
<head>
<title>Solar Sound Inc | Entertainment </title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<style type="text/css">
body {
padding-top: 60px;
@zilkey
zilkey / ember-precompile.js
Created March 10, 2012 22:30 — forked from garth/Jakefile.js
Precompile .handlebars templates with node js
var fs = require('fs');
var vm = require('vm');
var emberjs = fs.readFileSync('public/javascripts/vendor/ember-0.9.5.min.js', 'utf8');
var templatesDir = 'templates';
var destinationDir = 'public/javascripts/templates';
function compileHandlebarsTemplate(templatesDir, fileName) {
var file = templatesDir + '/' + fileName;
@zilkey
zilkey / Terminal commands
Created December 28, 2011 06:23 — forked from davidott/Terminal commands
Trying to push to git and new controller /views
Davids-MacBook-Pro:blog daviddotterweich$ git.add
-bash: git.add: command not found
Davids-MacBook-Pro:blog daviddotterweich$ git.
-bash: git.: command not found
Davids-MacBook-Pro:blog daviddotterweich$ git. add
-bash: git.: command not found
Davids-MacBook-Pro:blog daviddotterweich$ git
usage: git [--version] [--exec-path[=<path>]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=<path>] [--work-tree=<path>]
class MyClass
def self.my_method
100.times do |index|
yield 100, index + 1 if block_given?
end
end
end
class AdminController < ApplicationController
before_filter do |controller|
controller.redirect_to login_path unless logged_in?
end
end
(function($) {
$.extend($, {
updateContent : function updateContent(event, newContent) {
var $contentKeyElements = $(newContent).filter('[data-content-key]');
$contentKeyElements.each(function() {
var contentKey = $(this).attr("data-content-key");
$("[data-content-key=" + contentKey + "]").html($(this).html());
});
$(document).trigger('content-updated');