Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
// adapters/application.js
var ApplicationAdapter = DS.Adapter.extend({
init: function() {
this.hoodie = window.hoodie; // FIXME?
this._super();
},
find: function(store, type, id) {
return this.hoodie.store.find(type.typeKey, id);
@ahx
ahx / hoodie_adapter.js
Last active March 15, 2018 19:52
A ember-model adapter for hoodie.js. Hoodie: http://hood.ie ember-model: https://github.com/ebryn/ember-model
// Usage:
// HoodieAdapter.create({type: "mystuff", url: "some/url"})
// "type" is required. "url" is optional.
var hoodie,
get = Ember.get,
Promise = Ember.RSVP.Promise;
function mustImplement(message) {
var fn = function() {
@ahx
ahx / validate_session_cookie.rb
Last active December 17, 2015 19:09
Use an additional secure cookie to validate the session across HTTP/HTTPS This technique is described here: http://railscasts.com/episodes/356-dangers-of-session-hijacking?view=asciicast
@ahx
ahx / application.html.haml
Created January 31, 2013 18:35
How to add conditional classes to your html tag using HAML. This adds a ie8/i9 class when using IE and nothing when using real browsers. The whole backstory: http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ Yes, i will try Slim next time.
!!!
/[if IE 8] <html class="ie-lt10 ie8" lang="de">
/[if IE 9] <html class="lt-lt10 ie9" lang="de">
:plain
<!--[if gt IE 9]><!--><html lang="de"><!--<![endif]-->
%head
%body
:plain
@ahx
ahx / devise.de.yml
Created December 16, 2011 18:28 — forked from bitboxer/devise.de.yml
german i18n for devise
de:
errors:
messages:
expired: "ist abgelaufen, bitte fordern Sie es neu an"
not_found: "nicht gefunden"
already_confirmed: "wurde bereits aktiviert, bitte versuchen Sie sich anzumelden."
not_locked: "ist nicht gesperrt"
not_saved:
one: "Ein Fehler hat verhindert, dass %{resource} gespeichert werden konnte:"
other: "%{count} Fehler haben verhindert, dass %{resource} gespeichert werden konnte:"
@ahx
ahx / gist:1115464
Created July 30, 2011 12:13
globes oculaires - belle exemple de todos
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>globes oculaires</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript" charset="utf-8" ></script>
<script src="https://raw.github.com/paulca/eyeballs.js/refactor/eyeballs.js" type="text/javascript" charset="utf-8" ></script>
<script src="https://raw.github.com/paulca/eyeballs.js/refactor/eyeballs.jquery.js" type="text/javascript" charset="utf-8" ></script>
</head>
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
@ahx
ahx / integration_test.rb
Created November 12, 2010 16:21
gaming_test.rb
# Example of how you can to use Capybara with plain Rails' integration tests and FactoryGirl (or plain MyModel.create…)
require 'test_helper'
require 'capybara'
require 'capybara/dsl'
require 'database_cleaner'
Capybara.app = Pardy::Application
Capybara.default_driver = :rack_test
DatabaseCleaner.strategy = :truncation
@ahx
ahx / app.js
Created October 23, 2010 20:26
small demo for handlebars.js, jQuery 1.4.3 data events and require.js
/* small demo for handlebars.js, jQuery, require.js */
/*global Handlebars */
var cart = {
products: [
],
total: function() {
var sum = 0;
for(var i in this.products) {
sum += this.products[i].price;
From 3786858be2d9ea56444fc0554a289a558d8bede9 Mon Sep 17 00:00:00 2001
From: Andreas Haller <[email protected]>
Date: Fri, 8 Oct 2010 11:39:17 +0200
Subject: [PATCH] `test_timer=on rake test` to print how long each test takes to run
---
Rakefile | 7 +++++++
lib/test_timer.rb | 40 ++++++++++++++++++++++++++++++++++++++++
test/test_helper.rb | 7 +++++++
3 files changed, 54 insertions(+), 0 deletions(-)