Skip to content

Instantly share code, notes, and snippets.

Avatar

Ricardo Amores Hernández rickyah

View GitHub Profile
@rickyah
rickyah / GetCurrentMethodName.cs
Created Mar 28, 2014
Get the currently executing method name in .NET/Mono
View GetCurrentMethodName.cs
[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 Aug 30, 2012 — forked from errorstudio/_locale_nav.html.erb
Refinery CMS: a list of all frontend locales with links
View :rails :erb RefineryCms locale navigation
<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 Oct 1, 2015
Add timestamps and more info to default Rails logger
View :rails Add timestamps to logs
# 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",