Skip to content

Instantly share code, notes, and snippets.

View terdia's full-sized avatar

Ogbemudia Terry Osayawe terdia

View GitHub Profile
@terdia
terdia / postgres_queries_and_commands.sql
Created September 22, 2022 16:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'

I bundled these up into groups and wrote some thoughts about why I ask them!

If these helped you, I'd love to hear about it!! I'm on twitter @cvitullo or send me an email carl.vitullo@gmail.com

Onboarding and the workplace

https://medium.com/@cvitullo/questions-to-ask-your-interviewer-82a26e67ce6c

  • How long will it take to deploy my first change? To become productive? To understand the codebase?
  • What kind of equipment will I be provided? Will the company pay/reimburse me if I want something specific?
@terdia
terdia / Laravel-Container.md
Created April 7, 2018 23:55
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

// Bonfire: Return Largest Numbers in Arrays
// Author: @terdia
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays?solution=function%20largestOfFour(arr)%20%7B%0A%20%20%2F%2F%20You%20can%20do%20this!%0A%20%20%0A%20%20%0A%20%20var%20result%20%3D%20%5B%5D%3B%0A%20%20var%20i%3B%0A%20%20var%20j%20%3D%200%3B%0A%20%20%0A%20%20%2F%2Floop%20through%20the%20main%20array%20element%20with%20i%0A%20%20for(i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B)%7B%0A%20%20%20%20var%20base_check%20%3D%200%3B%0A%20%20%20%20%0A%20%20%20%20%2F%2Floop%20through%20the%20inner%20array%20element%20with%20j%0A%20%20%20%20for(j%20%3D%200%3B%20j%20%3C%20arr.length%3B%20j%2B%2B)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%2F%2Fget%20the%20value%20of%20the%20current%20inner%20array%20element%20in%20the%20loop%0A%20%20%20%20%20%20%20%20var%20value_from_inner_array%20%3D%20arr%5Bi%5D%5Bj%5D%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%2F%2Fcheck%20if%20that%20is%20greater%20than%20base%20che
// Bonfire: Find the Longest Word in a String
// Author: @terdia
// Challenge: http://www.freecodecamp.com/challenges/bonfire-find-the-longest-word-in-a-string?solution=function%20findLongestWord(str)%20%7B%0A%20%20%0A%20%20var%20convertToArray%20%3D%20str.split(%22%20%22)%3B%0A%20%20var%20longestWord%20%3D%20%22%22%3B%0A%20%20var%20check%20%3D%20%22%22%3B%0A%20%20%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20convertToArray.length%3B%20i%2B%2B)%7B%0A%20%20%20%20%20%20%20%0A%20%20%20%20if(convertToArray%5Bi%5D.length%20%3E%20check.length)%7B%0A%20%20%20%20%20%20%20check%20%3D%20convertToArray%5Bi%5D%3B%20%0A%20%20%20%20%20%20%20longestWord%20%3D%20convertToArray%5Bi%5D%3B%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20return%20longestWord.length%3B%20%0A%7D%0A%0AfindLongestWord(%22The%20quick%20brown%20fox%20jumped%20over%20the%20lazy%20dog%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function findLongestWord(str) {
var convertToArray = str.split(" ");
var
// Bonfire: Check for Palindromes
// Author: @terdia
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes?solution=function%20palindrome(str)%20%7B%0A%20%20%2F%2F%20Good%20luck!%0A%20%20%0A%20%20%2F%2Fgnoring%20punctuation%2C%20case%2C%20and%20spacing%0A%20%20var%20strippedString%20%3D%20str.toLowerCase().replace(%2F%5CW%7C_%2Fg%2C%20%27%27)%3B%0A%20%20%0A%20%20%2F%2Freverse%20the%20string%20entered%20in%20the%20function%20%0A%20%20var%20reverseString%20%3D%20strippedString.split(%22%22).reverse().join(%22%22)%3B%0A%20%20%0A%20%20%2F%2Fcheck%20if%20reverseString%20is%20equal%20to%20strippedString%20then%20return%20true%20%0A%20%20%2F%2Felse%20return%20false%0A%20%20%0A%20%20if(strippedString%20%3D%3D%3D%20reverseString)%7B%0A%20%20%20%20return%20true%3B%0A%20%20%7D%0A%20%20%0A%20%20return%20false%3B%0A%7D%0A%0A%0A%0Apalindrome(%22A%20man%2C%20a%20plan%2C%20a%20canal.%20Panama%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function palindrome(str) {
// Good