Skip to content

Instantly share code, notes, and snippets.

deliro / Dockerfile
Last active Apr 17, 2020
python alpine lxml image example
View Dockerfile
FROM python:3.7-alpine
COPY . .
RUN apk add --update --no-cache --virtual .build-deps \
g++ \
python-dev \
libxml2 \
libxml2-dev && \
ypresto / safari-11-file-xhr-workaround-2.js
Last active Sep 6, 2018
iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround for rails-ujs / jquery_ujs
View safari-11-file-xhr-workaround-2.js
// iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround.
// This should work with every modern browser which supports ES5 (including IE9).
document.addEventListener('ajax:before', function(e) {
var inputs ='input[type="file"]:not([disabled])')
inputs.forEach(function(input) {
if (input.files.length > 0) return
input.setAttribute('data-safari-temp-disabled', 'true')
anlek / application.scss
Last active Apr 30, 2020
My current work around for simple_form and Bootstrap 4 beta to work together (till simple_form allows input fields to have `is-invalid` set on it on error - see
View application.scss
// Fix for validations on simple form
// Need to import bootstrap functions and mixins if you want to dynamically set colors
// Otherwise replace theme-color... with hex color
@import 'bootstrap/functions';
@import 'bootstrap/variables';
@import 'bootstrap/mixins';
.has-invalid {
.invalid-feedback {
briankung /
Last active May 6, 2021
Using pry-rails with Docker

First, add pry-rails to your Gemfile:

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

rmm5t /
Last active Feb 19, 2021
How to properly introduce a new counter_cache to an existing Rails project.

Fast/efficient approach:

-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id =")
   -> 1.3197s

Slow/naïve approach:



jenkins_url + /api/json?tree=jobs[name,color]


jenkins_url + /job/${job_name}/api/json?tree=builds[number,status,timestamp,id,result]

last build

View gist:3698476
* WordPress Query Comprehensive Reference
* Compiled by luetkemj -
* Source:
$args = array(
bkimble / gist:1365005
Last active Feb 8, 2021
List local memcached keys using Ruby
View gist:1365005
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []