Skip to content

Instantly share code, notes, and snippets.

View malina's full-sized avatar
🌴

Alexandr Shumov malina

🌴
View GitHub Profile
@malina
malina / maze.rb
Last active February 8, 2018 17:21
maze_map = %Q(
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓ ▓ ▓
▓ ▓▓▓▓▓▓▓ ▓ ▓ ▓ ▓
▓ ▓ ▓ ▓▓▓ ▓ ▓ ▓
▓ ▓ A ▓ ▓ ▓ ▓ ▓ ▓
▓ ▓ ▓B ▓ ▓ ▓ ▓
▓▓ ▓ ▓▓▓▓▓ ▓▓▓ ▓▓▓
▓ ▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
# frozen_string_literal: true
module TrackStatus
extend ActiveSupport::Concern
StatusDefinition = Struct.new(:default_value, :values, :initialized)
included do
class_attribute :_statuses_definitions, instance_writer: false
require 'httparty'
class FacebookConnectService < BaseService
class ApiError < StandardError; end
attr_reader :fb_user, :login_params, :last_browser, :access_token
attr_writer :user
PROVIDER = 'facebook'.freeze
PROFILE_URL = 'https://graph.facebook.com/v2.8/me?fields=email,name,picture.type(large)&access_token=%{access_token}'.freeze
@malina
malina / Ansible-Vault how-to.md
Created January 23, 2018 09:09 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@malina
malina / task.md
Last active January 8, 2018 07:07
  1. Задание 1. Ближайшая задача
query = <<-SQL
  select users.*,
    (
      select a.id
      from tasks as a
      inner join users as b on b.id = a.user_id
      where a.deadline = (select min(tasks.deadline) from tasks where tasks.deadline < datetime('now') and tasks.user_id = users.id) or
@malina
malina / ROUTER
Created December 30, 2017 05:33
import {Redirect, Route} from 'react-router';
/**
* Class representing a route that checks if user is logged in.
* @extends Route
*/
class AuthRequiredRoute extends Route{
/**
@malina
malina / benchmark.rb
Created December 18, 2017 06:57 — forked from hakanensari/benchmark.rb
PostgreSQL update strategies in and around Rails
require 'active_record'
require 'activerecord-import'
require 'benchmark'
require 'pg'
include ActiveRecord
Base.establish_connection adapter: 'postgresql',
encoding: 'unicode',
pool: 5,
@malina
malina / INSTALLATION.md
Created November 30, 2017 02:15 — forked from DenisIzmaylov/INSTALLATION.md
DigitalOcean Dokku: fresh install with Node.js Environment

DigitalOcean Dokku / Node.js Cloud Environment

Custom recipe to get full Node.js Cloud Environment in DigitalOcean Dokku droplet running from scratch. Yes. Your own Heroku for $5 per month.

I use this gist to keep track of the important configuration steps required to have a functioning system after fresh install.

When you have executed that's all step by step you will get a new working and stable system which is ready to host & serve your Node.js application and databases.

@malina
malina / restore
Last active November 3, 2017 06:39 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
Backup your databases
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore your databases
cat your_dump.sql | docker exec -i your-db-container psql -U postgres