models = Model.all.group_by{|model| [model.attr1,model.attr2,model.attr3] }; nil
models.values.each do |duplicates|
first_one = duplicates.shift
duplicates.each{|double| double.destroy} # duplicates can now be destroyed
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
'use strict'; | |
// Configure authentication | |
const authUser = 'user'; | |
const authPass = 'pass'; | |
exports.handler = (event, context, callback) => { | |
// Get request and request headers | |
const request = event.Records[0].cf.request; | |
const headers = request.headers; |
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
#!/bin/sh | |
target_env=$1 | |
profile=$2 | |
REPO="https://gitlab.com/namespace-inc/corporate" | |
SLACK_URL="https://hooks.slack.com/services/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" | |
CHANNEL="#corporate" | |
BOTNAME="deployer" |
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
{ | |
"HTML": { | |
"beautifiers": [ | |
"Pretty Diff", | |
"JS-Beautify" | |
], | |
"indent_size": 2, | |
"indent_style": "space", | |
"max_preserve_newlines": 0, | |
"multiline_ternary": "never", |
Copy data from one table to another table, and insert it.
INSERT INTO destination_table(
col1, col2, col3, col4, col5, col6
)
SELECT col1, col2, col3, 'custom_value' as col4, col5, col6
FROM source_table;
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems
sudo apt install apache2
sudo systemctl enable apache2
sudo service apache2 status
sudo ufw app list
sudo ufw allow in "Apache Full"
sudo a2enmod rewrite
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
# Example: | |
# Adding unique index on user_id(existing foreign_key) of kycs table | |
class AddUniqueIndexOnUserIdToKycs < ActiveRecord::Migration[6.0] | |
def change | |
remove_foreign_key :kycs, :users | |
remove_index :kycs, :user_id | |
add_index :kycs, :user_id, unique: true | |
add_foreign_key :kycs, :users | |
end | |
end |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
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
devise_for :users, :skip => [:registrations] | |
as :user do | |
get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration' | |
put 'users' => 'devise/registrations#update', :as => 'user_registration' | |
end | |
# And then modify the app/views/devise/shared/_links.erb |