Skip to content

Instantly share code, notes, and snippets.

View hubertlepicki's full-sized avatar

Hubert Łępicki hubertlepicki

View GitHub Profile
#--
# Copyright (c) 2009 Hubert Lepicki <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
lat, lng = [53, 21]
conditions = { :page => 1, :per_page => 20 }
map = "function() { emit(this._id, {lat: this.lat, lng: this.lng}); }"
reduce = <<BEGIN
function(key, values) {
distance = 0;
values.forEach(function(doc) {
distance = (doc.lat - #{lat})*(doc.lat - #{lat}) + (doc.lng - #{lng})*(doc.lng - #{lng});
});
return distance;
# Unique, atomic sequential number generator using MongoMapper, MongoDB and Ruby.
# Usage:
# Helper::Sequence.next_value(:my_seq)
# => 1
# Helper::Sequence.next_value(:my_seq)
# => 2
# Helper::Sequence.next_value(:my_other_seq)
# => 1
# Helper::Sequence.next_value(:my_seq)
# => 3
/* Client side pagination with jQuery by Hubert Łępicki / AmberBit
License: MIT
Usage:
- HTML:
<div class='paginated' per-page='4'><div class='i'>Item 1</div><div class='i'>Item 2</div>....<div class='i'>Item 100</div></div>
- JS:
$('.paginated').clientSidePagination();
*/
$.fn["clientSidePagination"] = function(options) {
options = options || {};
include Java
frame = javax.swing.JFrame.new
frame.set_default_close_operation javax.swing.JFrame::EXIT_ON_CLOSE
frame.get_content_pane.add javax.swing.JLabel.new("Hello, World!")
frame.pack
frame.set_visible true
require 'riddle'
require 'riddle/0.9.9'
companies = %w(AmberBit Google HP)
client = Riddle::Client.new "localhost", 5000
client.match_mode = :extended
client.sort_mode = :extended
client.sort_by = "@geodist ASC"
Failures:
1) Mongoid::Attributes .accepts_nested_attributes_for #association_attributes= on a embeds many association when :allow_destroy is enabled removes the items that have _destroy => true set
Failure/Error: @person.favorites_attributes = @attributes
undefined method `favorites_attributes=' for #<Person:0x7f10ebc3d860>
# ./spec/../lib/mongoid/attributes.rb:23:in `method_missing'
# ./spec/unit/mongoid/attributes_spec.rb:133
# /home/hubert/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `inject'
2) Mongoid::Collections .index_information returns index information from the collection
Failure/Error: Person.index_information["title_1"].should_not be_nil
require 'rails'
module Cms
class Engine < Rails::Engine
rake_tasks do
load "cms/railties/tasks.rake"
end
end
end
class HelloWorldController < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
include ActionController::UrlWriter
# Uncomment if you want to use helpers defined in ApplicationHelper in your views
# helper ApplicationHelper
package com.fuckeyah.todos;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;