This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEFORE | |
def access_denied! | |
throw(:halt, :access_denied) | |
end | |
def access_denied(message = "Please sign in first") | |
case content_type | |
when :html | |
store_location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application/authentication.rb | |
class Application | |
module Authentication | |
module Accessors | |
# Returns true or false if the user is logged in. | |
# Preloads @current_person with the Person model if they're logged in. | |
def logged_in? | |
!!current_person | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ::Object | |
def hide_inspect_for_one_shot(replacement = "#<#{self.class}:0x#{object_id.to_s(16)}>") | |
return unless self | |
mc = class <<self; self; end | |
mc.send(:alias_method, :inspect_457290, :inspect) | |
mc.send(:define_method, :inspect) do | |
mc.send(:alias_method, :inspect, :inspect_457290) | |
replacement | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oleg Andreev: | |
щас пишу named args для Io | |
с ними проблема есть концептуальная: | |
в руби они как хеши - это удобно | |
можно передавать туда-сюда | |
но не очень эффективно | |
в обж-си они - часть имени метода | |
их не попередаешь туда-сюда | |
вопрос: какой подход лучче | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The simplest possible state machine implementation in AS3. | |
Author: Oleg Andreev <oleganza@gmail.com> | |
Date: March 11, 2009 | |
Example: | |
// If you single hit spacebar, you just trigger play/pause state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* treat double click as a single click (hello, Mom! :-) | |
function onMouseDown(){ | |
if (!SingleClick()) return | |
... | |
} | |
*/ | |
package pierlis.framework | |
{ | |
public function SingleClick(delay = SC.DELAY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Reclone current directory to refresh Flash CS3 brains about classpath | |
# (after that please do "cd .") | |
def main | |
dir = File.dirname(File.expand_path(__FILE__)) | |
dir_basename = File.basename(dir) | |
dir_basename2 = dir_basename + "-refucking-flash" | |
origin = sh("git config remote.origin.url").strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pierlis.framework | |
{ | |
import flash.events.* | |
import fl.transitions.* | |
import pierlis.framework.* | |
/* | |
var tq = new TweenQueue() | |
tq.push(function(){ new Tween(...) }) | |
tq.push(function(){ new Tween(...) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BNF parser framework for JavaScript | |
// Oleg Andreev | |
var result = (function(text){ | |
// The Y Combinator | |
var Y=function (gen) { | |
return function(f) {return f(f)}( | |
function(f) { | |
return gen(function() {return f(f).apply(null, arguments)})})} |