Skip to content

Instantly share code, notes, and snippets.

View polyglotdev's full-sized avatar

Dom Hallan polyglotdev

View GitHub Profile
polyglotdev /
Last active January 3, 2023 18:21
`dynamic_reducer` takes a list integers and an operator and does maths on list to sum integers.
def dynamic_reducer(numbers, operator):
result = numbers[0]
for i in range(1, len(numbers)):
if operator == "+":
result += numbers[i]
elif operator == "-":
result -= numbers[i]
elif operator == "*":
result *= numbers[i]
elif operator == "/":
polyglotdev / hook-flow.js
Created September 24, 2021 21:16
shows how Hooks flow in React
// Hook flow
// http://localhost:3000/isolated/examples/hook-flow.js
// PLEASE NOTE: there was a subtle change in the order of cleanup functions
// getting called in React 17:
import * as React from 'react'
polyglotdev / longest_word.rb
Created September 22, 2021 18:37
longest word
# frozen_string_literal: true
def longest_word(sentence)
split_sentence = sentence.split
my_longest_word = split_sentence.max_by { |word| word.size }
same_length_words = { |word| word.size == my_longest_word.size }
if same_length_words.empty?
polyglotdev /
Last active November 23, 2021 22:40
Software/Hardware that I use
polyglotdev / App.js
Created April 1, 2021 18:23
axios call to api
import './App.css'
import withListLoading from './components/withListLoading'
import List from './components/List'
import React, { useEffect, useState } from 'react'
function App() {
const ListLoading = withListLoading(List)
const [appState, setAppState] = useState({
loading: false,
polyglotdev /
Created November 20, 2020 01:20
Homebrew Extension Issue

Homebrew Extension Issue

After installing the Big Sir 11.0 update I attempted to install graphviz to use with a tool that will map dependecies in node.js projects. The output looked like this:

❯ brew install graphviz                  
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 4 taps (hashicorp/tap, homebrew/cask-versions, homebrew/core and homebrew/cask).
==> New Formulae
using Dapper;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Transactions;
namespace DataLayer
public class ContactRepository : IContactRepository
.PHONY: tf-init
docker-compose -f deploy/docker-compose.yml run --rm terraform init
.PHONY: tf-fmt
docker-compose -f deploy/docker-compose.yml run --rm terraform fmt
.PHONY: tf-validate

Dropping Migration Table, Models, Controller

Command Line

1. Drop Table/Migration

rails generate migration DropTablename

A file will be created, in the db > migrate folder, make sure it looks like:

polyglotdev / seeds.rb
Created October 10, 2018 01:57
require 'random_data'
50.times do
title: RandomData.random_sentence,
body: RandomData.random_paragraph
posts = Post.all