Skip to content

Instantly share code, notes, and snippets.

@kirel
kirel / server.js
Last active August 29, 2015 13:56
Modulo Kalenderserver - /5/4?topic=Küchendienst trägt für jede i-te Kaldenderwoche für die gilt `i%5=4` einen Termin "Küchendienst" ein.
var express = require('express');
var moment = require('moment');
var ical = require('ical-generator');
var app = express();
moment.lang('de'); // make monday start of week
app.get('/', function(req, res){
res.send('Subscribe to /:modulo/:residual?topic=topic i.e. <a href="http://modulocal.herokuapp.com/5/4?topic=Küchendienst">http://modulocal.herokuapp.com/5/4?topic=Küchendienst</a>.');
});
module AngularCsrf
def self.included(klass)
klass.after_filter :set_csrf_cookie_for_ng
end
protected
def set_csrf_cookie_for_ng
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
@kirel
kirel / build_sti_subclass.rb
Last active April 25, 2017 09:54
Build correct sti subclass
# STI subclass building backported from Rails 4 to use in Rails 3.2 - see
# https://github.com/rails/rails/commit/89b5b31cc4f8407f648a2447665ef23f9024e8a5
# Usage:
# include BuildStiSubclass # in your model and be done
module BuildStiSubclass
extend ActiveSupport::Concern
included do
attr_accessible inheritance_column
end
module ClassMethods
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "daniel.kirsch@zweitag.de"
@from = "no-reply@monitor.booxoffice.de"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
%spinner
@extend [class^="icon-"]
@extend .icon-refresh
@extend .icon-spin
+transition(opacity 1s ease, width 0.7s ease, height 0.3s ease)
position: relative
top: -1px
display: inline-block
overflow: hidden
text-decoration: inherit
@kirel
kirel / angular_helper.rb
Created October 7, 2013 09:03
Angular template cache helper
module AngularHelper
# Usage:
# In your server side rendered template
# = ng_template 'path/to/partial', 'path/to/other/partial'
# and then in i.e. angular directives
# template: 'path/to/partial'
def ng_template *partial_paths
safe_join(
partial_paths.map do |partial_path|
content_tag 'script', render(partial_path), id: partial_path, type: "text/ng-template"
require 'bundler/setup'
require 'rmagick'
require 'awesome_print'
require 'benchmark'
require 'httparty'
require 'json'
IP = '192.168.1.144'
# Usage:
#
# In your controller
#
# before_filter :ser_active_navigation_item
# def set_active_navigation_item
# active_navigation_item :we, :are, :here
# # or
# active_navigation_item controller.controller_name, controller.action_name
# # or
@kirel
kirel / combined.rb
Last active December 19, 2015 12:39
class CombinedFilter
def initialize *klasses, params = {} # nicht sicher ob das funktioniert.
@klasses = klasses
@filters = @klasses.map do |klass|
klass.new(params.slice(klass.class.attributes))
end
end
def to_api_hash
@kirel
kirel / checkbox.md
Last active December 19, 2015 09:39
  • Checkbox

:trollface: