Skip to content

Instantly share code, notes, and snippets.

View Marthyn's full-sized avatar

Marthyn Olthof Marthyn

View GitHub Profile
whitelist = ["volkskrant.nl", "nos.nl", "defacto.nl"]
whitelist.each do |url|
Onebox::Engine::WhitelistedGenericOnebox.whitelist.push url
end
# DEFAULT WHITELIST
# 23hq.com
# 500px.com
# about.com
# answers.com
valid = false
operations = []
formula = Formula.new(operations)
while !valid
operations << Operation.new(
AVAILABLE_OPERATORS["Multiplication"],
Constant.new(Float((rand(1...1000)*10))/100),
Constant.new(Float(1 + rand(1...40)).round(2))
)
formula = Formula.new(operations)
rake aborted!
Custom asset_path helper is not implemented
Extend your environment context with a custom method.
environment.context_class.class_eval do
def asset_path(path, options = {})
end
end
(in /tmp/build_f2bc2012-1427-4301-843b-6531f4975e76/app/assets/stylesheets/active_admin.css.scss)/tmp/build_f2bc2012-1427-4301-843b-6531f4975e76/vendor/bundle/ruby/2.1.0/gems/sprockets-2.10.1/lib/sprockets/context.rb:241:in `asset_path'
@Marthyn
Marthyn / gist:7103125
Created October 22, 2013 15:50
trevor text parsing stack trace JSON::ParserError in LearningSpaces#show
json (1.8.0) lib/json/common.rb:155:in `parse'
json (1.8.0) lib/json/common.rb:155:in `parse'
sir-trevor-rails (0.2.4) lib/sir-trevor/helpers/view_helper.rb:64:in `parse_sir_trevor'
sir-trevor-rails (0.2.4) lib/sir-trevor/helpers/view_helper.rb:9:in `render_sir_trevor'
app/views/learning_spaces/show.html.erb:46:in `block in _app_views_learning_spaces_show_html_erb___2846945259841152377_70125041516840'
activerecord (4.0.0) lib/active_record/relation/delegation.rb:13:in `each'
activerecord (4.0.0) lib/active_record/relation/delegation.rb:13:in `each'
app/views/learning_spaces/show.html.erb:33:in `_app_views_learning_spaces_show_html_erb___2846945259841152377_70125041516840'
actionpack (4.0.0) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.0) lib/active_support/notifications.rb:161:in `instrument'
@Marthyn
Marthyn / gist:6595364
Created September 17, 2013 14:48
Hiding elements on show
$(//selector).ready(function(element) {
setTimeout(function(){$(//selector).fadeOut()},2000);
});
@Marthyn
Marthyn / LanguageDetection.js
Created April 11, 2013 10:24
Language detection, normal browser and phonegap.
var detectLanguage = function(successCB, errorCB) {
//Phonegap browser detection
if (navigator.globalization !== null && navigator.globalization !== undefined) {
navigator.globalization.getPreferredLanguage(
function (language) { successCB(language); },
function (error) { errorCB(error); }
);
//Normal browser detection
} else {
if(window.navigator.language !== null && window.navigator.language !== undefined) {
@Marthyn
Marthyn / JqueryAjaxRequest.js
Last active December 15, 2015 04:58
Jquery Ajax Requests
var api = "yourApiUrlGoesHere";
/*
Method to do a GET request to the service
*/
var getService = function (uri, failureFunction, errorFunction, successFunction)
{
$.ajax({
cache: true,
url: api+uri,