This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyNewAwesomeClass | |
DEPENDENCIES = { | |
logger: -> { Rails.logger }, | |
logic: -> { MyBusinessLogic.new }, | |
service: -> { MyServiceClass } | |
} | |
attr_accessor :dependencies | |
def initialize(deps={}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_with_defaults(options={}) | |
defaults = { | |
foo: 1, | |
bar: 2, | |
baz: 'some_string' | |
} | |
arguments = defaults.merge(options) | |
puts arguments.inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder