Skip to content

Instantly share code, notes, and snippets.

View pvrt's full-sized avatar

Pavel R pvrt

View GitHub Profile
@klich3
klich3 / iphone-addressbar-gap.html
Created January 25, 2022 12:24
Attach some dom element on the bottom of screen as absolute, triggered to move on resize address bar.
<!--
Author: <Anthony Sychev> (hello at dm211 dot com | a.sychev at jfranc dot studio)
Buy me a coffe: https://www.buymeacoffee.com/twooneone
Untitled-1 (c) 2022
Created: 2022-01-25 20:06:02
Desc: Attach some dom element on the bottom of screen as absolute, triggered to move on resize address bar.
-->
<html>
@pvrt
pvrt / index.haml
Created March 26, 2019 14:07
Product quantity js counter
.counter
.down{:onclick => "decreaseCount(event, this)"} -
%input{:type => "text", :value => "1"}
.up{:onclick => "increaseCount(event, this)"} +
@pvrt
pvrt / rails_models_cheatsheet.md
Created September 18, 2018 13:53 — forked from romchambe/rails_models_cheatsheet.md
Setup of SSL certificate on Heroku with Gandi

SSL setup: https://vimeo.com/209534466

Creating a join table

rails g migration CreateJoinTableGameInvitesInvitees game_invites invitees

  • Models linked together must be in alphabetical order when naming the migration file
  • The columns can be given any names as long as they are correctly associated in the model file:
has_and_belongs_to_many :invitees, class_name: 'User', foreign_key: 'invitee_id', #the associated column and the alien model
                        join_table: 'game_invites_invitees', #name of the join table
                        association_foreign_key: 'game_invite_id' #the name of the domestic model in the join table
@romchambe
romchambe / rails_models_cheatsheet.md
Last active September 18, 2018 13:53
Setup of SSL certificate on Heroku with Gandi

SSL setup: https://vimeo.com/209534466

Creating a join table

rails g migration CreateJoinTableGameInvitesInvitees game_invites invitees

  • Models linked together must be in alphabetical order when naming the migration file
  • The columns can be given any names as long as they are correctly associated in the model file:
has_and_belongs_to_many :invitees, class_name: 'User', foreign_key: 'invitee_id', #the associated column and the alien model
                        join_table: 'game_invites_invitees', #name of the join table
                        association_foreign_key: 'game_invite_id' #the name of the domestic model in the join table
@marteinn
marteinn / Guardian JWT.md
Last active December 9, 2019 18:46 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

This is a updated guide aimed to support Phoenix 1.3 and Guardian 1.0

Preparing environment

We need to generate secret key for development environment.

mix phx.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf
@rlipscombe
rlipscombe / exwx.exs
Created November 26, 2017 16:08
Using wxWidgets from Elixir
#!/usr/bin/env elixir
defmodule Canvas do
@behaviour :wx_object
@title "Canvas Example"
@size {600, 600}
def start_link() do
:wx_object.start_link(__MODULE__, [], [])
@mankind
mankind / rails-jsonb-queries
Last active April 17, 2024 12:14
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@mileandra
mileandra / letsencrypt_setup.md
Last active April 9, 2020 19:39
Letsencrypt on Ubuntu 16.04 with Nginx, Rails and Capistrano-Unicorn-Nginx

Install Letsencrypt

Install with apt-get

$ sudo apt-get update    
$ sudo apt-get install letsencrypt

Generate a strong DH

$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Configure nginx

@tomdalling
tomdalling / simple_authentication.rb
Created May 23, 2016 12:26
A simple Sinatra app that demonstrates basic authentication
#!/user/bin/env ruby
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'sinatra', '~> 1.4'
gem 'bcrypt', '~> 3.1'
end
require 'sinatra/base'
@joshrieken
joshrieken / Gulpfile.js
Last active July 10, 2019 15:33
Replacing Brunch with Gulp in Phoenix
// Contains support for: SASS/SCSS, concatenation, and minification for JS and CSS
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var concat = require('gulp-concat');
var compress = require('gulp-yuicompressor');