Skip to content

Instantly share code, notes, and snippets.

@alex700
alex700 / update-config.sh
Created April 5, 2024 23:08
Shell script to place AWS credentials issued by Opal to local AWS config
#!/bin/sh
# Usage Instructions
# - Open Opal and login to AWS.
# - Copy content with environment variables and place it to ~/.aws/opal-config.txt
# - Make the script executable: chmod +x update-config.sh
# - The script will place the credentials to ~/.aws/config
config_file="$HOME/.aws/opal-config.txt"
aws_config_file="$HOME/.aws/config"
@alex700
alex700 / list_ror_models.rb
Last active December 21, 2023 00:29
List Ruby on Rails models
# Open rails console `rails c` and run the command:
ActiveRecord::Base.descendants.map(&:name).each { |name| puts name }
# Alternatively, list classes that extend ActiveRecord::Base or any other class the application might use as a base model
ObjectSpace.each_object(Class).select { |klass| klass < ActiveRecord::Base }.map(&:name).sort
# For docker-based apps
docker exec -it [your_container_name] rails runner "ActiveRecord::Base.descendants.each { |model| puts model.name }"
@alex700
alex700 / check_sum.rb
Created October 12, 2023 22:55
Checksum of Ruby Application
#!/usr/bin/env ruby
require 'digest'
require 'fileutils'
# Function to calculate the checksum for a directory
def calculate_checksum(directory_path, excluded_directories = [])
checksum = Digest::SHA256.new
Dir[File.join(directory_path, '**', '**/*')].each do |file|
@alex700
alex700 / add_two_numbers.js
Created August 7, 2022 21:38
Add two numbers (LeetCode #2)
function ListNode(val, next) {
this.val = (val === undefined ? 0 : val);
this.next = (next === undefined ? null : next);
}
const addTwoNumbers = (l1, l2) => {
let carry = 0;
let result = new ListNode(-1)
let dummy = result;
@alex700
alex700 / lru_cache.js
Created August 7, 2022 21:31
LRU Cache Implementation
class LruCache {
constructor(capacity) {
this.capacity = capacity;
this.map = new Map();
}
get(key) {
if(this.map.has(key)) {
let val = this.map.get(key);
this.map.delete(key);
@alex700
alex700 / main.go
Created June 23, 2022 21:39
Detect Number of Islands - LeetCode - Go
package main
import "fmt"
func main() {
var a = [][]int{
{0, 0, 1, 1, 0},
{0, 0, 1, 1, 0},
{1, 0, 1, 0, 0},
{1, 0, 1, 0, 0},
@alex700
alex700 / BluetoothOn
Created April 14, 2020 16:45
Perform these commands to solve the problem: Connection Failed: blueman.bluez.errors.DBusNotReadyError: Resource Not Ready
bluetoothctl
power on
discoverable on
pairable on
scan on
@alex700
alex700 / ng_image_skin.sh
Last active November 19, 2019 19:16
KDE5 - Set National Geographic Picture of a Day to Desktop
#!/bin/bash
# This script downloads photo of the day from nationalgeographic.com and set it as desktop wallpaper.
# Applicable for Ubuntu KDE 18.04
# Permission to copy, modify, and distribute is granted under GPLv3
# Last Revised 7 Mar 2019
#
# Initial installation:
# Place the script into /usr/local/bin/ng_image_skin
# Run it to pull image and create symlink to it which will be lcocated at ~/Picture/Wallpapers/wp_image
# Set desktop image manually that pointed to ~/Picture/Wallpapers/wp_image
@alex700
alex700 / kernel_4.19.sh
Last active January 16, 2019 00:21
Download and install linux 4.19 kernel
#!/bin/bash
#
# Install linux kernel 4.19
#
# To check last available dep's visit https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/
#
##
rm -rf linux-*;
@alex700
alex700 / phpldapadmin.conf
Created October 11, 2018 21:33
Nginx Config for phpldapadmin
server {
listen 80;
server_name localhost;
# application: phpldapadmin
location /phpldapadmin {
alias /usr/share/phpldapadmin/htdocs;
index index.php index.html index.htm;