Skip to content

Instantly share code, notes, and snippets.

@pangui
pangui / prevent_double_click.js
Created January 28, 2015 22:06
Prevent double click!
// jQuery plugin to prevent double click
jQuery.fn.preventDoubleClick = function() {
$(this).on('click', function(e){
var $el = $(this);
if($el.data('clicked')){
// Previously clicked, stop actions
e.preventDefault();
e.stopPropagation();
}else{
// Mark to ignore next click
@pangui
pangui / wavelength_to_rgb.rb
Last active January 18, 2017 00:23
Obtain an RGB color based on wavelength
# credits: http://www.physics.sfasu.edu/astro/color/spectra.html
# Calculates an RGB color based on factor betwen 0 (380nm) and 1 (780nm)
def color_by_factor(f)
f = f.to_f
max = 255.0
wl = 380.0 + (780.0 - 380.0) * f
if wl >= 380 and wl <= 440
r = -1.0 * (wl - 440.0)/(440.0 - 380.0)
g = 0.0
b = 1.0
require 'json'
class Person
@age = nil
attr_accessor :json_field, :age
def initialize *args
# useful for Rails ApplicationRecord models
args[0].each{|key, value| self.send("#{key}=".to_sym, value)}
# uncomment next line for inherited classes
# super *args
@pangui
pangui / aws-cloudfront-function-www-to-non-www.js
Created December 1, 2023 22:36
Redirect non-www to www url in AWS CloudFront
// Create function in
// cloudfront /
// functions
// Create distribution in
// cloudfront /
// distributions
// Associate function to distribution in
// cloudfront /
// distributions /
// YOUR_DIST /
@pangui
pangui / VSCodeUserSettings.json
Created April 6, 2024 00:14 — forked from berndverst/VSCodeUserSettings.json
VS Code: Override Terminal Colors with Solarized Dark regardless of Theme
{
"workbench.colorCustomizations": {
"terminal.foreground": "#839496",
"terminal.background": "#002833",
"terminal.ansiBlack": "#003541",
"terminal.ansiBlue": "#268bd2",
"terminal.ansiCyan": "#2aa198",
"terminal.ansiGreen": "#859901",
"terminal.ansiMagenta": "#d33682",
"terminal.ansiRed": "#dc322f",