Skip to content

Instantly share code, notes, and snippets.

View zimdo's full-sized avatar

Timo Mika Gläßer zimdo

View GitHub Profile
@zimdo
zimdo / Install Node.JS
Created January 31, 2011 00:47
Install Node.JS
# very easy
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
@zimdo
zimdo / Urls one should avoid...
Created January 31, 2011 00:51
Urls one should avoid... extracted from log-file. random tests from various ip's for well-known services.
ActionController::RoutingError (No route matches "/Aktuell.html" with {:method=>:get}):
ActionController::RoutingError (No route matches "/CMS/administrator/index.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/Engels/index_uk.html" with {:method=>:get}):
ActionController::RoutingError (No route matches "/Joomla/administrator/index.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/MSOffice/cltreq.asp" with {:method=>:get}):
ActionController::RoutingError (No route matches "/Site/administrator/index.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/Site_old/administrator/index.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/WP/wp-login.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/Wordpress/wp-login.php" with {:method=>:get}):
ActionController::RoutingError (No route matches "/_vti_bin/_vti_aut/author.dll" with {:method=>:post}):
@zimdo
zimdo / WithOutAgeFieldSource.java
Created May 21, 2012 03:16
WithOutAgeFieldSource
TermQuery termQuery = new TermQuery(new Term("title", "foo"));
FieldScoreQuery scoreQuery = new FieldScoreQuery("agescore", FieldScoreQuery.Type.FLOAT);
Query query = new CustomScoreQuery(termQuery, scoreQuery);
@zimdo
zimdo / AgeFieldSource.java
Created May 21, 2012 03:18
AgeFieldSource
public class AgeFieldSource extends FieldCacheSource {
private int now;
public AgeFieldSource(String field) {
super(field);
now = (int)(System.currentTimeMillis() / 1000);
}
@Override
public boolean cachedFieldSourceEquals(FieldCacheSource other) {
return other.getClass() == MyFieldSource.class;
@zimdo
zimdo / WithAgeFieldSource.java
Created May 21, 2012 03:19
WithAgeFieldSource
TermQuery termQuery = new TermQuery(new Term("title", "foo"));
ValueSourceQuery valueQuery = new ValueSourceQuery(new AgeFieldSource("created"));
CustomScoreQuery query = new CustomScoreQuery(termQuery, valueQuery);
@zimdo
zimdo / application.rb
Created May 23, 2012 03:17
Removing ActiveRecord from Rails
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
# Auto-require default libraries and those for the current Rails environment.
Bundler.require :default, Rails.env
@zimdo
zimdo / application.rb
Created May 23, 2012 03:19
Require Rails
require 'rails'
# or
require 'active_record/railtie'
@zimdo
zimdo / instanceOfRight
Created May 23, 2012 18:09
x.isAssignable(y) vs. x instanceof y
collibri instanceof Bird
@zimdo
zimdo / isAssignableWrong
Created May 23, 2012 18:10
x.isAssignable(y) vs. x instanceof y
collibri.getClass().isAssignableTo(Bird.class)
@zimdo
zimdo / isAssignableRight
Created May 23, 2012 18:11
x.isAssignable(y) vs. x instanceof y
Bird.class.isAssignableFrom(collibri.getClass())