Skip to content

Instantly share code, notes, and snippets.

View af23me's full-sized avatar
👋

Evghenii M af23me

👋
View GitHub Profile
#
# Proof of concept - import maps with JSX transpilation. Can trivially
# be extended to TypeScript and all the languages currently supported
# with Sprockets.
#
# There are two parts to this:
# * Have `find_javascript_files_in_tree` in importmap-rails to not only
# find JS files, but also files that can be transpiled to JS.
# * Add sprockets JSX transformer, making use of esbuild
#
@zmts
zmts / tokens.md
Last active June 25, 2024 12:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@naumov
naumov / rpush_apns2.rb
Last active March 12, 2017 21:40
rpush apns 2 http/2 example
app = Rpush::Apns2::App.new
app.name = "ios_app"
app.certificate = File.read("/path/to/cert/cert.pem")
app.environment = "production"
app.connections = 1
app.save!
Rpush.embed # to deliver in console on notification save
n = Rpush::Apns2::Notification.new
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@workgena
workgena / cooke.js
Created October 2, 2015 10:27
cooke.js
/**
*
* Usage:
* Create/Update: Cookie.set("username", "John", 90);
* Read: Cookie.get("username");
* Destroy: Cookie.delete("username");
*
*/
var Cookie = {
set: function (name,value,days) {
@gmontard
gmontard / domain.rb
Last active October 20, 2023 21:44
Rails dynamic domain and subdomain routes constraint
# -*- encoding : utf-8 -*-
class Domain < ActiveRecord::Base
after_save :reload_routes
def reload_routes
if self.domain_changed?
REDIS.set("rails_routes_ts", "expired")
end
end
@camertron
camertron / measure.rb
Created June 15, 2012 22:48
Measure the memory taken by a Ruby object (by Robert Klemme)
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@h3h
h3h / rubify_regexp.rb
Created April 6, 2012 18:38
Perl to Ruby Regular Expression Conversion
POSSIBLE_OPTIONS = "[misxp]"
def rubify_regexp(l)
re = l.gsub(/\(\?(#{POSSIBLE_OPTIONS}*)(?:-(#{POSSIBLE_OPTIONS}*))?:/) do |_|
enabled = $1
disabled = $2
# Perl's `s` option is `m` in Ruby
if enabled.include?('s') && !enabled.include?('m')
enabled.sub!('s', 'm')
else
@mathiasbynens
mathiasbynens / toggleAttr() jQuery plugin
Created February 8, 2010 21:20
toggleAttr() jQuery plugin
/*!
* toggleAttr() jQuery plugin
* @link http://github.com/mathiasbynens/toggleAttr-jQuery-Plugin
* @description Used to toggle selected="selected", disabled="disabled", checked="checked" etc…
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
jQuery.fn.toggleAttr = function(attr) {
return this.each(function() {
var $this = $(this);
$this.attr(attr) ? $this.removeAttr(attr) : $this.attr(attr, attr);