Skip to content

Instantly share code, notes, and snippets.

View michaeldegli's full-sized avatar

Michael D. michaeldegli

View GitHub Profile
@michaeldegli
michaeldegli / big-o.md
Created January 4, 2022 21:09 — forked from PJUllrich/big-o.md
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for < 32 elements, O(log n) for >= 32 elements [2]
Deletion O(n) for < 32 elements, O(log n) for >= 32 elements
@michaeldegli
michaeldegli / postgres_queries_and_commands.sql
Created July 2, 2021 14:32 — 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%'
@michaeldegli
michaeldegli / .vimrc
Last active November 8, 2020 18:20
VIM Configuration
" VIM Configuration - Vincent Jousse
" Cancel the compatibility with Vi. Essential if you want
" to enjoy the features of Vim
set nocompatible
" Activate pathogen
call pathogen#infect()
" -- Display
set title " Update the title of your window or your terminal
defmodule ChangeMaker do
@denominations [
10000,
5000,
2000,
1000,
500,
200,
100,
25,
@michaeldegli
michaeldegli / vcard.py
Last active October 18, 2019 00:34
Parse VCard with Python
import asyncio
import vobject
import os
import json
import_dir = os.path.dirname(__file__)
rel_path = "contacts.vcf"
abs_file_path = os.path.join(import_dir, rel_path)
f = open(abs_file_path)
@michaeldegli
michaeldegli / Dockerfile
Created September 25, 2019 20:34
Phoenix Sample Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y curl git locales
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt-get -y update && \
@michaeldegli
michaeldegli / Elixir_Supervision_Trees.md
Created July 19, 2019 19:24 — forked from gkaemmer/Elixir_Supervision_Trees.md
Quick guide to creating Elixir supervision trees from scratch

Elixir Supervision Trees Made Easy

I started with Elixir just a couple weeks after the switch from 1.4 to 1.5, so the bulk of online resources were out of date (or at least resulted in deprecation warnings). This guide is for defining Elixir 1.5 supervised modules.

It's not actually terribly complicated. It's just sometimes unclear from examples what's implemented by the language and what you actually have to implement yourself.

Say we want a supervision tree like this (where each atom is a process):

    :a

/ \

" This vimrc is "inspired" by @moonglum, @garybernhardt and @railsbros-dirk
" Thanks to all of you for letting me steal your stuff :)
" Activate Syntax Highlight
set hlsearch
" Incremental search, search as you type
set incsearch
" Ignore case when searching
set ignorecase smartcase
" Ignore case when searching lowercase
@michaeldegli
michaeldegli / Pull-and-Sync-Data-Between-Google-Doc-Spreadsheet-and-MySQL.gs
Created July 12, 2018 19:18
You can pull data from MySQL database to Google doc spreadsheet auto with just click of a button or scheduled time. This is great use for retrieving data in spreadsheet format.
// MySQL to Google Spreadsheet By Pradeep Bheron
// Support and contact at pradeepbheron.com
function myMySQLFetchData() {
var conn = Jdbc.getConnection('jdbc:mysql://127.0.0.1:3306/employee_db', 'username', 'pass'); // Change it as per your database credentials
var stmt = conn.createStatement();
var start = new Date(); // Get script starting time
@michaeldegli
michaeldegli / missingNumbers.js
Created November 25, 2016 18:44
Given an array of integers, select the missing numbers in the sequence.
// https://jsbin.com/wakubofuvo/edit?js,console
var arr = [2012, 2011, 2010, 2008, 2002];
var tmp = [];
_.forEach(arr, function (e, i) {
if(e - arr[i + 1] > 1) {
var range = e - (arr[i + 1] + 1); //in between
while(range > 0) {
tmp.push({year: +(e - range)});
--range;