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 |
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
# 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
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
➜ wordpress sudo chown -R _www ./ | |
➜ wordpress sudo chmod -R g+w ./ |
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
<!-- 1. "Show Package Contents" --> | |
<!-- 2. Open Info.plist --> | |
<!-- 3. append to "dict" section: --> | |
<key>LSUIElement</key> | |
<string>1</string> | |
<!-- Worked for iTerm. --> | |
<!-- Or change Info.plist to have: --> | |
<key>LSUIElement</key> | |
<true/> |
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
server{ | |
server_name www.domain.com; | |
return 301 $scheme://domain.com$request_uri; | |
} | |
server{ | |
server_name domain.com; | |
[...] | |
} |
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
`mkdir .ssh` | |
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> ~/.ssh/authorized_keys' | |
# optional | |
sudo chmod 700 .ssh | |
sudo chmod 640 .ssh/authorized_keys |
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
# dump all databases | |
mysqldump --user=root --password=pass --all-databases > localhost.sql | |
# dump specific databases | |
mysqldump --user=root --password=pass --databases DB_NAME1 DB_NAME2 DB_NAME3 > backup.sql | |
# restore from file | |
mysql --verbose --user=root --password=pass DB_NAME < /PATH/TO/DUMPFILE.SQL | |
# copy database |
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
ps aux | grep puma |
OlderNewer