This file contains hidden or 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
SELECT first_name, last_name | |
FROM users | |
GROUP BY first_name, last_name | |
HAVING COUNT(*) > 1 |
This file contains hidden or 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
# Rails 4 | |
class ExampleModel < ActiveRecord::Base | |
self.inheritance_column = '_type_disable' | |
end | |
# Rails 3 | |
class ExampleModel < ActiveRecord::Base | |
set_inheritance_column do | |
'disabled' | |
end |
This file contains hidden or 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
puts oldproduct.title | |
# => Gestänge Stahl lang für Tarps (240cm) | |
i = Iconv.new('LATIN1','UTF-8') | |
new_title = i.iconv(oldproduct.title).force_encoding("UTF-8") | |
puts new_title | |
# => Gestänge Stahl lang für Tarps (240cm) |
This file contains hidden or 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 App.Helper | |
generate_password: (length = 8) -> | |
charset = "abcdefghjknpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789_@=.%" | |
password = "" | |
i = 0 | |
n = charset.length | |
while i < length | |
password += charset.charAt(Math.floor(Math.random() * n)) | |
++i | |
password |
NewerOlder