Skip to content

Instantly share code, notes, and snippets.


Edison Yap edisonywh

View GitHub Profile
View Calendar.tsx
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,
edisonywh / suggestion_component.ex
Created Apr 2, 2021
Suggestion Component (For use with Backoffice)
View suggestion_component.ex
defmodule SlickWeb.NewsletterSuggestionComponent do
use SlickWeb, :live_component
def mount(socket) do
socket =
|> assign(:suggestions, [])
|> assign(:picked, nil)
{:ok, socket}
View ruby_array_memory.rb
# Note: This is pretty badly written code, I just wrote it as a quick proof for
# 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 =
result = {}
100.times do |i|
edisonywh / nightwatch.rb
Last active Sep 20, 2018
Pings `` and send a notification if a keyword matches
View nightwatch.rb
require 'httparty'
require 'pry'
require 'nokogiri'
require 'terminal-notifier'
class FeedService
attr_accessor :url
attr_accessor :keyword
edisonywh / pre-commit
Last active Aug 27, 2018
Run Rubocop in Git's pre-commit hook
View pre-commit
echo "\nRunning rubocop 🚓 💨 💨 💨\n"
declare -a ERRORS=()
for file in $(git diff --cached --name-only | grep -E '.rb')
ERRORS+=("$(rubocop $file | grep -e 'C:' -e 'E:')")