Skip to content

Instantly share code, notes, and snippets.

View obliviusm's full-sized avatar
🏠
Can't work from home because of russians

Misha Sebalo obliviusm

🏠
Can't work from home because of russians
View GitHub Profile
@obliviusm
obliviusm / postgresql_configuration_on_mac_for_rails.md
Created June 14, 2018 09:33 — forked from p1nox/postgresql_configuration_on_mac_for_rails.md
PostgreSQL configuration without password on Mac for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

Go to Postgre Download Site

Install Postgre gem

/Gemfile

// app/assets/javascripts/modals.js
$(function() {
const modal_holder_selector = '#modal-holder';
const modal_selector = '.modal';
$(document).on('click', 'a[data-modal]', function() {
const location = $(this).attr('href');
// Load modal dialog from server
$.get(
# app/controllers/messages_controller.rb
class MessagesController < ApplicationController
respond_to :html, :json
def new
@message = Message.new
respond_modal_with @message
end
<%# app/views/layouts/_header.html.erb %>
<%= link_to 'Add Message', new_message_path, class: 'btn btn-outline-success my-2 my-sm-0', data: { modal: true } %>
<%# app/views/messages/_form.html.erb %>
<%= simple_form_for(@message, remote: request.xhr?, html: { data: { modal: true } }) %>
defmodule ShepherdHeadTail do
def count_sheeps([]), do: 0
def count_sheeps(sheeps) do
[head | tail] = sheeps
count_sheeps(tail) + (if head, do: 1, else: 0)
end
end
defmodule ShepherdAccumulator do
defmodule TestShepherd do
use ExUnit.Case
import Shepherd, only: [count_sheeps: 1]
test "work for some examples" do
assert count_sheeps([]) == 0
assert count_sheeps([true]) == 1
assert count_sheeps([true, false]) == 1
assert count_sheeps([false, false]) == 0
assert count_sheeps(
defmodule Shepherd do
def count_sheeps(sheeps) do
# TODO: for Elixir only true/false values can be presented the in sheeps list
end
end
@obliviusm
obliviusm / elixir_data_types.md
Last active November 25, 2017 16:27
My elixir cheetsheet
Data structures
  • immutable
List
[1,2,:a,"b"]
  • IS: linked list
  • cheap to work with the start of the list CRUD
  • expensive to work with the end CRUD
cd android && bundle exec fastlane android beta