Skip to content

Instantly share code, notes, and snippets.

💭
Never asked for this.

Paweł Gościcki pjg

💭
Never asked for this.
Block or report user

Report or block pjg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am pjg on github.
  • I am pjg (https://keybase.io/pjg) on keybase.
  • I have a public key whose fingerprint is E334 4C87 8C09 541C 00E7 8C13 55D0 A2D3 1EE6 F1ED

To claim this, I am signing this object:

View resource_hacks lib for Rails 2.3.4
module ActionController
module Resources
class Resource
# Redefining methods from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/resources.rb so that the RESTful routes accept member_path option
def member_path
@member_path || options[:member_path] || "#{shallow_path_prefix}/#{path_segment}/:id"
end
View application_controller.rb
def default_url_options(options = {})
# resource hack so that url_for(@post) works like it should
# if a post was given as a parameter to `post_path` it will be assigned to the first (unnassigned) parameter of the route (year)
if options[:controller] == "posts" && options[:year].is_a?(Post)
post = options[:year]
options[:year] = post.year
options.merge(:month => post.month, :slug => post.slug)
else
{}
end
@pjg
pjg / gist:1385392
Created Nov 22, 2011
Metaprogramming fu
View gist:1385392

I have:

def self.host
  @@host ||= something
end

now I want to convert it into this:

@pjg
pjg / lyrics.txt
Created Apr 22, 2012
Piano Man by Johnny Diggz @ Railsberry
View lyrics.txt
It's 8:00 o'clock on a Friday
The regular crowd shuffles in
there's an old man sitting next to me
making love to his beer
la la di di da
la la di di da
Sing us a song, you're the piano man!
sing us a song tonight
@pjg
pjg / gist:4619601
Created Jan 24, 2013
My vim version
View gist:4619601
```bash
☺ vim --version 11:16
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 26 2012 16:45:32)
Included patches: 1-547
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
View projections.json
{
"app/assets/javascripts/models/*.coffee": {
"command": "jmodel",
"alternate": "spec/javascripts/models/%s_spec.coffee",
"template": "App.%S = DS.Model.extend"
},
"app/assets/javascripts/controllers/*_controller.coffee": {
"command": "jcontroller",
"alternate": "spec/javascripts/controllers/%s_spec.coffee",
View big_decimal_inspect.rb
class BigDecimal
def inspect
format("#<BigDecimal:%x %s>", object_id, to_s('F'))
end
end
View rails_load_path_tips.md

In Rails 3

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

(e.g. app/models/concerns/, app/models/products/)

@pjg
pjg / rom-mapper.rb
Last active Oct 6, 2017
rom-mapper problem with reverse relationship
View rom-mapper.rb
require 'rom-mapper'
class BigDecimal
def inspect
format("#<BigDecimal:%x %s>", object_id, to_s('F'))
end
end
class Gateway
def get_authors
You can’t perform that action at this time.