Skip to content

Instantly share code, notes, and snippets.

function themeChange() {
var currentTheme = document.getElementById("theme-dropdown").value;
var theme1 = document.getElementById("theme-1").value;
var theme2 = document.getElementById("theme-2").value;
var theme3 = document.getElementById("theme-3").value;
var theme4 = document.getElementById("theme-4").value;
var docBody = document.getElementById("body");
var leftPanel = document.getElementById("left-panels");
var mainPanel = document.getElementById("main-panel");
var scrollingPanel = document.getElementById("scrolling-panel");
@alexbartlow
alexbartlow / submit_idea.rb
Last active June 14, 2016 16:09
Using a Submit-Only portal as an API Endpoint in Aha!
require 'net/http'
require 'uri'
require "base64"
require "json"
uri = URI("http://new-submit-only-portal.ideas.aha.io/ideas/new")
post_uri = URI("http://new-submit-only-portal.ideas.aha.io/ideas")
req = Net::HTTP::Get.new(uri)
res = Net::HTTP.start(uri.hostname, uri.port) {|http| http.request(req) }
class MyNewAwesomeClass
DEPENDENCIES = {
logger: -> { Rails.logger },
logic: -> { MyBusinessLogic.new },
service: -> { MyServiceClass }
}
attr_accessor :dependencies
def initialize(deps={})
The signing implementation
The SignImp class isn’t much different from all the examples we’ve written before. When I write
Servlets that involve the use of iText, I always start by writing a short standalone application with a
main() method. This way I can test the code before integrating it into a web application.
In code sample 4.11, I’ve removed the main() method for brevity.
Code sample 4.11: the SignImp class
public class SignImp {
private PrivateKey pk;
private Certificate[] chain;
public SignImp(PrivateKey pk, Certificate[] chain) {
account-plugin-aim install
account-plugin-facebook install
account-plugin-flickr install
account-plugin-google install
account-plugin-jabber install
account-plugin-salut install
account-plugin-twitter install
account-plugin-windows-live install
account-plugin-yahoo install
accountsservice install
#!/usr/bin/env ruby
specs_to_run = `git status --porcelain | grep "spec"`.each_line.map{|line| line.split(/\s+/).last}
specs_to_run.reject!{|spec| spec =~ %r{^spec/support} }
puts "running #{specs_to_run.join(',')}"
`git add spec && git stash save --keep-index`
class Message < ActiveRecord::Base
scope :last_two_weeks, -> {
where(:created_at => (2.weeks.ago..Time.now))
}
scope :for_month, (date) -> {
where(:created_at => (date.beginning_of_month..date.end_of_month))
}
def self.sum_word_count
@alexbartlow
alexbartlow / gist:5667286
Created May 29, 2013 01:03
Justin's Ruby Learning
puts "Enter your name"
name = gets
length = name.length - 1
print "Your name is "
print length
print " characters long."
# ok, so remember what we talked about with .chomp - whenever you use gets, you'll get the extra newline character on the end,
# (\n) - so chomp will remove that. That's why you have to subtract 1 to get the right length, so we can revise the code to the following
def method_with_defaults(options={})
defaults = {
foo: 1,
bar: 2,
baz: 'some_string'
}
arguments = defaults.merge(options)
puts arguments.inspect
@alexbartlow
alexbartlow / gist:5164760
Created March 14, 2013 20:08
Define_method with a block
def self.define_user_field(field_name, &block)
block ||= lambda{|x| x}
define_method("user_#{field_name}"} do |f|
if user_signed_in?
block.call(current_user.send(field_name))
else
f.text_field field_name
end
end
end