Skip to content

Instantly share code, notes, and snippets.

@peakpg
peakpg / gist:1173438
Created August 26, 2011 13:49
Watch Dox API
gem 'json', '= 1.1.3'
require 'json'
module Watchdox
class API
BASE_URL = "https://api.watchdox.com"
API_VERSION = "1.0"
attr_accessor :ssid
@peakpg
peakpg / gist:5254600
Last active December 15, 2015 11:39
How the Content API will behave in 4.0
# Case A
case_a = Cms::HtmlBlock.new(name: "Case A")
case_a.save
assert case_a.published? == true
# Case B
case_b = Cms::HtmlBlock.new(name: "Case B")
assert case_b.publish == false
assert case_b.persisted? == false
@peakpg
peakpg / gist:5249564
Last active December 15, 2015 10:59
Expectionations for working with Content Blocks
# What would you expect to happen in each of these cases? (Don't test, just what you expect should happen)
# Case A
case_a = Cms::HtmlBlock.new(name: "Case A")
case_a.save
# Is this block in draft or published mode?
# Case B
case_b = Cms::HtmlBlock.new(name: "Case B")
$(function () {
$('.countdown').click(function () {
$("#main").hide();
$("#hud").hide();
$("body").removeClass("game").addClass("gameover");
$("#gameover-container").show();
});
});
# Implementing http://beust.com/weblog/2013/02/13/coding-challenge-light-edition in Ruby
# Contract for eql? and hash as per: http://stackoverflow.com/questions/2328685/how-to-make-object-instance-a-hash-key-in-ruby
class School
attr_accessor :name, :nickname
def initialize(name, nickname)
self.name = name
self.nickname = nickname
end
@peakpg
peakpg / gist:2776664
Created May 23, 2012 17:53
Upgrade BrowserCMS Module to 3.5.x (cliffnotes version)
$ echo "rvm use 1.9.3@r3.2" > .rvmrc
$ cd .. & cd bcms_module_dir
$ bcms-upgrade module
# Update gemspec to add the following:
spec.files = Dir["{app,config,db,lib}/**/*"]
spec.files += Dir["Gemfile", "LICENSE.txt", "COPYRIGHT.txt", "GPL.txt" ]
spec.test_files += Dir["test/**/*"]
spec.test_files -= Dir['test/dummy/**/*']
spec.add_dependency("browsercms", "< 3.6.0", ">= 3.5.0")
@peakpg
peakpg / Gemfile
Created May 14, 2012 18:46 — forked from ylluminate/Gemfile
Example BrowserCMS (v3.5.0) Gemfile for Heroku
source 'https://rubygems.org'
gem 'sqlite3', :group=>:development
gem 'pg', :group=>:production
gem 'thin'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
private String encodeToMD5(String message) throws java.io.UnsupportedEncodingException, NoSuchAlgorithmException{
byte[] bytesOfMessage = message.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(bytesOfMessage);
BigInteger number = new BigInteger(1, messageDigest);
String hashtext = number.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while (hashtext.length() < 32) {
hashtext = "0" + hashtext;