Skip to content

Instantly share code, notes, and snippets.

View briankung's full-sized avatar

Brian Kung briankung

  • Chicago
View GitHub Profile
@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 💔 ☠

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

@briankung
briankung / youtube2srt.rb
Last active June 7, 2018 22:31 — forked from lsloan/ Convert video subtitles from YouTube XML format to SubRip (.srt)
Convert XML Youtube subtitles to SubRip (srt) from YouTube ID or XML file
# Convert XML Youtube subtitles to SubRip (srt) format
# To download the subtitle in XML, put the code of the Youtube video
# at the end of the next url:
# http://video.google.com/timedtext?hl=en&lang=en&v=
# Usage:
#
# $ ruby youtube2srt.rb [input_filename] [output_filename]
#
# Where input_filename can be either the name of your xml file