Skip to content

Instantly share code, notes, and snippets.

View npras's full-sized avatar
😃
Coding all the time

Prasanna Natarajan npras

😃
Coding all the time
View GitHub Profile
@npras
npras / number_guess.sh
Created July 2, 2026 11:46
fcc certification - number_guess - relational database
#!/bin/bash
psql=(psql --username=freecodecamp --dbname=number_guess -t --no-align -X)
#echo $("${psql[@]}" "\d")
get_username="Enter your username:"
welcome_msg="Welcome, %s! It looks like this is your first time here."
welcome_back_msg="Welcome back, %s! You have played %d games, and your best game took %d guesses."
game_prompt_start="Guess the secret number between 1 and 1000:"
@npras
npras / element.sh
Created June 29, 2026 11:05
fcc - certification - relational database - periodic table
#!/bin/bash
# one two three asdf
if [[ -z $1 ]]; then
printf "Please provide an element as an argument.\n"
exit 0
fi
arg="$1"
@npras
npras / salon.sh
Created June 27, 2026 14:21
fcc certification - relational db - salon appointment
#!/bin/bash
psql="psql --username=freecodecamp --dbname=salon -X -A -t -c"
# use a hash to store ids instead of regular arrays because of fast lookup ability
declare -A service_id_to_name
# use this reg array to keep track of service record order, based on service id
service_order=()
@npras
npras / insert_data.sh
Created June 27, 2026 03:11
fcc - certification - relational database - worldcup
#! /bin/bash
if [[ $1 == "test" ]]
then
PSQL="psql --username=postgres --dbname=worldcuptest -t --no-align -c"
else
PSQL="psql --username=freecodecamp --dbname=worldcup -t --no-align -c"
fi
# Do not change code above this line. Use the PSQL variable above to query your database.
@npras
npras / fcc-celestial.sql
Last active June 19, 2026 00:21
fcc-celestial.sql
create table galaxy(
galaxy_id serial primary key,
name varchar(30) not null unique,
is_milky boolean not null default false,
age int,
distance numeric
);
create table star(
star_id serial primary key,
@npras
npras / markdown.js
Created June 13, 2026 13:29
FCC - javascript certification project - markdown to html converter
const mdInput = document.querySelector('#markdown-input');
const htmlOutput = document.querySelector('#html-output');
const htmlPreview = document.querySelector('#preview');
const Transformers = [
// block level elems
[/^# (.+)/gm, "<h1>$1</h1>"],
[/^## (.+)/gm, "<h2>$1</h2>"],
[/^### (.+)/gm, "<h3>$1</h3>"],
[/^> (.+)/gm, "<blockquote>$1</blockquote>"],
@npras
npras / application.js
Created January 5, 2025 00:50
Javascript in Rubular.com
function $w(e) {
return (e = e.strip()) ? e.split(/\s+/) : []
}
function $H(e) {
return e && e.constructor == Hash ? e : new Hash(e)
}
function $(e) {
if (1 < arguments.length) {
@npras
npras / build.sh
Created December 27, 2024 14:47
Bash Script to Build a Static Website From a Bunch of Markdown Files
#!/usr/bin/env bash
# set -euxo pipefail
set -euo pipefail
die() {
printf "%s\n" "$*" > "$(tty)"
exit 1
}
@npras
npras / acme-client.conf
Created November 6, 2024 05:29 — forked from morgant/acme-client.conf
OpenBSD httpd & relayd reverse proxy configuration
authority letsencrypt {
api url "https://acme-v02.api.letsencrypt.org/directory"
account key "/etc/acme/letsencrypt-privkey.pem"
}
# example.net
domain example.net {
alternative names { www.example.net }
domain key "/etc/ssl/private/example.net.key"
domain certificate "/etc/ssl/example.net.crt"
@npras
npras / af2_original_submission.rb
Last active March 10, 2017 14:10
AF - Codility: Task2
def solution(a)
total = a.size
lindex = a.size-1
sorted = a.sort
min = total
combos = []
return 0 if a == sorted
(2..total).each do |pair_size|