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
app.round_up = (float, digits) -> | |
digits = (if not digits? then 2 else digits) | |
k = Math.pow(10, digits) | |
int = (float * k).toFixed(1) | |
rounded = Math.floor(int) | |
((rounded + ((if int - rounded < 0.5 then 0 else 1))) / k).toFixed 2 |
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 ChangeMessages < ActiveRecord::Migration | |
def change | |
rename_column :messages, :recipient_ids, :old_recipient_ids | |
add_column :messages, :recipient_ids, :integer, array: true | |
Message.all.each do |message| | |
message.recipient_ids = message.old_recipient_ids | |
message.save!(validate: false) | |
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
app.pluralize = (num, variant1, variant2, variant3)-> | |
plural = | |
if num % 10 == 1 && num % 100 != 11 | |
0 | |
else if num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) | |
1 | |
else | |
2 | |
switch plural |
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
1) Enter these 2 commands in the Terminal to add this PPA and update your packages list: | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
2) Enter one (or more) of these commands to install the proprietary Java(s) you require: | |
sudo apt-get install oracle-java6-installer | |
sudo apt-get install oracle-java7-installer | |
sudo apt-get install oracle-java8-installer |
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
1. Mysql only | |
> ids = [11,31,29] | |
=> [11, 31, 29] | |
> Page.where(id: ids).order("field(id, #{ids.join(',')})") | |
2. Postrgesql variant | |
def self.order_by_ids(ids) | |
order_by = ["case"] |
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
bundle exec unicorn_rails -c config/unicorn.conf.rb -E production -D |
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
lib/tasks/dummy.rake | |
namespace :db do | |
desc "Add system data" | |
task dummy: :environment do | |
SeedDummyData.run | |
end | |
end | |
class SeedDummyData |
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
CTRL + SHIFT + P | |
in opened window put: Install | |
ENTER | |
in opened window put: SidebarFileExt | |
ENTER |
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
For editing use | |
vi galfit.feedme | |
For inserting | |
Press i //Do required editing |
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
sudo apt-get remove --auto-remove vagrant | |
sudo apt-get purge --auto-remove vagrant | |
sudo rm -rf /opt/vagrant | |
sudo rm -rf /usr/bin/vagrant | |
sudo rm -rf ~/.vagrant.d |
OlderNewer