Skip to content

Instantly share code, notes, and snippets.

View egze's full-sized avatar

Aleksandr Lossenko egze

View GitHub Profile
@egze
egze / Gemfile
Created January 6, 2011 13:05 — forked from smichaelis/Gemfile
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path '.gems/bundler_gems'
# List gems to bundle here:
gem 'rails_dm_datastore'
gem 'rails', "2.3.5"
# Needed for Devise-Plugin
@egze
egze / README.rdoc
Created January 6, 2011 14:07 — forked from woodie/README.rdoc

Rails 2.3.10 on App Engine (DataMapper)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also: gist.github.com/gists/269075

Install the Development Environment

@egze
egze / gist:3287333
Created August 7, 2012 17:06
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@egze
egze / after_commit_patch.rb
Created August 21, 2012 18:22 — forked from gnufied/after_commit_patch.rb
after_commit_patch.rb
#WARNING do not load this file in environments other than test
module AfterCommitPatch
def transaction(options = {})
rolled_back = false
return_value = nil
begin
return_value = super
rescue ActiveRecord::Rollback => e
puts e.message
puts e.backtrace
class EventCell < UITableViewCell
IDENTIFIER = 'EventCell'
PADDING = 10
LEFT_MARGIN = 40
RIGHT_MARGIN = 20
attr_reader :event
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
@egze
egze / README.md
Created May 8, 2018 19:01 — forked from sevos/README.md
Rails 5.2 + Komponent + Turbolinks + Stimulus

Usage

rails new my_app --rc=template.rc -m template.rb
@egze
egze / with_example.ex
Created February 15, 2020 17:46 — forked from devonestes/with_example.ex
Further refactoring of a with statement
# Step 1
def create_subscription(email, plan_id, payment_method_id) do
with %User{customer_id: nil, name: name} = user <-
Repo.get_by(User, email: email),
{:ok, %Stripe.Customer{id: customer_id}} <-
Stripe.Customer.create(%{
name: name,
email: email,
payment_method: payment_method_id,
@egze
egze / foo.ex
Created June 12, 2020 16:16 — forked from 0x6a6/foo.ex
Spec to Callback
defmodule MyApp.Foo do
@on_definition MyApp.SpecToCallback
@spec bar(String.t()) :: String.t()
def bar(foobar) do
impl().bar(foobar)
end
defp impl, do: Application.get_env(:my_app, :my_app_foo_impl, __MODULE__.DefaultImpl)
end
@egze
egze / ets_cache.ex
Created September 23, 2020 19:01 — forked from raorao/ets_cache.ex
Simple ETS based cache with TTL
defmodule RequestCache do
@moduledoc """
Simple ETS-based cache.
"""
use GenServer
@type t :: %{ttl: integer, invalidators: %{}}
@type cache_key :: any
@type cache_value :: any
@egze
egze / snowjob.sh
Created December 15, 2023 11:24 — forked from sontek/snowjob.sh
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear