Skip to content

Instantly share code, notes, and snippets.

@ChuckJHardy
ChuckJHardy / example_activejob.rb
Last active March 3, 2024 20:10
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
#
# install daemon preconditions
#

include_recipe "apt"

mysql_root_password = "change me"
mysql_port = "3306"
wordpress_db = "wordpressdb"
@s2t2
s2t2 / text_reader.rb
Created April 12, 2015 03:46
reads text from a public github repository
require 'github_api'
github = Github.new
dir = github.repos.contents.get :user => 's2t2', :repo => 'text', :path => '/'
files = dir.map{|f|
github.repos.contents.get :user => 's2t2', :repo => 'text', :path => f.path.to_s
}
@c-lliope
c-lliope / money.rb
Created March 27, 2015 05:21
Reports on the status of your goals in Simple, and catches them up if necessary
require 'capybara/poltergeist'
require 'ruby-progressbar'
session = Capybara::Session.new(:poltergeist)
session.visit("https://bank.simple.com/signin")
session.fill_in("username", with: "USERNAME")
session.fill_in("password", with: "PASSWORD")
session.click_on("Sign in")
@brattonc
brattonc / README.md
Last active November 20, 2023 17:14
D3 Liquid Fill Gauge

Liquid Fill Gauge v1.1 - 7/14/2015

Changes:

  • Added support for updating the gauge value after loading is complete. The loadLiquidFillGauge method now returns an object with an update method which allows the gauge value to be changed. Click any of the gauges above to randomly update their value.

Configurable features include:

  • Changeable min/max values.
  • All colors.
@obfusk
obfusk / break.py
Last active May 1, 2024 20:32
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@igrigorik
igrigorik / bq.sql
Last active January 17, 2020 05:23
/* count of issues opened, closed, and reopened on 2019/01/01 */
SELECT event as issue_status, COUNT(*) as cnt FROM (
SELECT type, repo.name, actor.login,
JSON_EXTRACT(payload, '$.action') as event,
FROM `githubarchive.day.20190101`
WHERE type = 'IssuesEvent'
)
GROUP by issue_status;
@kosamari
kosamari / index.html
Last active March 27, 2016 03:23
D3.js Hanabi
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<style>
body {
background: #222;
color:#fff;
font-family: "Helvetica Neue", Helvetica, sans-serif;
@koistya
koistya / DefaultLayout.jsx
Last active July 1, 2021 16:05
React.js (ReactJS) Page and Layout components. For a complete sample visit https://github.com/kriasoft/react-starter-kit and http://reactjs.kriasoft.com (demo)
/**
* Page layout, reused across multiple Page components
* @jsx React.DOM
*/
var React = require('react');
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
var Navigation = require('../components/Navigation.jsx');
var DefaultLayout = React.createClass({
@mlanett
mlanett / rails http status codes
Last active May 3, 2024 04:15
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing