Skip to content

Instantly share code, notes, and snippets.

View Bighamster's full-sized avatar

Vyacheslav Podgornyy Bighamster

  • Moscow, Russia
View GitHub Profile
@Bighamster
Bighamster / jquery-cleave.js
Last active February 26, 2020 15:04
jquery-cleave.js
//
// How to use:
//
// $('#price,#sum').cleave({ numeral: true, numeralThousandsGroupStyle: 'thousand', autoUnmask: true});
//
// or use pre-defined sets:
//
// $('#price').cleave('money');
// $('#date_at').cleave('date');
// $('#qty').cleave('integer');
/**
*
* for BootstrapTable v.1.12.1
*
* small plugin [multiple-select-rows = 'true'] to select/deselect rows with Ctrl & Shift keys
*
*/
(function($) {
'use strict';
@Bighamster
Bighamster / add_images.rb
Last active March 11, 2021 04:07
Using a join model to annotate Active Storage blobs with custom data
Project.first.images.attach(io: File.open(filename), filename: filename, content_type: 'image/jpg')
@Bighamster
Bighamster / capybara cheat sheet
Created June 19, 2018 09:44 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@Bighamster
Bighamster / wait_until.rb
Created June 19, 2018 10:01 — forked from metaskills/wait_until.rb
Never sleep() using Capybara!
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
click_link 'My HomeMarks'
within '#login_area' do
fill_in 'email', with: 'will@not.work'
fill_in 'password', with: 'test'
@Bighamster
Bighamster / 00_Rails-binstubs-vs-Bundler-binstubs.md
Created June 27, 2018 09:10 — forked from stevenharman/00_Rails-binstubs-vs-Bundler-binstubs.md
Rails' binstubs vs. Bundler binstubs - incompatibility and breaking changes, maybe?

Rails' binstubs vs. Bundler binstubs

There's an incompatibility in the Rails vs Bundler-generated bin/bundle binstub. Futher, other Bundler-generated binstubs (e.g., bin/rspec) generated by older versions of Bundler don't play well with those generated by Bundler v1.16.

The Binstubs and versions.

bin/rspec

The older rspec-old.rb was generated by an older version of Bundler.

@Bighamster
Bighamster / javascript.js
Created December 11, 2019 15:03 — forked from chaintng/javascript.js
Encryption Decryption Javascript and Ruby
// IDEA FROM: https://stackoverflow.com/questions/33929712/crypto-in-nodejs-and-ruby
var crypto = require('crypto'),
algorithm = 'aes-256-cbc',
key = 'SOME_RANDOM_KEY_32_CHR_123456789', // 32 Characters
iv = "0000000000000000"; // 16 Characters
function encrypt(text){
var cipher = crypto.createCipheriv(algorithm,key,iv)
var crypted = cipher.update(text,'utf-8',"base64")
@Bighamster
Bighamster / access.svelte
Created March 5, 2020 21:05 — forked from NetOpWibby/access.svelte
Sapper session handling (creation and updating). Idk if this is the best way of doing things but at least it *works*. Feel free to scrutinize this code and let me know all the ways it sucks.
<script>
// import
import { onMount } from "svelte";
// util
import { metadata } from "~util";
// redirect
onMount(() => {
// `location.replace` forces a hard refresh in the browser,
@Bighamster
Bighamster / tokens.md
Created March 25, 2020 06:20 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 21.10.2019

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

Например после аутентификации юзер sasha получает право обращатся и получать от ресурса "super.com/vip" некие данные. Во время обращения юзера sasha к ресурсу vip система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)

@Bighamster
Bighamster / generate-ssh-key.sh
Created January 23, 2024 15:48 — forked from denisgolius/generate-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa