Skip to content

Instantly share code, notes, and snippets.

View Bestulo's full-sized avatar

Besto Bestulo

View GitHub Profile
@Bestulo
Bestulo / restartcapy.ts
Created October 28, 2022 13:47
restart capy
import { Application } from "https://deno.land/x/oak@v11.1.0/mod.ts";
const app = new Application();
app.use((ctx) => {
// if receive request to /restart?bot=capy, use `pm2 restart capy`
if (
ctx.request.url.pathname === "/restart" &&
ctx.request.url.searchParams.get("bot") === "capy"
) {
// Works for a max of 50 entries
// Needs to inject jQuery first so you can use .map (Reddit uses Jquery Slim which can't map)
// Just copy and paste the contents of minified jQuery into console, then $ = jQuery
// https://code.jquery.com/jquery-3.5.1.min.js
const idarr = []
$(".entry a.title").map((a, b) => idarr.push(/youtu(?:.*\/v\/|.*v\=|\.be\/)([A-Za-z0-9_\-]{11})/.exec($(b).attr('href'))[1]))
console.log('https://www.youtube.com/watch_videos?video_ids=' + idarr.join(','))
@Bestulo
Bestulo / node-polcomp-flair-counter.js
Created June 11, 2020 16:41
Node.js PoliticalCompassMemes flair counting tool
const rp = require('request-promise')
const fs = require('fs')
const baseUrl = 'https://www.reddit.com/r/PoliticalCompassMemes/.json'
const getPCM = (after = '') =>
rp(baseUrl + (after ? '?after=' + after : after)).then(JSON.parse)
const mergeCounters = (arr1, arr2) => {
if (arr1 && arr2) {
@Bestulo
Bestulo / pinboard.css
Last active January 11, 2020 19:39
pinboard.in custom theme
/* Theme Name: Flat Pinboard */
/* Theme URL: http://tackk.com/flat-pinboard */
/* Version: v1.0.1 */
/* Created by: Dan Klammer */
/* Broswer: Chrome + Stylish Extension */
/*
THEME SOURCE: https://gist.github.com/jfred/c5fe00da60a19ff74999223e9a451586
COLORS INVERTED WITH: https://jalu.ch/coding/css-negative.php
@Bestulo
Bestulo / pinboard.css
Created January 11, 2020 19:36
pinboard.in custom theme
/* Theme Name: Flat Pinboard */
/* Theme URL: http://tackk.com/flat-pinboard */
/* Version: v1.0.1 */
/* Created by: Dan Klammer */
/* Broswer: Chrome + Stylish Extension */
/*
THEME SOURCE: https://gist.github.com/jfred/c5fe00da60a19ff74999223e9a451586
@Bestulo
Bestulo / letter-structure-analysis.md
Created January 9, 2020 01:24
Analysis of AWAI's Letter Structure

Letter Structure Analysis

Examples at the end of this document.

3 rules:

  1. People don't like being sold
  2. People buy things for emotional, not rational, reasons
  3. Once sold, people need to satisfy their emotional decisions with logic
@Bestulo
Bestulo / power-of-one.md
Last active January 9, 2020 01:22
Summary of "The Power of One" by AWAI

Summary of "The Power of One" by AWAI

Content extracted from The Secret Formula for Making Six-Figures from Home --- Writing Letters. Chapter 5 "The Secret To Good Writing".

Mark Morgan Ford writes:

It struck me that readers didn’t want to hear everything I had to say about a topic every time I wrote. They were looking for a single, useful suggestion or idea that could make them more successful.

Power of One:

@Bestulo
Bestulo / material-design-shadows.css
Created May 17, 2019 01:30 — forked from serg0x/material-design-shadows.css
Google material design elevation system shadows as css. Based on https://material.io/design/environment/elevation.html#default-elevations Exported with Sketchapp from the Google material design theme editor plugin "Baseline" theme.
/* Shadow 0dp */
box-shadow: none;
/* Shadow 1dp */
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.14), 0 2px 1px -1px rgba(0,0,0,0.12), 0 1px 3px 0 rgba(0,0,0,0.20);
/* Shadow 2dp */
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.20);
/* Shadow 3dp */
@Bestulo
Bestulo / index.pug
Created March 1, 2019 16:22
Under Construction
- var objects = ['line lineOne', 'line lineTwo', 'line lineThree', 'stand', 'weight', 'cabin', 'arm']
- var n = 0
#content
h1 < building />
p Working day and night!
#outerCraneContainer
.buildings
while n < 5
@Bestulo
Bestulo / cap-all-lines.js
Last active December 26, 2018 01:59
Each line's first letter to uppercase (lines.split('\n').firstToUpper)
const { head, tail, toUpper } = require('ramda')
const text = `det var två ädla konungabarn
som lova varandra sin tro
och den som då skulle svika`
/* =>
Det var två ädla konungabarn
Som lova varandra sin tro
Och den som då skulle svika