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
put( | |
"/admin/prizes.json", | |
headers: { 'CONTENT_TYPE' => 'application/json; charset=UTF-8' }, | |
params: { prizes: [] }.to_json | |
) |
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
source 'https://rubygems.org' | |
ruby '2.6.5' | |
gem 'dry-initializer' | |
gem 'dry-struct' | |
gem 'dry-types' | |
gem 'dry-validation' |
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
current_user = User.last | |
receipt = Receipt.last | |
pm = Stripe::PaymentMethod.create({ | |
type: 'card', | |
card: { token: 'tok_visa' }, #no PCI complaint thats why | |
billing_details: { | |
address: { | |
city: 'Pune', | |
country: receipt.customer_country, | |
line1: 'Somji Petrol', |
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
def encrypt_alt(message,final_shift) | |
character_set = ("a".."z").to_a << " " | |
split_message = message.split("") | |
offset_array = split_message.map.with_index do |char, index| | |
f_index = (index % 4) + 1 | |
new_index = final_shift[f_index - 1] | |
char_index = character_set.find_index(char) | |
new_char_index = (char_index + new_index) % 27 | |
character_set[new_char_index] | |
end.join |
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 ItemCollection | |
def where(data) | |
items.select do |item| | |
item.fetch(data.keys.first) == data.values.first.to_s | |
end.map { |item| Item.new(item) } | |
end | |
end | |
item_collection = ItemCollection.new | |
item_collection.where({merchant_id: 2}) |
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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
#include <SoftwareSerial.h> | |
float pulse = 0; | |
float temp = 0; | |
SoftwareSerial ser(9,10); | |
String apiKey = "OO707TGA1BLUNN12"; | |
// Variables | |
int pulsePin = A0; // Pulse Sensor purple wire connected to analog pin 0 |
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
# Log in to the droplet | |
ssh deploy@ip_address | |
# install redis server | |
sudo apt-get install redis-server | |
# create sidekiq pid file | |
sudo nano project/shared/tmp/pids/sidekiq.pid | |
# give permission to the pid file |
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
# To cancel busy jobs in sidekiq | |
# Stop sidekiq | |
redis-cli KEYS '*' | xargs -n1 redis-cli DEL |
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
# Examples of select_tag in forms | |
```ruby | |
class SomeModel < ActiveRecord::Base | |
enum status: %i[draft pending paid] | |
end | |
``` | |
```html | |
<%= f.select :status, Receipt.statuses.keys.map{ |w| [w.humanize, w] }, { include_blank: true }, { class: 'form-control', required: true } %> |