Skip to content

Instantly share code, notes, and snippets.

View briankung's full-sized avatar

Brian Kung briankung

  • Chicago
View GitHub Profile
@briankung
briankung / 00.md
Last active May 25, 2022 17:11
[RFC] Forcing GitHub Gists into a blog-shaped hole

Well, I didn't know this was going to be as hard as it turned out to be, but sometime yesterday I decided that I didn't really want to manage a backend and GitHub Gists were where my technical thoughts ended up, anyway (and I didn't want to handle embeds, either) so why not just hit up Gists for my tech blog? That way, I'd get syntax highlighted embeds, comments, version management, and more.

As with a lot of technical things, it was much more difficult than I gave it credit for at first, mostly because of embeds and the CORS policy on GitHub Gists.

The first step was to get my GitHub Pages running locally, which I did with this convenient python3 one-liner: python -m http.server 8000. Loading up http://localhost:8000/ gave me a look at my static files. I set up a barebones html file with some script tags for the majority of the logic.

I knew I could access the GitHub Gists through some sort of [API], but I wasn't sure what I got with it. Shouldn't be a problem, right? Sure enough, it was as easy as hi

@briankung
briankung / deleteMediumCrap.js
Last active May 4, 2018 16:00
Delete Medium crap bookmarklet
// This deletes the giant header, the share bar on the left, and the bar on the bottom on Medium sites.
// Create a new bookmark and copy either of the following as the "location" of the bookmark
javascript:void(
[
...document.querySelectorAll('.metabar, .js-stickyFooter, .postActionsBar, aside')
].forEach(el => el && el.remove())
)
// Or in one line:
require 'benchmark'
Benchmark.bm do |x|
arr = Array.new(1_000_000) { rand(1...9) }
x.report { 500.times { arr.uniq } }
x.report { 500.times { arr & arr } }
end
@briankung
briankung / remove-redundant-results.js
Created January 30, 2018 17:25
Removes redundant craigslist results from a search based on title
const reducer = (resultTitles, result) => {
let title = result.querySelector('.result-title').innerText
resultTitles.includes(title) ? result.remove() : resultTitles.push(title)
return resultTitles
}
[...document.querySelectorAll('li.result-row')].reduce(reducer, [])
@briankung
briankung / 00-toggle-click-rm.js
Last active January 22, 2018 17:35
Firefox bookmarklet for toggling element deletion on click - copy into Firefox bookmark to fuck shit up
javascript:void(
(
(document.fuckShitUp === undefined)
&&
(document.addEventListener('click', (e) => {
if (document.fuckShitUp) { e.preventDefault(), e.target.remove() }
}))
), (
document.fuckShitUp = !document.fuckShitUp
)
@briankung
briankung / parent.vue
Created December 22, 2017 18:02
This is not a good idea, but it's cool
<template>
<ToggleableFields :fields="toggleableFields" />
</template>
<script>
import ToggleableFields from 'checkout/address/toggleable_fields.vue'
export default {
@briankung
briankung / yoshida.rb
Last active November 19, 2017 04:13
Debugging the yoshida growth curve
YI = 1.6968467
B1 = -0.1915674
C = -1.8162469
def yoshida(i)
C + YI / (1 + B1 * (i ** (-C)))
end
(1..6).step(0.1).each do |i|
puts "#{i}:\t\t\t\t#{yoshida(i)}"
@briankung
briankung / oi.js
Created October 12, 2017 23:52
oi.js from PoC||GTFO
function millis() {
return Date.now();
}
function flip_coin() {
n = 0;
then = millis() + 1;
while (millis() <= then) {
n = !n;
@briankung
briankung / Signal 💔 ☠.md
Created September 19, 2017 01:37
Signal 💔 ☠

❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️