Skip to content

Instantly share code, notes, and snippets.

1) С какими Rails библиотеками(gem-ами) приходилось работать?

Я не сторонник лишних gems. Если необходим какой-либо несистемный функционал (например, state machine), то вместо того, чтобы тянуть в проект какую-то стороннюю OpenSource либу (которая вместе с нужным функционалом добавляет ненужный потайной функционал "магического характера"), я лучше потрачу тоже самое время на разработку собственной библиотеки, которая может уместиться в 1-3 класса, чем разбираться в коде и в случае багов выяснять, где проблема: "у нас или у них там в геме?". Либо выдеру из гема нужный мне код без лишнего.

Ответ на вопрос:

  • rspec
  • composite_primary_keys
  • omniauth (omniauth-instagram, omniauth-vkontakte, omniauth-google-oauth2)
@marcostolosa
marcostolosa / addCron.md
Last active April 18, 2019 13:25
Create a Cron Job Using Bash (Shell Script) Automatically Without Interactive Editor

Adding a Cron Job via Shell Script

#write out current crontab
crontab -l > mycron

#echo new cron into cron file
echo "00 09 * * 1-5 echo hello" >> mycron

#install new cron file
@c80609a
c80609a / task.md
Last active January 22, 2020 10:46
Rails Junior+ Test

Задача

Необходимо посчитать количество перепостов новости (а-ля в соцсети).

Прикладная структура новости:

  1. Заголовок
  2. Тело новости
  3. Автор
  4. Время создания
@armw4
armw4 / redux-is-smarter-than-you-think.md
Last active June 19, 2021 20:10
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the knot between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

@solnic
solnic / am_dry_validation_1.rb
Last active May 21, 2022 13:42
dry-validation vs activemodel
require 'benchmark/ips'
require 'active_model'
require 'virtus'
require 'dry-validation'
require 'dry/validation/schema/form'
class User
include ActiveModel::Validations
include Virtus.model
@yesvods
yesvods / gist:51af798dd1e7058625f4
Created August 15, 2015 11:13
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
@chantastic
chantastic / AudioFileStepSelector.coffee
Created January 18, 2015 19:20
My First React Component
# My First React Component
# Added to this Gist for posterity.
# Extracted from https://github.com/ministrycentered/transposr/commit/fa616871914ac16b72d0d1b035a08e01e337bd07
# January 08, 2014
{ div, input } = React.DOM
AudioFileStepSelector = React.createClass
getInitialState: ->
halfSteps: 2
@evincarofautumn
evincarofautumn / git-branch-description.sh
Created October 29, 2014 18:18
Show git branch description
#!/bin/sh
if [ $# -ne 1 ]; then
echo 'Usage: git-branch-description <branch name>' >&2
exit 1
fi
EDITOR='cat' git branch --edit-description "$1" | grep -v '^#'
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@davemo
davemo / app.coffee
Last active March 25, 2020 13:25
Got a .coffee file with JSX? Here's how you can transpile to .js with Reacts JSX parsed.
`/** @jsx React.DOM */`
converter = new Showdown.converter
Comment = React.createClass
render: ->
rawMarkup = converter.makeHtml @props.children.toString()
`<div className="comment">
<h2 className="comment">{this.props.author}</h2>
<span dangerouslySetInnerHTML={{__html: rawMarkup}} />