Skip to content

Instantly share code, notes, and snippets.

.logo {
background: url("logo.png") no-repeat;
}
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6 / 2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
.logo {
@0xGGGGG
0xGGGGG / arel_duplicates.rb
Created November 10, 2013 11:53
arel duplicates
User
.where(
phone: User
.select('phone, count(phone)')
.group('phone')
.having('count(phone) > 1')
.select{|u| u.phone.present?}
.map(&:phone) )
.select([:id, :phone, :email, :fullname])
.includes(:items)
@0xGGGGG
0xGGGGG / application_helper.rb
Created August 26, 2013 12:23
render respecting subdomains.
module ApplicationHelper
def render_respecting_subdomain(options = nil, extra_options = {}, &block)
raw render(sanitized_options_from(options, request.subdomain), extra_options, &block)
rescue ActionView::MissingTemplate
raw render(sanitized_options_from(options, "default"), extra_options, &block)
end
def sanitized_options_from(args, subdomain = "")
return args unless subdomain.present?
@0xGGGGG
0xGGGGG / doctest_test.ex
Last active December 18, 2015 21:19
doctest not working for nonmatching function clause.
defmodule ListExtensions do
@moduledoc false
@doc """
Traverses all of the elements in given list
and then sums the result and returns it.
Does not accept types other than list.
### Examples
# Clone rbenv into ~/.rbenv
git clone [email protected]:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL
@0xGGGGG
0xGGGGG / rebazer.sh
Created April 23, 2013 12:08
a bash script to make rebasing default on git-pull
#!/bin/bash
# Makes rebasing default on git-pull
# Run it on the working-git-directory
echo "Existing branch's default action is being updated"
for file in $(find . -type d -name ".git")
do
LENGTH=${#file}
PRPATH="${file:0:LENGTH-4}"
pushd $PRPATH
create new rails app:
$ rails new store_name -d postgresql
in postgres:
$ psql -U postgres
$ create role store_name login createdb;
create databases:
.highlight {
background-color: #efefef;
padding: 7px 7px 7px 10px;
border: 1px solid #ddd;
-moz-box-shadow: 3px 3px rgba(0,0,0,0.1);
-webkit-box-shadow: 3px 3px rgba(0,0,0,0.1);
box-shadow: 3px 3px rgba(0,0,0,0.1);
margin: 20px 0 20px 0;
overflow: hidden;
@0xGGGGG
0xGGGGG / keyword_args_example.rb
Last active December 12, 2015 08:38
keyword arguments is coming with ruby 2.0 . No need to merge stuff!
# In ruby < 2.0 we should implement this on our own.
def something_useful(opts = {})
opts = opts.merge({ overridden_opt: :something, another_overridden_opt: :something_else })
do_something_useful_with(opts[:overridden_opt]) if suitable?(opts[:another_overridden_opt])
end
# In new ruby 2.0 we can implement this behavior easily thanks to keyword_arguments.
@0xGGGGG
0xGGGGG / photo_uploader.rb
Created January 9, 2013 19:13
retina carrierwave uploader snippet
{
:thumb => [142, 106],
:box_iphone => [296, 222],
:box_normal => [219, 164],
:box_large => [450, 340],
:normal => [600, 450]
}.each do |name, dimensions|
retina_name = "#{name}_retina"