Skip to content

Instantly share code, notes, and snippets.

View ArtOfCode-'s full-sized avatar
💎
Ruby

ArtOfCode ArtOfCode-

💎
Ruby
View GitHub Profile
@ArtOfCode-
ArtOfCode- / faq.md
Last active January 30, 2020 10:24

Frequently Asked Questions

  • Why is this necessary?
    This project was started by a group of Stack Exchange users who were (and are) dissatisfied with the way Stack Exchange is running things, on a number of counts. Essentially, we believe that the goals of a community-oriented product and a for-profit company are fundamentally at odds. The aim of Codidact is to be that truly community-oriented product.

  • How can I get involved?
    See above for links to various communication channels we use. We suggest joining both our forum (for structured

CREATE TABLE `ar_internal_metadata` (
`key` varchar(255) NOT NULL,
`value` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
class ActiveRecord::Relation
# Preload one level a chained association whose name is specified in attribute.
def preload_chain(attribute, collection: nil)
preloader = ActiveRecord::Associations::Preloader.new
preloader.preload(collection || records, attribute.to_sym)
self
end
# Preload all levels of a chained association specified in attribute. Will cause infinite loops if there are cycles.
def deep_preload_chain(attribute, collection: nil)
@ArtOfCode-
ArtOfCode- / contrast_checker.js
Created September 13, 2018 20:10
WCAG 2.0 contrast ratio implementation in JavaScript/ES6
/**
* Get the contrast ratio between two colors specified in RGB, as defined by WCAG 2.0.
* Ex:
*
* getContrastRatio([0, 0, 0], [255, 255, 255]); // => 21 (white vs black, i.e. full contrast)
* getContrastRatio([0, 0, 0], [255, 0, 0]); // => 5.252 (red vs black)
*
* References/resources:
* https://www.w3.org/TR/WCAG20/#contrast-ratiodef
* https://www.w3.org/TR/WCAG20/#relativeluminancedef
@ArtOfCode-
ArtOfCode- / ballots.txt
Created March 19, 2018 00:09
SO election placing data
Election | Results
---------+--------------------------------------------------------------------------------------------------------------------------------------------
2011 | SLaks, Robert Harvey, Tim Post / Kev, jjnguy, Dave DeLong, Paul Dixon, Michael Mrozek, George Stocker
Nov 2011 | Adam Lear, casperOne, BoltClock, NullUserException / jjnguy, Brad Larson, Flexo, George Stocker, Stu Thompson, Jeremy Banks, ircmaxell
2012 | Brad Larson, ThiefMaster, George Stocker / Flexo, Sathya, Dennis, Andrew Barber, slugster, Moshe
2013 | Andrew Barber, Gordon, Flexo, ChrisF / Raghav Sood, animuson, Taryn, Pops, JNK
2014 | Bohemian, Taryn, Siddharth Rout, Mick MacCallum / Jon Clements, Matt, Undo, Raghav Sood, Doorknob
2015 | Martijn Pieters, Jeremy Banks, meagar / Raghav Sood, Ed Cottrell, Jon Clements, deceze, Paresh Mayani, Madara Uchiha
Nov 2015 | Ed Cottrell, josliber, Madara Uchiha / Undo, Thomas Owens, Mureinik, deceze, slugster, rekire
2016 | Aaron Hall, deceze, Bhargav Rao / Andy, Cerb

Keybase proof

I hereby claim:

  • I am artofcode- on github.
  • I am artofcode (https://keybase.io/artofcode) on keybase.
  • I have a public key ASAHgXxJmQzmvNiBQ5iVkouMeUWs4DQsbrmGjU5wcM6RnQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am ArtOfCode- on github.
  • I am artofcode (https://keybase.io/artofcode) on keybase.
  • I have a public key whose fingerprint is 605A 49AF E0F8 F25B 64A1 419C 6233 7BF2 22ED 4669

To claim this, I am signing this object:

window.csslib = {
createStyleSheet: function() {
var el = document.createElement("style");
el.appendChild(document.createTextNode(""));
document.head.appendChild(el);
return el.sheet;
},
addRule: function(sheet, selector, rules) {
var ruleString = "";
// ==UserScript==
// @name Smokey Sidebar
// @desc Adds recent Smokey reports to the sidebar along with feedback buttons.
// @author ArtOfCode
// @version 0.5.12
// @grant none
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/*
// @match *://*.superuser.com/*
// @match *://*.serverfault.com/*
@ArtOfCode-
ArtOfCode- / analyse_flags.py
Last active November 9, 2015 22:44
An analysis script for bad flags on SO, when given a list of bad flags one-per-line in bad_flags.dta.
import sys
def get_list_index(list_obj, item, alternative=None):
try:
return list_obj.index(item)
except:
if alternative is not None:
try:
return list_obj.index(alternative)
except: