Skip to content

Instantly share code, notes, and snippets.

View gshutler's full-sized avatar
📅
👨‍💻

Garry Shutler gshutler

📅
👨‍💻
View GitHub Profile
@gshutler
gshutler / the_key.rb
Last active August 29, 2015 13:57
The key, the secret
let(:key) { "I've got the key" }
let(:secret) { "I've got the secret" }
let(:refresh_token) { "I've got the key to another way" }
let(:token) { "Ah ah ah ah ah ah, aha aha" }
let(:iv) { "Ah ah ah ah ah" }
config.appender(Hatchet::LoggerAppender.new) do |appender|
appender.file = 'log/application.log'
# Could delegate to:
# self.logger = Logger.new('log/application.log')
end
config.appender(Hatchet::LoggerAppender.new) do |appender|
appender.device = Logger.new('log/application.log')
end
config.hatchet.configure do |hatchet|
require 'rbconfig'
hatchet.backtrace_filters Bundler.bundle_path.to_s => '[BUNDLER]',
Bundler.bin_path.to_s => '[BUNDLER]',
Rails.root.to_s => '[RAILS_ROOT]',
RbConfig::CONFIG['sitelibdir'] => '[SITELIBDIR]',
RbConfig::CONFIG['rubylibdir'] => '[RUBYLIBDIR]',
RbConfig::CONFIG['libdir'] => '[LIBDIR]',
RbConfig::CONFIG['sitedir'] => '[SITEDIR]'
@gshutler
gshutler / Example.java
Last active August 29, 2015 14:09
Example of retrieving a day's events in Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public final class Example {
public static void main(String[] args) throws IOException {
String url = "https://api.onediary.com/v1/events?from=2014-12-17&to=2014-12-18&tzid=Europe/Lisbon";
String token = "REPLACE_WITH_YOUR_TOKEN";
public static class ServiceBusExtensions
{
public static bool HasSubscribersFor<T>(this IServiceBus serviceBus, T message)
{
IEnumerable<Action<object>> enumerable = serviceBus.OutboundPipeline.Enumerate(message);
return enumerable.Any();
}
}
<html>
<head></head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("button").click(function() {
$("form").append(
$("<input />")
.attr("type", "hidden")
$(".container").each(function() {
var that = $(this);
that.find("img").load(function() {
that.append("<span>" + $(this).height() + "</span>");
});
});
var elementsToHash = function(elements) {
var hash = {};
elements.each(function() {
var element = $(this);
hash[element.attr("name")] = element.val();
});
return hash;
}