This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create new rails app: | |
$ rails new store_name -d postgresql | |
in postgres: | |
$ psql -U postgres | |
$ create role store_name login createdb; | |
create databases: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ChronalCalibration do | |
def calc_result(stream), do: Enum.sum(stream) | |
def find_first_redundant(stream) do | |
Stream.cycle(stream) | |
|> Stream.scan({0, MapSet.new([0])}, &collect_step/2) | |
|> Stream.filter(&redundant?/1) | |
|> Stream.map(fn {elem, _} -> elem end) | |
|> Enum.take(1) | |
|> Enum.at(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule InventoryManagement.Checksum do | |
def checksum(stream) do | |
stream | |
|> Stream.map(&String.trim/1) | |
|> Stream.map(&count_occurances/1) | |
|> Enum.reduce([two: 0, three: 0], &collect_each/2) | |
|> Enum.reduce(1, fn {_, val}, acc -> val * acc end) | |
end | |
defp collect_each([two: item_two, three: item_three], two: two, three: three) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SpoilsOfFabric do | |
def count_overlaps(stream) do | |
stream | |
|> Stream.map(&cleanup/1) | |
|> Stream.map(&to_grid_positions/1) | |
|> Enum.reduce(%{}, &count_positions/2) | |
|> Enum.reduce(0, &count_overlaps/2) | |
end | |
def detect_sacred_fabric(stream) do |