Skip to content

Instantly share code, notes, and snippets.

nelson fernandez kascote

Block or report user

Report or block kascote

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kascote
kascote / spinner.dart
Created Jul 11, 2019
flutter icon spinner
View spinner.dart
//
// https://stackoverflow.com/questions/55431496/font-awesome-spinners-icons-not-spinning-in-flutter
//
// Usage:
// Spinner(
// icon: FontAwesomeIcons.spinner,
// )
//
class Spinner extends StatefulWidget {
final IconData icon;
@kascote
kascote / blob_authenticatable.rb
Created Sep 4, 2018 — forked from dommmel/blob_authenticatable.rb
Devise authentication for Rails' ActiveStorage
View blob_authenticatable.rb
# Rails controller concern to enable Devise authentication for ActiveStorage.
# Put it in +app/controllers/concerns/blob_authenticatable.rb+ and include it when overriding
# +ActiveStorage::BlobsController+ and +ActiveStorage::RepresentationsController+.
#
# Optional configuration:
#
# Set the model that includes devise's database_authenticatable.
# Defaults to Devise.default_scope which defaults to the first
# devise role declared in your routes (usually :user)
#
@kascote
kascote / uglifier.rb
Created Dec 7, 2017
Uglifiers don't return the filename with the error
View uglifier.rb
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
@kascote
kascote / msgbox.js
Created Oct 2, 2017
Replace Rails 5 alert dialog
View msgbox.js
promiseBasedConfirmPopup = new Promise((resolve) => {
// Show a nice popup and resolve to true/false
setTimeout(() => resolve(true), 2000)
})
$("a[data-confirm]").on("confirm", function(evt) {
// evt.target hold the clicked anchor from where
// can be extracted some data to build the popup
@kascote
kascote / dnsmasq
Last active Jul 22, 2017
add TLD to local dnsmask
View dnsmasq
# /etc/NetworkManager/dnsmasq.d/hosts.conf
address=/dev/127.0.0.1
address=/spk/192.168.1.98
address=/nfx/192.168.1.99
address=/spk2/192.168.1.97
@kascote
kascote / sql.sh
Created May 24, 2017
Parse Rails's database.yml and start psql
View sql.sh
#!/bin/bash
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
@kascote
kascote / config.ru
Created Nov 2, 2016
Rails 2.3.x. config.ru to use with passenger for example
View config.ru
# Reference: http://guides.rubyonrails.org/v2.3.11/rails_on_rack.html#rackup
#
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
# Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment'
# Serve static assets from RAILS_ROOT/public directory
# use Rails::Rack::Static
# Dispatch the request
run ActionController::Dispatcher.new
@kascote
kascote / full_text_search.sql
Last active Feb 16, 2016
Postgres Full Text Search
View full_text_search.sql
CREATE TABLE messages (
title text,
body text,
tsv tsvector
);
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
ON messages FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger(tsv, 'english', title, body);
View enumerator_to_json.rb
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|
@kascote
kascote / color_luminance
Created Mar 14, 2015
Calculate Lighter or Darker Hex Colors
View color_luminance
#
# Examples:
# color_luminance("#69c", 0); # returns "#6699cc"
# color_luminance("6699CC", 0.2); # "#7ab8f5" - 20% lighter
# color_luminance("69C", -0.5); # "#334d66" - 50% darker
# color_luminance("000", 1); # "#000000" - true black cannot be made lighter!
#
# based on code from
# http://www.sitepoint.com/javascript-generate-lighter-darker-color/
#
You can’t perform that action at this time.