Skip to content

Instantly share code, notes, and snippets.

View ndeto's full-sized avatar
💭
GraphQL

Martin Ndeto ndeto

💭
GraphQL
View GitHub Profile
@ndeto
ndeto / configure-ec2-instance.md
Created March 31, 2023 03:26 — forked from linuxdevops-34/configure-ec2-instance.md
Complete guide for deploying rails application to aws ec2 instance, using capistrano as deploying tool with nginx & puma server

Deploy Rails Application to AWS EC2

Creating AWS EC2 Instance

- login to 'AWS Management Console' (https://aws.amazon.com/console/)
- from 'Services'(in navbar) choose 'EC2'
- from 'Create Instance' section, click on 'Launch Instance'
- then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example
- select 'Instance Type' as per your requirement
- then click 'Next:Configure Instance Details' to continue
  change 'Configure Instance Details' or used as default settings
@ndeto
ndeto / Robot.rb
Last active February 4, 2022 07:02
A robot actions code
class Robot
MOVEMENTS = ['N', 'E', 'W', 'S']
ACTIONS = ['G', 'D']
CRATES_POSITIONS = []
@length = 10
@width = 10
@is_lifting = false
@ndeto
ndeto / clean_json_backslash.rb
Created September 23, 2021 04:55
Clean Backslashes
# Clean backslash characters
def clean_str(str)
new_str = []
str.chars.each do |char|
if char == "\\"
next
end
new_str << char
end
def filter
# receive params
allowed_constant_params = %w(property_type listing_type_id rooms bathrooms location)
allowed_varying_params = %w(price)
query = ""
allowed_constant_params.each do |param|
unless params[param] == ""
if query.empty?
query.concat("SELECT * FROM properties WHERE #{param} = '#{params[param]}'")
@ndeto
ndeto / EmailValidationRegex.js
Created October 22, 2017 19:06
Email validation Regex
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (email.match(re)) {
return true;
} else {
return false;
}
}
@ndeto
ndeto / kenyanphonenumber.js
Created October 22, 2017 19:03
Regex for Kenyan phone numbers in format 07xxxxxxxx
var phoneno = /^(07)([0-9|7])(\d){7}$/;
if (phonenumber.match(phoneno)) {
return true;
} else {
return false;
}