Skip to content

Instantly share code, notes, and snippets.

View Thorsson's full-sized avatar
🎯
Focusing

Ivan Turkovic Thorsson

🎯
Focusing
View GitHub Profile
@Thorsson
Thorsson / vim-shortcuts.md
Created December 9, 2022 21:09 — forked from tuxfight3r/vim-shortcuts.md
VIM SHORTCUTS

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
@Thorsson
Thorsson / README.md
Created October 16, 2022 20:26 — forked from subfuzion/README.md
vim/neovim configuration

I recently switched over to neovim (see my screenshots at the bottom). Below is my updated config file.

It's currently synchronized with my .vimrc config except for a block of neovim-specific terminal key mappings.

This is still a work in progress (everyone's own config is always a labor of love), but I'm already extremely pleased with how well this is working for me with neovim. While terminal mode isn't enough to make me stop using tmux, it is quite good and I like having it since it simplifies my documentation workflow for yanking terminal output to paste in a markdown buffer.

These days I primarily develop in Go. I'm super thrilled and grateful for fatih/vim-go,

@Thorsson
Thorsson / a_rails_rspec_checklist\README.md
Created February 13, 2021 13:17 — forked from BideoWego/a_rails_rspec_checklist\README.md
Rails Spec setup checklist, helper and support files

Rails RSpec Checklist

  • Ensure turbolinks is disabled for good measure

    • comment out gem
    • remove from javascript asset pipeline
    • remove from application layout
  • Add the following gems to Gemfile in a development, test group

    • hirb
@Thorsson
Thorsson / README.md
Created November 25, 2020 19:35 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@Thorsson
Thorsson / active_record_marshalable.rb
Created April 2, 2019 14:40 — forked from keichan34/active_record_marshalable.rb
Get Marshal.dump and Marshal.load to load cached association objects ( Whatever.includes(:example_models) ), as well.
module ActiveRecordMarshalable
def marshal_dump
[attributes, self.association_cache, instance_variable_get(:@new_record)]
end
def marshal_load data
send :initialize, data[0]
instance_variable_set :@association_cache, data[1]
instance_variable_set :@new_record, data[2]
end
@Thorsson
Thorsson / redux-orm-normalization.js
Created February 2, 2019 20:57 — forked from markerikson/redux-orm-normalization.js
Redux-ORM nested data normalization
import {fk, many, Model} from 'redux-orm';
class Book extends Model {
static get fields() {
authors: many('Author', 'books'),
publisher: fk('Publisher', 'books'),
}
static parse(data) {
/*
@Thorsson
Thorsson / rds_ri_prices_parser.rb
Created August 15, 2017 09:01 — forked from shinsaka/rds_ri_prices_parser.rb
AWS RDS RI pricing parser
#!/usr/bin/env ruby
require 'json'
def parse(uri)
JSON.parse `curl -s #{uri}`.gsub(/\/\*(?:(?!\*\/).)*\*\//m, '').strip.gsub(/^callback\(/, '').gsub(/\);/, '').gsub(/([a-zA-Z]+[0-9]*):/, '"\1":')
end
puts %w(
platform
@Thorsson
Thorsson / ofPropertyPathChanges.js
Created February 1, 2017 14:26 — forked from jayphelps/ofPropertyPathChanges.js
RxJS observable of property value changes, given an object and property path
function isObject(value) {
// Avoid an old bug in Chrome 19-20
// See https://code.google.com/p/v8/issues/detail?id=2291
const type = typeof value;
return type === 'function' || (!!value && type === 'object');
}
function ofPropertyChanges(obj, key) {
if (isObject(obj) === false) {
return Rx.Observable.return(undefined);
@Thorsson
Thorsson / Gemfile
Created January 17, 2017 15:27 — forked from goncalvesjoao/Gemfile
Changes you need to make in order to make Devise use JWT Header Authentication
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile"
gem 'jwt'
@Thorsson
Thorsson / README.md
Created October 25, 2016 08:46 — forked from pbojinov/README.md
Two way iframe communication

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe