Skip to content

Instantly share code, notes, and snippets.

Anton Rieder aried3r

Block or report user

Report or block aried3r

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
@ryanb
ryanb / shrine_storage.rb
Created Jan 31, 2018
Swap between file system and in-memory storage for Shrine file uploads with RSpec.
View shrine_storage.rb
# This sets up both a memory store and file system store for Shrine file uploads.
# We use the memory store by default but in cases where you want to test actual
# file uploads you can enable it with `file_upload: true` on a per example basis
require "shrine/storage/memory"
require "shrine/storage/file_system"
# We use a delegator to swap out the storage dynamically
# since the storage hash is duplicated for each uploader
class Shrine::Storage::Dynamic < SimpleDelegator
def initialize(initial, storages)
@JakeWharton
JakeWharton / ShampooRule.java
Last active Jul 8, 2019
Got flaky tests? Shampoo them away with a quick JUnit rule. Apache 2.
View ShampooRule.java
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
@fnando
fnando / Gemfile
Created Feb 17, 2015
PostgreSQL: json vs jsonb benchmark
View Gemfile
source 'https://rubygems.org'
gem 'pg'
gem 'pry-meta'
gem 'activerecord'
View CollapsingTitleLayout.java
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@staltz
staltz / introrx.md
Last active Oct 19, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
View documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@seyhunak
seyhunak / devise_helper.rb
Created Sep 16, 2013
Devise Error Messages Twitter Bootstrap style
View devise_helper.rb
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
@JakeWharton
JakeWharton / dex.sh
Last active Dec 1, 2018
`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH.
View dex.sh
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active Oct 19, 2019
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
View Apple_mobile_device_types.txt
i386 : iPhone Simulator
x86_64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
iPhone5,1 : iPhone 5 (GSM)
You can’t perform that action at this time.