Skip to content

Instantly share code, notes, and snippets.

💎
Ruby

ArtOfCode ArtOfCode-

💎
Ruby
Block or report user

Report or block ArtOfCode-

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View qpixel_schema.sql
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,
View activerecord_relation.rb
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 Sep 13, 2018
WCAG 2.0 contrast ratio implementation in JavaScript/ES6
View contrast_checker.js
/**
* 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 Mar 19, 2018
SO election placing data
View ballots.txt
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
View keybase.md

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:

View keybase.md

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:

View csslib.js
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 = "";
View smokey_sidebar.user.js
// ==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 Nov 9, 2015
An analysis script for bad flags on SO, when given a list of bad flags one-per-line in bad_flags.dta.
View analyse_flags.py
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:
You can’t perform that action at this time.