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 Class | |
def acts_as(*args) | |
modules_with_options = [] | |
for arg in args | |
if arg.is_a?(Module) | |
modules_with_options << [arg] | |
elsif arg.is_a?(Hash) | |
raise ArgumentError, "Options without module" unless modules_with_options[-1][0].is_a?(Module) | |
modules_with_options[-1][1] = arg | |
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
/* Style un-reset for TinyMCE content inserted on the pages with YUI CSS reset. | |
* Added along with YUI CSS reset to the content_css option of TinyMCE and to the page on which TinyMCE content should be displayed. | |
*/ | |
/* This part is based on tinymce-3.2.1.1\jscripts\tiny_mce\themes\advanced\skins\default\content.css */ | |
.mceContentBody, | |
.mceContentBody td, | |
.mceContentBody pre | |
{ |
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
ActiveRecord::Associations::AssociationCollection.class_eval do | |
def sum_with_enumerable_fallback(*args, &block) | |
if args.empty? && block | |
to_a.sum(&block) | |
else | |
sum_without_enumerable_fallback(*args) | |
end | |
end | |
alias_method_chain :sum, :enumerable_fallback |
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
var MyClass = function() { | |
var self = this; | |
$.extend(self, { | |
initialize: function(constructor_arg1, constructor_arg2) { | |
self.method(); | |
}, | |
method: function() { | |
} | |
// other methods below... |
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
def parse_rails_log_file(file) | |
# Remove all empty lines | |
lines = file.each_line.map(&:strip).reject(&:empty?) | |
# Use +Enumerable#slice_before+ to slice log file into sections for each request | |
lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| | |
# Only include successfully finished actions in report | |
if duration = request_log.last[/Completed 200 OK in (?<duration>\d+)ms/, :duration] | |
action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] | |
totals[action_name] ||= 0 |
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
def parse_ini_file(file) | |
# Use +Enumerable#slice_before+ to slice ini file into sections where | |
# start of new section is detected with regexp matching the opening square bracket | |
file.each_line.slice_before(/\[/).each_with_object({}) do |section, config| | |
# Remove the first element which is the section header and extract header name | |
section_name = section.shift[/\[(?<section_name>.+?)\]/, :section_name] # use Oniguruma's named capture | |
# Use Hash[] class method to create parameters hash from key/value assoc array | |
section_parameters = Hash[section.map { |parameter| parameter.split("=").map(&: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
if ARGV.size < 1 | |
puts "Use like mysqldump database_name | ./#{ $PROGRAM_NAME } table_name[s]" | |
exit(0) | |
end | |
# Dump for each table in standard mysqldump output is started with the line like: | |
# | |
# -- Table structure for table `access_rights` | |
# | |
# Use +Enumerable#slice_before+ to slice the whole dump into sections per table |
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 | |
if ARGV.empty? | |
puts <<-USAGE | |
Use like tail -f log/production.log | #{ $PROGRAM_NAME } request_regexp | |
Examples: | |
Show only local requests: | |
tail -f log/production.log | #{ $PROGRAM_NAME } 127.0.0.1 |
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
taskkill /f /im gnotify.exe | |
taskkill /f /im skype.exe | |
taskkill /f /im miranda32.exe |
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
diff --git a/ext/internal/node/node_type_descrip.c.rpp b/ext/internal/node/node_type_descrip.c.rpp | |
index 10ae8a3..5ae8ca4 100644 | |
--- a/ext/internal/node/node_type_descrip.c.rpp | |
+++ b/ext/internal/node/node_type_descrip.c.rpp | |
@@ -3,7 +3,7 @@ | |
Node_Type_Descrip node_type_descrips_unsorted[] = { | |
#ruby <<END | |
-require 'node_type_descrip' | |
+require File.expand_path('../node_type_descrip', __FILE__) |
OlderNewer