Skip to content

Instantly share code, notes, and snippets.

scss:
enabled: false
ruby:
config_file: .ruby-style.yml
javascript:
config_file: .jshintrc
@urbanautomaton
urbanautomaton / build_stubbed.rb
Created June 23, 2016 12:36
actually, factory_girl is extremely good
RSpec.describe 'FactoryGirl.build_stubbed' do
let(:stubbed_model) { FactoryGirl.build_stubbed(:step_progress) }
it 'doesnt allow #save' do
expect {
stubbed_model.save
}.to raise_error RuntimeError, /stubbed models are not allowed to access the database/
end
it 'doesnt allow #update_attributes' do
@urbanautomaton
urbanautomaton / copies_to_log.sh
Created July 6, 2016 19:01
appending script output to a logfile
#!/usr/bin/env bash
exec 1> >(tee -a somefile.log) 2>&1
echo "hello"
@urbanautomaton
urbanautomaton / readme.markdown
Last active July 18, 2016 15:32
Username tab-completion for mynewsdesk-git-pair

If you use mynewsdesk-git-pair to manage pairing authors in git, add the following snippet to your .bashrc to enable tab completion of pairing author names.

_git_pair () {
  __gitcomp_nl "$(git config --get-all git-pair.authors | sed 's/\([^ ]*\).*/\1/')"
}

Prerequisites

@urbanautomaton
urbanautomaton / benchmark.rb
Last active February 21, 2018 21:03
Perf analysis of `Performance/HashEachMethods` cop
require 'securerandom'
require 'benchmark/ips'
hash = {}
1000.times do
hash[SecureRandom.uuid] = SecureRandom.uuid
end
array = hash.to_a
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('Range#include? (int)') do
(1..10_000).include?(5_000)
end
x.report('Range#cover? (int)') do
(1..10_000).cover?(5_000)
end
$ yarn check
yarn check v1.5.1
warning "babel-traverse#globals@^9.0.0" could be deduped from "9.18.0" to "globals@9.18.0"
error "hypernova-react#react@^0.14 || ^15 || ^16" doesn't satisfy found match of "react@16.3.0-alpha.1"
error "hypernova-react#react-dom@^0.14 || ^15 || ^16" doesn't satisfy found match of "react-dom@16.3.0-alpha.1"
error "react-autosize-textarea#react@^0.14.0 || ^15.0.0 || ^16.0.0" doesn't satisfy found match of "react@16.3.0-alpha.1"
error "react-autosize-textarea#react-dom@^0.14.0 || ^15.0.0 || ^16.0.0" doesn't satisfy found match of "react-dom@16.3.0-alpha.1"
warning "react-big-calendar#prop-types@^15.5.8" could be deduped from "15.6.0" to "prop-types@15.6.0"
error "react-big-calendar#react@^15.3.0 || ^16.0.0" doesn't satisfy found match of "react@16.3.0-alpha.1"
error "react-big-calendar#react-dom@^15.3.0 || ^16.0.0" doesn't satisfy found match of "react-dom@16.3.0-alpha.1"
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url.startswith("https://www.example.net/exercise"):
flow.response = http.HTTPResponse.make(
200,
b"exercise-content",
)
elif flow.request.pretty_url.startswith("https://cdnjs.cloudflare.com/ajax/libs/mathjax"):
flow.response = http.HTTPResponse.make(
Viewing your learning
as a learner
I see recommended courses if I have no enrolments
Warning: Failed prop type: The prop `onBeforeFilter` is marked as required in `CourseEnrolmentFilterForm`, but its value is `undefined`.
in CourseEnrolmentFilterForm
in ContextProvider
Warning: Failed prop type: The prop `onFilter` is marked as required in `CourseEnrolmentFilterForm`, but its value is `undefined`.
in CourseEnrolmentFilterForm
in ContextProvider
v1_city v2_city count
Kiev Kyiv 35890
Bangalore Bengaluru 31071
Central District Central 25702
Sao Paulo São Paulo 25153
Mexico Mexico City 23647
Bogota Bogotá 22802
Abuja Suleja 13848
Rio De Janeiro Rio de Janeiro 13840
Saint Petersburg St Petersburg 13379