Skip to content

Instantly share code, notes, and snippets.

View leifcr's full-sized avatar

Leif Ringstad leifcr

View GitHub Profile
@RISCfuture
RISCfuture / typescript-vue.md
Last active June 3, 2023 05:48
Adding TypeScript to a Rails + Webpacker + Vue project

Adding TypeScript to a Rails + Webpacker + Vue project

These instructions assume you already have a Rails 5.2 project using Webpacker 4 with Vue 2 and Vuex 3. I'll show you how to add TypeScript to the project, and type-safe your Vue components, including single-file components (SFCs). This document will not teach you TypeScript syntax or type theory. It also assumes your code already works without TypeScript. You shouldn't use this article to, for example, get started with Vuex, because I'm leaving out lots of necessary boilerplate code and focusing just on TypeScript changes.

If you want to see a commit on a project accomplishing this migration, visit https://github.com/RISCfuture/AvFacts/commit/666a02e58b4626a074a03812ccdd193a3891a954.

Setup

  1. Run rails webpacker:install:typescript. This should modify config/webpacker.yml and config/webpack/environment.js (leave those changes), add tsconfig.json and config/webpack/loaders/typescript.js (leave those files), and add some other files in `a
@sashko
sashko / _flutter
Created May 9, 2018 14:51
Google Flutter autocompletion plugin for Oh My Zsh
#compdef flutter
#autoload
# in order to make this work, you will need to have Flutter installed
#
# flutter zsh completion, based on adb completion
local -a _1st_arguments
_1st_arguments=(
'analyze:Analyze the project''s Dart code'
@judetucker
judetucker / select2-boostrap-v4-alpha-6.scss
Created April 6, 2017 22:29
Select2 Boostrap 4 Stylesheet
//
// Variables
// --------------------------------------------------
// Variables directly translating Bootstrap variables
// -------------------------
$s2bs-border-radius-base: $border-radius !default;
$s2bs-border-radius-large: $border-radius-lg !default;
$s2bs-border-radius-small: $border-radius-sm !default;
@gerarldlee
gerarldlee / Experimenting with ChromeOS on VirtualBox.md
Last active March 24, 2024 23:51
Installing ChromeOS on VirtualBox using the NeverWare build

Installing ChromeOS on VirtualBox

  1. Download the NeverWare's ChromeOS build from http://www.neverware.com/freedownload

  2. Extract the *.bin.zip

  3. Convert it to VDI. vboxmanage convertdd chromiumos_image.bin chromiumos_image.vdi

  4. mv chromiumis_image.vdi C:\t\v\chromeos\

config.middleware.insert_before ActionDispatch::ParamsParser, ::Rack::Robustness do |g|
g.no_catch_all
# you might need to replace this with JSON::ParserError, depending on your Rails configuration
# or you can catch both...
g.on(MultiJson::ParseError) { |ex| 400 }
g.content_type 'text/plain'
g.body{ |ex| ex.message }
g.ensure(true) do |ex|
env['rack.errors'].write(ex.message)
logger.warn(ex.message)
@taras
taras / gist:3acbed53702ce4e0d106
Created July 4, 2014 02:02
Where to start after you read Ember Guides?
You'll need proper development environment, learn about Ember CLI - https://www.youtube.com/watch?v=hygxGDjhGp8.
You might want to know about more about what's happening under the hood, watch Robert Jackson talk about Ember Magic - https://www.youtube.com/watch?v=OjqcI8KWesk.
Learn more about complex architecture in Ember https://www.youtube.com/watch?v=Kcij9lH2OyM
Learn more about Ember Data - https://www.youtube.com/watch?v=HL2bMjndviE.
You can get lost in the View layer, learn about Events and Actions from Luke Melia - https://www.youtube.com/watch?v=w6__hEUjqaw
@catsby
catsby / puma.rb
Created October 17, 2013 14:28
Example config/puma.rb file
preload_app!
min_threads = Integer(ENV['MIN_THREADS'] || 0)
max_threads = Integer(ENV['MAX_THREADS'] || 5)
threads min_threads, max_threads
workers Integer(ENV['WORKER_COUNT'] || 3 )
on_worker_boot do
ActiveSupport.on_load(:active_record) do
@sj26
sj26 / capybara-jquery_ui.rb
Last active January 30, 2019 14:45
Some helpers for interactive with jQuery UI from Capybara, but only when using Selenium WebDriver.
require "capybara"
# Encapsulate some jQuery UI interactions so we can call them cleanly using Capybara.
module Capybara::JQueryUI
# Find the jQuery UI Autocomplete widget corresponding to this element
def autocompleter
jquery_result(jquery_this(".autocomplete('widget')").first)
end
# Fill in an autocompletable field and accept a completion.
@leifcr
leifcr / leifcr.zsh-theme
Created March 14, 2013 08:48
Oh-my-zsh theme based on "muse". Added green user@machine
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
/* normal flexbox */
.flexbox .flex-container {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: flex;
}
.flexbox .flex-container.vertical {
display: -webkit-flex;
display: -moz-flex;