Skip to content

Instantly share code, notes, and snippets.

View Miravicson's full-sized avatar

Victor Chiagozie Ughonu Miravicson

View GitHub Profile
@Miravicson
Miravicson / CurrySumFunctional.js
Created November 5, 2021 15:23
CurrySumFunctional. I was able to implement this as soon as we were done with the interview.
// Write a sum function
// sum(1)(2)(3)(4)()
// Logs 10
function currySum(n, acc = 0) {
function createClosure(acc) {
return (m) => currySum(m, acc);
}
@Miravicson
Miravicson / Currying_Sum.js
Created November 5, 2021 15:09
Solution to the encoding string problem.
// Write a sum function
// sum(1)(2)(3)(4)()
// Logs 10
function currySum(n, acc) { // n = 3
if (!n) {
return acc;
} else {
@Miravicson
Miravicson / mutation.jsx
Created October 11, 2021 08:15
Making mutations using react query
const queryKeys = {
completedTodos: "completed-todos",
openTodos: "open-todos"
}
function TodoApp(){
const [selectedTodo, ] = React.useState({/...})
function markAsComplete(todo){
@Miravicson
Miravicson / fontawesome-scss-in-nextjs.md
Created December 31, 2019 07:20 — forked from mehmetnyarar/fontawesome-scss-in-nextjs.md
Loading FontAwesome with SCSS in NextJS

Loading FontAwesome with SCSS in NextJS

Install Plugins

Install these two plugins:

Edit Configuration File

@Miravicson
Miravicson / Heroku env variables
Last active June 20, 2019 22:29
Adding environment variables from local to Heroku via cli
#Adding environment variables from Local to Heroku
1. Running command one by one
```
$ heroku config:set DATABASE_URI=database_uri_here
$ heroku config:set SESSION_SECRET=session_secret
... and so on for each variable,
```
2. Reading the environment variable from a .env file
@Miravicson
Miravicson / Heroku linking.md
Created May 18, 2019 15:35
Linking a project to an existing heroku repository

How to link your local clone of your project to an existing heroku remote:

This comes very handy when you change your laptop

Download the Heroku CLI

Authenticate your Heroku account

`heroku login`

View your heroku app list:

@Miravicson
Miravicson / postgresql mac .md
Created May 17, 2019 10:43
Helpful information for postgresql for mac

Some helpful tips to have for mac postgresql

post setup instructions

  1. to have the launchd start postgresql on startup/login run the following command
    	brew services start postgresql
  2. If you don't need a background service you can just run the following command.
@Miravicson
Miravicson / heroku_config_clone.md
Last active May 3, 2019 16:01
Simple script for cloning all the configuration variables from an existing Heroku application

To clone the configuration variable run the following command

heroku config -s -a existing-heroku-app > .env

Review and push to another application

cat .env | tr '\n' ' ' | xargs heroku config:set -a new-heroku-app

@Miravicson
Miravicson / Postgres.md
Created May 2, 2019 07:53
Some Handy Postgress command

Create a superuser

sudo -u postgres createuser --superuser *name_of_user*

Create a database using the created user

sudo -u *name_of_user* createdb *name_of_database*

@Miravicson
Miravicson / Method employed to prepare the google credentials for heroku deployment.md
Last active March 19, 2019 15:33
An Effective Way to Store Secrets in an Environment Variable

An effective way of saving secrets in environment variable

  • Convert the original file bq_credentials.json in to a Base64 String.
     $ openssl base64 -in bq_credentials.json -out bq_credentials.bin
    
  • Copy the string from the file bq_credentials.bin
  • Save this string in a environment variable with the name GOOGLE_AUTH_KEY
  • In the NodeJS application a function should be written to parse the string saved in the GOOGLE_AUTH_KEY variable to string. Below is a sample function: