Skip to content

Instantly share code, notes, and snippets.

View dinjas's full-sized avatar
:shipit:
Alive

Jason Dinsmore dinjas

:shipit:
Alive
  • Battle Ground, WA
View GitHub Profile
// https://webreflection.medium.com/using-the-input-datetime-local-9503e7efdce
Date.prototype.toDatetimeLocal =
function toDatetimeLocal() {
var
date = this,
ten = function (i) {
return (i < 10 ? '0' : '') + i;
},
YYYY = date.getFullYear(),
MM = ten(date.getMonth() + 1),
@dinjas
dinjas / active_admin.js
Created October 23, 2023 15:38 — forked from agarciadelrio/active_admin.js
Getting active_admin panels become collapsable with non-intrusive javascript with jquery
//....add this in app/assets/javascript/active_admin.js
$(function(){
// CONFIGURE PANELS COLLAPSER
$(".panel[data-panel]").each(function(){
var $this = $(this);
var $a = $("<a href='javascript:void(null)'>").on("click",function(event){
$(this).closest(".panel").find(".panel_contents").each(function(){
$(this).slideToggle();
});
$(this).closest("h3").each(function(){
@dinjas
dinjas / clear-sidekiq-jobs.sh
Created February 8, 2023 22:03 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@dinjas
dinjas / docker-pry-rails.md
Created March 31, 2022 14:02 — forked from briankung/docker-pry-rails.md
Using pry-rails with Docker
@dinjas
dinjas / 7300_wsjtx.md
Created January 31, 2022 01:53 — forked from edmondburnett/7300_wsjtx.md
Icom IC-7300 WSJT-X FT8 Settings

IC-7300 digital modes/FT8 setup

WSJT-X Radio tab

  • Serial Port: /dev/cu.SLAB_USBtoUART
  • Baud Rate: 115200
  • Data Bits: Eight
  • Stop Bits: Two
  • Handshake: None
@dinjas
dinjas / cleanup.rake
Created March 9, 2019 21:49
rails rake task to make running common commands consistent - cleanup
# frozen_string_literal: true
namespace :cleanup do
JUMPSTART_TASK = 'cleanup:jumpstart'
ANNOTATE_TASK = 'cleanup:annotate'
ANNOTATE_ROUTES_TASK = 'cleanup:annotate_routes'
RUBOCOP_TASK = 'cleanup:rubocop'
ALL_CLEANUP = [JUMPSTART_TASK,
ANNOTATE_TASK,
ANNOTATE_ROUTES_TASK,
@dinjas
dinjas / measure.rb
Created September 20, 2018 16:59 — forked from camertron/measure.rb
Measure the memory taken by a Ruby object (by Robert Klemme)
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@dinjas
dinjas / speed.rb
Created September 11, 2018 14:57
Tim's cache engine code for his other app It interacts directly with memcache It is the rails side of the php caching engine
# frozen_string_literal: true
module Speed
PAGE_UPDATES = 'SPcstat:all_updates'
VERSION_NAME = "mv|#{Rails.env}"
# the master version increments the 'decimal' portion
# each day (using julian day)
# this automatically invalidates the cache at least once daily

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@dinjas
dinjas / depends_on.js
Created October 3, 2017 23:17 — forked from masonjm/depends_on.js
Show/Hide form fields based on the value in another field.
(function( $ ){
$.fn.dependsOn = function(element, value) {
var elements = this;
var hideOrShow = function() {
var $this = $(this);
var showEm;
if ( $this.is('input[type="checkbox"]') ) {
showEm = $this.is(':checked');
} else if ($this.is('select')) {