Skip to content

Instantly share code, notes, and snippets.

View RudolfHattenkofer's full-sized avatar

Rudolf Hattenkofer RudolfHattenkofer

  • Munich, Germany
View GitHub Profile
// Register our actions here
actions_setup = function( $el, query_children ) {
// Initialize our apply_to_selector function
var apply = apply_to_selector( $el, query_children );
// The action to insert the links
apply( '.links-insert', function( $node ) {
// Add the event, don't forget to use jQuery.offon
// to avoid duplicate events!
$node.offon( 'click.links-insert', function() {
@RudolfHattenkofer
RudolfHattenkofer / rss.php
Last active December 26, 2015 18:39
RSS-Feed für TUMonline Seiten. Für DS vorkonfiguriert.
<?php
// Feed URL und Name der Überschrift hier eingeben:
$feed_url = 'http://www7.in.tum.de/um/courses/ds/ws1314/';
$config = array(
'name' => 'Vorlesung DS WS 13/14',
'desc' => 'RSS-Feed zur Vorlesung',
'url' => $feed_url,
);
@RudolfHattenkofer
RudolfHattenkofer / rss.php
Last active December 26, 2015 18:39
RSS-Feed für TUMonline Seiten. Für ERA vorkonfiguriert.
<?php
// Feed URL und Name der Überschrift hier eingeben:
$feed_url = 'http://www.lrr.in.tum.de/public/VorlesungERAWS13';
$headline = 'Aktuelles';
// Feed-interne Einstellungen
$config = array(
'name' => 'Vorlesung ERA WS 13/14',
'desc' => 'RSS-Feed zur Vorlesung',
'url' => 'http://www.lrr.in.tum.de/public/VorlesungERAWS13',
@RudolfHattenkofer
RudolfHattenkofer / word_generator.rb
Created October 24, 2013 16:33
Generate a never ending list of words and save them in a list to avoid duplicates. More memory intensive.
# Initialize variables
alphabet = 1
word = 1
direction = 'down'
ignore = false
chars = []
all_words = []
# 0..20 is just a soft limit so the machine doesn't crash. Switch the hashtag
# in front of the following two lines for endless mode:
@RudolfHattenkofer
RudolfHattenkofer / word_generator.rb
Created October 24, 2013 16:28
Generate a never ending list of words.
# Initialize variables
alphabet = 1
word = 1
direction = 'down'
ignore = false
chars = []
# 0..20 is just a soft limit so the machine doesn't crash. Switch the hashtag
# in front of the following two lines for endless mode:
@RudolfHattenkofer
RudolfHattenkofer / action.html.erb
Created October 7, 2013 08:07
Display Resourceable errors
<% if @category.errors.any? %>
<div class="alert alert-block alert-error">
<h4><%= pluralize( @category.errors.count, 'error' ) %> prohibited this Category from being saved:</h4>
<ul>
<% @category.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
class Category
# GET /categories/new
def new
@category = Category.new
end
# GET /categories/1/edit
def edit
end
@RudolfHattenkofer
RudolfHattenkofer / resourceable.rb
Created October 7, 2013 07:52
Resourceable module for Rails ActiveRecord-Model controllers
module Resourceable
protected
def create_response( saved, resource, format, name, url = false )
if saved
format.html { redirect_to url ? url : resource, notice: name + ' was successfully created.' }
format.json { render action: 'show', status: :created, location: resource }
else
render_error( format, 'new' )
end
@RudolfHattenkofer
RudolfHattenkofer / current_url.rb
Created September 29, 2013 14:41
URL of the current page.
request.original_url
# In a form:
<%= form_tag( request.original_url ) do %>
<% end %>
@RudolfHattenkofer
RudolfHattenkofer / responsive.css
Created September 28, 2013 17:07
The normal responsive query, not sure why I can't remember it...
@media only screen and (min-width:768px) {
/* Styles */
}