This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useMemo, useState } from "react"; | |
import { format, addDays, startOfWeek, endOfWeek, startOfMonth, endOfMonth, isSameMonth, addMonths, subMonths, parseISO, Interval, isFuture, getTime, isToday, isSameDay } from "date-fns"; | |
import { classNames, isoToUtc } from "../Shared/utils"; | |
import { Habit, HabitType, Progress, Streak, Entry } from "../Shared/types"; | |
import { isWithinInterval } from "date-fns/esm"; | |
import CircularProgressBar from "./CircularProgressBar"; | |
type Prop = { | |
habit: Habit, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SlickWeb.NewsletterSuggestionComponent do | |
use SlickWeb, :live_component | |
def mount(socket) do | |
socket = | |
socket | |
|> assign(:suggestions, []) | |
|> assign(:picked, nil) | |
{:ok, socket} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'objspace' | |
class Foo | |
def self.memo_hash | |
@_memo_hash ||= begin | |
Hash.new(100) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: This is pretty badly written code, I just wrote it as a quick proof for https://dev.to/edisonywh/how-arrays-work-the-way-arrays-work-3bpg | |
# To get the growth rate of the array, just look at the jump in memory bytes after every copy. You can see that it's about 1.5~ | |
require 'objspace' # Require this for additional ObjectSpace methods | |
def memory_calculator | |
array = Array.new | |
result = {} | |
100.times do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'pry' | |
require 'nokogiri' | |
require 'terminal-notifier' | |
class FeedService | |
attr_accessor :url | |
attr_accessor :keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
#!/bin/sh | |
echo "\nRunning rubocop 🚓 💨 💨 💨\n" | |
declare -a ERRORS=() | |
for file in $(git diff --cached --name-only | grep -E '.rb') | |
do | |
ERRORS+=("$(rubocop $file | grep -e 'C:' -e 'E:')") | |
done |