Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
https://github.com/drop-ice/dear-github-2.0

compwron compwron

💭
https://github.com/drop-ice/dear-github-2.0
View GitHub Profile
namespace :acts_as_paranoid do
desc "Verify that all models using acts_as_paranoid have scopes on their unique indexes and validations"
task lint: :environment do
if Rails.env.test?
currently_probably_buggy_classes_ignored = %w[
# too many things, redacted
]
Zeitwerk::Loader.eager_load_all
errors = []
allows_multiple_deleted = "(deleted_at IS NULL)"
#!/user/bin/env ruby
puts "hi"
my_variable = "hi"
puts my_variable
x = 1
puts x
puts x + 2
names = ["name", "naaaame"]
puts names
data = { name: "name" }
@compwron
compwron / tinytaste.js
Created February 16, 2022 19:05
skillz for tiny taste
1 + 1
console.log("hello")
myFunctionName = () => {console.log("hi")}
myFunctionName()
myFunctionName2 = (x) { return x + 1 }
myFunctionName2(100)
document.body.style.backgroundColor = "red"
window.location.href
@compwron
compwron / LW_draft.txt
Created September 29, 2020 05:47
LessWrong codebase post draft
Notes for a possible blog post about https://github.com/LessWrong2/Lesswrong2 by Oliver Habryka or whoever
I may also use or publish some part of my notes
The codebase has two big tech debts for historical reasons: https://www.mongodb.com/ and https://www.meteor.com/
Typescript is good and helps a lot to make a sturdy codebase. It has also been an essential part of moving away from meteor.
http://vulcanjs.org/ is built on top of meteor, and in fact it helps LW move away from meteor, because it’s an abstraction layer over meteor. Meteor relies on sockets for communication, abstracted via a https://graphql.org/ layer.
@compwron
compwron / slave_in_software_considered_harmful.md
Created June 10, 2020 17:12
slave_in_software_considered_harmful.md

Background

In the world of software development / computer science, there is a technical term "slave" which should be abandoned. This post is intended to be a list of software tools which use "slave" or which have gone through a rename process away from using the word "slave".

More discussion/summary or this topic on Wikipedia

Definitions

@compwron
compwron / live-coding.py
Last active May 21, 2020 15:54
my live-coding answer to some hackerrank problem as I was demoing tech interviewing to a mentee
input = [5,
'Harry',
37.21,
'Berry',
37.21,
'Tina',
37.2,
'Akriti',
41,
'Harsh',
@compwron
compwron / query-counter.py
Created May 8, 2020 22:46
query-counter.py
# USAGE:
# def test_foo:
# stmts = []
# def catch_queries(conn, cursor, statement, a, b, c):
# stmts.append(statement)
# assert most_frequent_queries(...) == ??
def most_frequent_queries(queries, query_count, query_type, query_print_length):
select_sql_statement_groupings = {}
for statement in queries:
@compwron
compwron / relay.py
Created April 5, 2020 05:42
python2 port forward proxy
#!/usr/bin/python
# Thanks https://gist.github.com/gschizas/3731989
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don't Care) license
import socket
import select
import time
@compwron
compwron / extending_sqlite.py
Last active March 28, 2020 21:27
demo of how I make sqlite pretend to be mysql better so we can test code which runs raw sql
# conftest.py
import datetime
from time import strptime
from dateutil import parser
from sqlalchemy import create_engine
def is_test():
"""
@compwron
compwron / _populate_missing_weeks.py
Created February 27, 2020 08:41
code that thankfully we don't need to _populate_missing_weeks
def _populate_missing_weeks(session: Session,
result_dict: List[Dict[str, str]], start_date: str, end_date: str) -> List[Dict[str, str]]:
# result_dict_week_start_dates = list(map(lambda data: data['start'], result_dict))
result_dict_week_start_dates = set(data['start'] for data in result_dict)
for week_start, week_end in _week_starts_between(session, start_date, end_date):
if week_start not in result_dict_week_start_dates:
result_dict.append({
'messages_received_per_patient': Decimal(0),
'start': week_start,
'end': week_end