Skip to content

Instantly share code, notes, and snippets.

View roamingthings's full-sized avatar

Alexander Sparkowsky roamingthings

View GitHub Profile
//
// NSDate+InternetDateTime.swift
//
// Objective-C Version created by Michael Waterfall on 07/10/2010.
// Copyright 2010 Michael Waterfall. All rights reserved.
//
// Swift Version created by Alexander Sparkowsky on 19/07/14.
// Copyright (c) 2014 Alexander Sparkowsky. All rights reserved.
//
@roamingthings
roamingthings / .gitignore_java
Created January 3, 2014 10:59
Basic .gitignore files for various kinds of projects
#
# Basic .gitignore file for Java projects using eclise, IntelliJ and maven
#
# Eclipse
.classpath
.project
.settings/
# Intellij
@roamingthings
roamingthings / MySingeltonClass.h
Created December 29, 2013 09:56
Objective-C Singleton Pattern
#import <Foundation/Foundation.h>
@interface MySingeltonClass : NSObject
+ (instancetype)sharedInstance;
@end
@roamingthings
roamingthings / TreeModel.rb
Created December 15, 2013 09:41
Build a tree structure in an ActiveRecord model
class TreeModel < ActiveRecord::Base
has_many :children, class_name: "TreeModel",
foreign_key: "parent_id"
belongs_to :parent, class_name: "TreeModel"
end
@roamingthings
roamingthings / RandomToken.java
Last active December 31, 2015 00:29
Generate a random alphanumerical String like a password or token.
package de.roamingthings.crypto;
public class RandomToken {
private static final SecureRandom rand = new SecureRandom();
public static String generateRandomToken(int bits) {
return new BigInteger(bits, rand).toString(32);
}
public static main(String[] args) {
@roamingthings
roamingthings / radio_list_seam_bootstrap.xhtml
Created December 10, 2013 08:32
Vertical list of radio buttons with bootstrap design using JBoss Seam 2 and JSTL
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:t="http://myfaces.apache.org/tomahawk"
contentType="text/html">
<t:selectOneRadio id="mySelect" value="#{target.value}" layout="spread" required="true">
<s:selectItems
@roamingthings
roamingthings / richfaces_jquery_update.xhtml
Created December 10, 2013 08:29
Use a current jQuerry parallel to Richfaces 3.3 which brings its own (old) jQuery implementation which cannot be turned off even when not using any Richfaces component in a view.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view>
<head>
<ui:remove>********** Richfaces 3.3 / jQuery Voodoo Spell **********</ui:remove>
<script>
@roamingthings
roamingthings / no_cache_and_search_headers.html
Created December 10, 2013 08:22
HTML Headers to turn of caching and search engines
<html>
<head>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
</head>
<body>