Skip to content

Instantly share code, notes, and snippets.

# Add it in your alias
# usage: bash-record final_gif_name speed:optional cast_file:optional
#
# Requires asciinema and docker.
# Optional to have gifsicle for gif optimization.
#
# Examples:
# bash-record testing-command-x
# bash-record slow-recording-x 2
# bash-record please-faster-x 20 /tmp/slow-recording-x.cast
@erluxman
erluxman / rectangularnotch.dart
Created April 28, 2020 02:28
Rectangular notched Fab
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@tomhicks
tomhicks / plink-plonk.js
Last active July 26, 2024 01:10
Listen to your web pages
@joemusacchia
joemusacchia / ReactCarrierwaveImageUploadBlogPost.md
Last active February 7, 2022 02:46
Upload images with React and the carrierwave Ruby gem for Rails 5

Upload images with React and the carrierwave Ruby gem for Rails 5

I recently attended a 4.5 month, intensive coding bootcamp in Boston, MA called Launch Academy. I spent a lot of time in academic science doing imaging research, so I naturally had an interest in learning how to manipulate images in this new web browser environment. For my capstone project, I created a very simple image editing Rails app where I realized I needed to be able to save/upload images to my database.

Since, through earnest effort, I wanted my app to use React for a single-page experience, and I quickly discovered that my desire to use a React/fetch/carrierwave/fog/Rails strategy was initially difficult to learn. I had to pull information from many sources (StackOverflow, Medium, official docs, other blog posts, course instructors, etc) to develop a method that uses this specific POSTing cycle.

This blog post represents my findings to integrate all these technologies in a modern, seamless

@manfe
manfe / helper.rb
Last active January 14, 2020 10:15
Rails Helper to build Hierachical HTML List
module TreeListHelper
# the collection need to be the root parents
def tree_list(collection)
content_tag(:ul) do
collection.each do |item|
if item.children.any?
concat(
content_tag(:li, id: item.id) do
concat(item.name)
concat(tree_list(item.children))
@hugohernani
hugohernani / ar_model_required_attrs.rb
Created March 11, 2016 17:47
Get Attributes which presence validator was added to a model_(instance|klass)
def required_attributes(obj)
target = obj.class == Class ? obj : obj.class
target.validators.select do |amv|
amv.class == ActiveRecord::Validations::PresenceValidator
end.map(&:attributes).flatten
end
@jarednorman
jarednorman / webpack-rails-1.markdown
Last active May 13, 2020 18:24
Webpack with Rails Part 1

Webpack with Rails Part 1

I don't like Sprockets, but it's the easiest and best choice for lots of Ruby on Rails projects. When looking for a better way to manage my JavaScript assets and an improved developer story, my current tool of choice is webpack. While I wish Rails supported drop-in asset pipelines the way that Phoenix does, it's not hard to use webpack with Rails.

@mlanett
mlanett / rspec_helper.rb
Created September 22, 2014 04:23
Helper to clear redis before/after examples in rspec.
=begin
Include in your rspec config like so:
RSpec.configure do |spec|
spec.include RSpec::RedisHelper, redis: true
end
This helper will clean redis around each example.
=end
@alvarobp
alvarobp / remote_pairing_setup.md
Last active July 29, 2022 20:20
Setting up a remote pair station with SSH + TMUX and/or Reverse SSH Tunnel

Disclaimer: The following examples try to give an overview of the process followed in different scenarios. Some commands were actually written from memory. Some tools might exist simplifying all this. Furthermore, I'm no expert so if anyone ever reads this and knows any improvement, please let me know.

Case 1: Direct access to Pairing Station

Given that the Guest User can access the Pairing Station directly, either because the station is publicly available or because NAT port forwarding can be used, there's only one thing we need to do, give ssh access to the Guest User by adding his ssh public key to our Local User (pair) .ssh/authorized_keys file.

The local user would open up a tmux session with

tmux new-session -s pairing
@loicginoux
loicginoux / gist:5577498
Created May 14, 2013 16:50
paste this into your app/assets/stylesheets/active_admin.css.scss to get Rich editor styling correct in Active Admin
body.active_admin {
.cke_chrome {
width: 76% !important;
overflow: hidden;
}
.cke_dialog_background_cover{
background-color: black !important;
}
}
body.active_admin {