Skip to content

Instantly share code, notes, and snippets.

Avatar

Dominick Caponi dcaponi

View GitHub Profile
View aoc.js
import axios from "axios"
import {part1, part2} from "./day6.js"
let input;
let day = process.argv[2];
let url = `https://adventofcode.com/2021/day/${day}/input`
let loginCookie = "<jack your session cookie from the console and stick that in here>";
try {
let res = await axios.get(url, {withCredentials: true, headers:{Cookie: `session=${loginCookie}`}})
View AoC2021Day6.js
let part1 = async (input) => {
let days = 80
let fish = input[0].split(',').map(f => parseInt(f)).sort()
return lifeCycle(fish, days)
}
let part2 = (input) => {
let days = 256
let fish = input[0].split(',').map(f => parseInt(f)).sort()
return lifeCycle(fish, days)
@dcaponi
dcaponi / ProtectedRoute.Svelte
Last active Aug 29, 2021
implementation of route protection component
View ProtectedRoute.Svelte
<script lang="ts">
import Client from "@onelogin/sdk";
import { Route } from 'svelte-routing';
import { accessToken } from './stores';
import Login from '../pages/Login.svelte';
export let path: string;
export let component: any;
@dcaponi
dcaponi / App.Svelte
Last active Aug 29, 2021
basic example of protected routes in svelte
View App.Svelte
<!-- App.svelte -->
<script lang="ts">
import { Router, Link, Route } from "svelte-routing";
import ProtectedRoute from './concerns/ProtectedRoute.svelte';
import Home from "./pages/Home.svelte";
import SecretStuff from "./pages/SecretStuff.svelte";
</script>
@dcaponi
dcaponi / controller.go
Created Aug 11, 2021
pw_less controller
View controller.go
package user
import (
"encoding/json"
"fmt"
"log"
"strings"
"github.com/onelogin/onelogin-go-sdk/pkg/services/users"
@dcaponi
dcaponi / handler.go
Created Aug 11, 2021
pw_less http handler
View handler.go
package user
import (
"errors"
"io/ioutil"
"net/http"
)
type UserHandler struct {
Controller UserController
@dcaponi
dcaponi / email.go
Created Aug 11, 2021
pw_less email sender
View email.go
package email
import (
"fmt"
"net/smtp"
)
type Emailer interface {
Send(to []string, msg string) error
}
@dcaponi
dcaponi / cache.go
Created Aug 11, 2021
pw_less cache.go
View cache.go
package cache
import (
"context"
"log"
"time"
"github.com/go-redis/redis/v8"
)
@dcaponi
dcaponi / main.go
Created Aug 11, 2021
pw_less main.go
View main.go
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/onelogin/onelogin-go-sdk/pkg/client"
@dcaponi
dcaponi / hack-brew.md
Last active Sep 7, 2021
how to make brew formula for your go build.
View hack-brew.md

Create Brew Tap - Because You're Not Cool Enough to be in the Official Brew Club

  1. create a new repository called homebrew-tap-your_app
  2. run git init and put the empty repository in Github
  3. create a new branch and run brew create --tap=USER/REPO --go https://github.com/user/repo/archive/vA.I.P.tar.gz (where A is Major, I is Minor and P is Patch version... obviously 😜) to create a new pre-gen formula in your empty project.
  4. Make sure the url in the pre-gen formula looks like https://github.com/user/repo/archive/refs/tags/vA.I.P.tar.gz
  5. If brew create doesn't already, copy the sha256 that gets stuck in your terminal output in the field for sha256
  6. push that shit and open a PR
  7. AFTER those are done, add the pr-pull label and wait for that action to run - this will add the bottles specified in the test-bot action in tests.yml (you don't have to update those SHAs on your own... dont panic)
  8. If it didn't blow up, you're donezo!