Skip to content

Instantly share code, notes, and snippets.

View rickyah's full-sized avatar

Ricardo Amores Hernández rickyah

  • Barcelona
  • 18:47 (UTC +02:00)
  • X @rickyah
View GitHub Profile
@rickyah
rickyah / GetCurrentMethodName.cs
Created March 28, 2014 11:02
Get the currently executing method name in .NET/Mono
[MethodImpl(MethodImplOptions.NoInlining)]
public string GetCurrentMethodName()
{
StackTrace st = new StackTrace ();
StackFrame sf = st.GetFrame (1);
MethodBase method = sf.GetMethod();
return method.DeclaringType.FullName + ':' + sf.GetMethod().Name;
}
@rickyah
rickyah / :rails :erb RefineryCms locale navigation
Created August 30, 2012 16:50 — forked from errorstudio/_locale_nav.html.erb
Refinery CMS: a list of all frontend locales with links
<ul>
<% Refinery::I18n.config.frontend_locales.each do |locale| %>
<li>
<%= link_to "/#{locale.to_s + request.path}", {:title => Refinery::I18n.locales[locale]} do%>
<span><%= Refinery::I18n.locales[locale] %></span>
<% end -%>
</li>
<% end %>
</ul>
@rickyah
rickyah / :rails Add timestamps to logs
Last active October 1, 2015 13:28
Add timestamps and more info to default Rails logger
# Adds timestamps to logs
# put it at the end of environment.rb
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
level = {
0 => "DEBUG",