Skip to content

Instantly share code, notes, and snippets.

View briankung's full-sized avatar

Brian Kung briankung

  • Chicago
View GitHub Profile
@briankung
briankung / binary to float converter.rb
Created June 29, 2019 19:00
binary to float converter
class String
def prettyb
self.chars.reverse.each_slice(4).map(&:join).join("_").reverse
end
def floatify
string = self.gsub('_', '')
if string.length % 16 != 0
raise RuntimeError, "must be a single or a double precision float"
@briankung
briankung / PlayRustBookmarklet.js
Created June 27, 2019 21:40
Play Rust! Copies selected text into the Rust playground at https://play.rust-lang.org/
javascript:void(
(function() {
window.open(
`https://play.rust-lang.org/?code=${encodeURIComponent(
window.getSelection().toString()
)}`,
"_blank"
);
})();
)
@briankung
briankung / Vaccine safety and efficacy.md
Created June 1, 2019 17:28
Vaccine safety and efficacy

I am in the midst of an argument about vaccine safety and efficacy so I have compiled a list of meta analyses detailing both:

SAFETY

Immunogenicity and safety of pandemic influenza A (H1N1) 2009 vaccine: systematic review and meta‐analysis - Yin - 2011 - Influenza and Other Respiratory Viruses - Wiley Online Library https://onlinelibrary.wiley.com/doi/full/10.1111/j.1750-2659.2011.00229.x

  • "We included 16 articles in the meta‐analysis, covering 17,921 subjects...Two serious (BK note: 2/17,921 == 0.01%) vaccination‐associated adverse events were reported, both of which resolved fully. No death or case of Guillain–Barré syndrome was reported. The pandemic influenza (H1N1) 2009 vaccine, with or without adjuvant, appears generally to be seroprotective after just one dose and safe among healthy populations aged ≥36 months; very young children (6–35 months) may need to receive two doses of non‐adjuvanted vaccine or one dose of AS03A/B‐adjuvanted product to achieve seroprotection."

Immunogenicity and safety

@briankung
briankung / activerecord vs arel command comparison.mysql
Created April 24, 2019 02:56
ActiveRecord vs Arel command comparison
-- Story.base.positive_ranked.joins(:taggings).where(taggings: { tag_id: tags.map(&:id) })
EXPLAIN SELECT `stories`.*
FROM `stories`
INNER JOIN `taggings`
ON `taggings`.`story_id` = `stories`.`id`
WHERE `stories`.`merged_story_id` IS NULL
AND `stories`.`is_expired` = false
AND ( ( Cast(upvotes AS signed) - Cast(downvotes AS signed) ) >= 0 )
AND `taggings`.`tag_id` = 159;
import { FluentBundle } from 'fluent/compat';
import { negotiateLanguages } from 'fluent-langneg/compat';
const MESSAGES_ALL = {
'pl': `
title = Witaj świecie!
today-is = Dziś jest { DATETIME($date, month: "long", day: "numeric") }.
`,
'en-US': `
title = Hello, world!
@briankung
briankung / 00 - lobsters top level comment search.js
Last active March 29, 2019 02:14
lobste.rs top level comment search using the root level comment input. If you're using the bookmarklet, save it as a bookmark and then click it once when you want to search top-level comments. Otherwise just copy the contents into console.
javacript:void((() => {
const topLevelComments = [...document.querySelectorAll('ol.comments > li > div')].slice(1),
hide = (node) => { node.closest('li').style.display = 'none' },
show = (node) => { node.closest('li').style.display = null },
reset = () => { topLevelComments.forEach(show) };
window.query = (query) => {
// Convenient for using it as an event handler
if (query && query.target) { query = query.target.value }
@briankung
briankung / lobsters new comments.js
Last active January 17, 2026 00:21
Bookmarklet to scroll through lobste.rs comments in order
javascript:void(
(function() {
this.distanceFromTop = (a, b) => {
return Math.sign(a.getBoundingClientRect().top - b.getBoundingClientRect().top);
};
this.setUnreadElements = () => {
document.unreadElements = [...document.querySelectorAll('[class*=unread]')].sort(this.distanceFromTop);
};
@briankung
briankung / Advent of Code.md
Last active December 2, 2018 22:45
Advent of Code 2018
@briankung
briankung / timingattack.rb
Created October 7, 2018 14:51
Timing attack test
# $ gem install benchmark-ips
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("long correct string: ") { "abfhbeufangi" == "abfhbeufangi" }
x.report("long mostly correct string: ") { "abfhbeufangx" == "abfhbeufangi" }
x.report("long incorrect string: ") { "bbfhbeufangi" == "abfhbeufangi" }
x.report("too short: ") { "bbfhbe" == "abfhbeufangi" }
x.report("too long: ") { "abfhbeufangibbfhbe" == "abfhbeufangi" }