Skip to content

Instantly share code, notes, and snippets.

View eddiesel's full-sized avatar

Eduard Siebert eddiesel

View GitHub Profile
@niksumeiko
niksumeiko / git.migrate
Last active April 30, 2024 12:54
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@sandeepraju
sandeepraju / ttfb.sh
Created July 20, 2016 21:17
curl command to check the time to first byte
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@joaocunha
joaocunha / How To Hide The Select Arrow On Firefox.md
Last active December 10, 2023 13:05
How to hide <select> dropdown's arrow in Firefox when using "-moz-appearance: none;".

This is no longer a bug. I'm keeping the gist for historical reasons, as it helped to get it fixed. Make sure to read the notes by the end of the post.

How to remove hide the select arrow in Firefox using -moz-appearance:none;

TL;DR (or, the fix)

  1. Set -moz-appearance to none. This will "reset" the styling of the element;
  2. Set text-indent to 0.01px. This will "push" the text a tiny bit[1] to the right;
@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@macek
macek / 20101004063749_create_photos.rb
Created October 4, 2010 22:38
How to save uploaded files to your database in Rails
# db/migrate/20101004063749_create_photos.rb
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.string :name, :null => false
t.binary :data, :null => false
t.string :filename
t.string :mime_type
t.timestamps
@maxivak
maxivak / rails-www-redirect-routes
Last active April 28, 2021 12:17
Redirect from WWW to a non-WWW version of site in Rails.details:http://maxivak.com/redirect-from-www-to-a-non-www-version-of-site-in-rails/
Foo::Application.routes.draw do
constraints(host: /^www\./i) do
match '(*any)' => redirect { |params, request|
URI.parse(request.url).tap { |uri| uri.host.sub!(/^www\./i, '') }.to_s
}
end
# other routes
@wvanbergen
wvanbergen / Decoding speed
Created October 5, 2010 08:56
Chunky PNG performance: same benchmarks on Ruby 1.8.7, but added 'require "oily_png"' for a speed boost
---------------------------------------------
ChunkyPNG (0.10.2) decoding benchmark (n=20)
---------------------------------------------
ChunkyPNG OilyPNG
PNG - no filtering ( 1.056832) ( 0.078345)
PNG - UP filtering ( 3.327986) ( 0.078387)
PNG - PAETH filtering ( 7.499367) ( 0.089143)
From RGBA pixelstream ( 0.032571) ( 0.035790)
@akirasosa
akirasosa / gist:6505112
Created September 10, 2013 04:50
force poltergeist to use 'Accept-Language' as "en"
# spec/spec_helper.rb
RSpec.configure do |config|
config.before(:each) do
if Capybara.current_driver == :poltergeist
page.driver.headers = { 'Accept-Language' => "en" }
end
end
end
require 'addressable/uri'
# Source: http://gist.github.com/bf4/5320847
# Accepts options[:message] and options[:allowed_protocols]
# spec/validators/uri_validator_spec.rb
class UriValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
uri = parse_uri(value)
if !uri