Skip to content

Instantly share code, notes, and snippets.

View jkriss's full-sized avatar

Jesse Kriss jkriss

View GitHub Profile
def Crop.interesting
puts "WHAT'S IN THE CACHE NOW?"
puts Rails.cache.read("interesting_crops").to_yaml
json_crops = Rails.cache.fetch("interesting_crops", :expires_in => 1.day) do
howmany = 12 # max number to find
interesting_crops = Array.new
Crop.randomized.each do |c|
break if interesting_crops.length == howmany
next unless c.interesting?
interesting_crops.push(c)
@jkriss
jkriss / dansinker.json
Last active December 23, 2015 21:09
@dansinker's glorious rant
[
{
"created_at": "Wed Sep 25 02:50:26 +0000 2013",
"text": "This has been a day.",
"id_str": "382698582274371587"
},
{
"created_at": "Wed Sep 25 02:50:21 +0000 2013",
"text": "That's all. \n\nI didn't intend to go down this path. Glad I did.",
"id_str": "382698557741867008"

Keybase proof

I hereby claim:

  • I am jkriss on github.
  • I am jkriss (https://keybase.io/jkriss) on keybase.
  • I have a public key whose fingerprint is FFFE 99AB E363 7EBE AEC0 A03B 3A8C 3222 4FB2 CC77

To claim this, I am signing this object:

@jkriss
jkriss / fave.js
Created January 7, 2017 05:13
Quick way to generate a solid color data uri (say, for a favicon)
// modified version of https://github.com/CMTegner/favicolor
var size = 1;
var canvas = document.createElement('canvas');
if (typeof canvas.getContext === 'function') {
var ctx = canvas.getContext('2d');
canvas.width = size;
canvas.height = size;
}
@jkriss
jkriss / index.html
Created June 15, 2017 00:44
CTA Aggregator api example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CTA Aggregator API example</title>
</head>
<body>
<pre id="events"></pre>
@jkriss
jkriss / README.md
Last active May 7, 2018 16:19
Simple Google Forms petition

Setup

  1. Make sure your Google Form is set up to save results to spreadsheet
  2. Follow the instructions from Tabletop.js to make the spreadsheet loadable (short version: publish to web, then make it public with link).
  3. Copy the example below (you'll need the tabletop script tag, the embedded javascript below it, and an element with an id for displaying the signers)
  4. Change publicSpreadsheetUrl in the example above to use the share link for your spreadsheet
  5. Change nameField to be the name of the column you want to display
@jkriss
jkriss / index.js
Created January 11, 2019 21:29
Stable anonymized data
const faker = require('faker')
const adler32 = require('adler-32')
faker.seed(adler32.str('[email protected]'))
faker.internet.email() // always returns '[email protected]'
faker.seed(adler32.str('[email protected]'))
faker.internet.email() // always returns '[email protected]'
function createObjects (acc, p) {
// rel="next" => 1: rel 2: next
var m = p.match(/\s*(.+)\s*=\s*"?([^"]+)"?/)
if (m) acc[m[1]] = m[2]
return acc
}
function parseLink(link) {
try {
var m = link.match(/<?([^>]*)>(.*)/)
@jkriss
jkriss / gist:5c74a285c8f2479fda4b79cc6ca4ef44
Created June 29, 2020 19:44
list flat dependencies from package.json
cat pacakge.json | jq -r '.dependencies|keys|join(" ")'
@jkriss
jkriss / index.html
Last active July 3, 2020 06:13
Template stamping
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>template stamping</title>
</head>
<body>
<div id=one></div>
<div id=two></div>