Skip to content

Instantly share code, notes, and snippets.

@thedanbob
thedanbob / update-ip.sh
Last active October 24, 2022 11:30
Script to update cloudflare DNS with dynamic IP
#!/bin/sh
domain=REDACTED
json="Content-Type: application/json"
unifi="https://unifi.$domain/api"
unifi_resolve="unifi.$domain:443:10.0.0.2"
unifi_user=REDACTED
unifi_pass=REDACTED
@thedanbob
thedanbob / fix-ipv6.sh
Last active August 15, 2022 13:07
Update IP
#!/bin/bash
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
rc-service dhcpcd restart -q 2>/dev/null
class FoldersController < ApplicationController
include Streamable
def download
@folder = Folder.find(params[:id]) # has_many_attached :files
response.headers['Last-Modified'] = @folder.updated_at.httpdate
zip = ZipStream.open
send_stream(filename: "folder_#{@folder.id}.zip", type: :zip) do |stream|
@folder.files.includes(:blob).each do |file|
@thedanbob
thedanbob / _form.html.erb
Last active November 24, 2021 15:57
Integrating Dropzone with ActiveStorage direct uploads
<%= form_for @album, multipart: true do |f| %>
<div id="dz-container" class="dropzone">
<% @album.photos.includes(:blob).each do |photo| %>
<%= render 'preview', blob: photo, field: 'album[photos]' %>
<% end %>
<div class="fallback">
<%= f.file_field :photos, multiple: true, direct_upload: true %>
</div>
</div>
{"type": "version", "driverVersion": "6.1.1", "serverVersion": "1.0.0-beta.4", "homeId": 3979475331}
{"type": "result", "success": true, "result": {"state": {"controller": {"libraryVersion": "Z-Wave 6.02", "type": 1, "homeId": 3979475331, "ownNodeId": 1, "isSecondary": false, "isUsingHomeIdFromOtherNetwork": false, "isSISPresent": false, "wasRealPrimary": true, "isStaticUpdateController": false, "isSlave": false, "serialApiVersion": "2.1", "manufacturerId": 634, "productType": 1025, "productId": 2, "supportedFunctionTypes": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20, 21, 22, 23, 28, 32, 33, 34, 35, 36, 39, 40, 41, 42, 43, 44, 45, 46, 47, 55, 56, 57, 58, 59, 60, 63, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 85, 86, 87, 88, 94, 95, 96, 97, 98, 99, 102, 103, 120, 128, 144, 146, 147, 152, 161, 180, 182, 183, 184, 185, 186, 189, 190, 191, 208, 209, 210, 211, 212, 238, 239], "sucNodeId": 0, "supportsTimers": false}, "nodes": [{"nodeId": 1, "index": 0, "status": 4, "ready": true, "
<0>2020-07-09T18:14:23.324595+00:00 [06|h1|4|mux_h1.c:2087] h1_recv(): leaving : [B] - h1c=0x5597a5036000(0x00000000) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324617+00:00 [06|h1|4|mux_h1.c:2242] h1_io_cb(): in : [B] - h1c=0x5597a5036000(0x00000000) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324622+00:00 [06|h1|4|mux_h1.c:2102] h1_send(): entering : [B] - h1c=0x5597a5036000(0x00000000) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324629+00:00 [06|h1|4|mux_h1.c:1979] h1_wake_stream_for_send(): in : [B] [MSG_RQBEFORE, MSG_RPBEFORE] - h1c=0x5597a5036000(0x00000000) h1s=0x5597a5095a40(0x00000010) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324634+00:00 [06|h1|4|mux_h1.c:2140] h1_send(): leaving with everything sent : [B] - h1c=0x5597a5036000(0x00000000) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324638+00:00 [06|h1|4|mux_h1.c:2152] h1_send(): leaving : [B] - h1c=0x5597a5036000(0x00000000) ibuf=0@0+0/0 obuf=0@0+0/0
<0>2020-07-09T18:14:23.324646+00:00 [06|h1|4|mux_h1.c:2720] h1_snd_buf(
@thedanbob
thedanbob / application.js
Created January 13, 2020 16:05
Load cocoon JS with webpacker
// app/javascripts/packs/application.js
import 'cocoon'
@thedanbob
thedanbob / cloudSettings
Last active September 4, 2020 02:22
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-04T02:22:49.625Z","extensionVersion":"v3.4.3"}
@thedanbob
thedanbob / cocoon.js
Created March 5, 2019 13:52
Cocoon rewrite in ES6 (WIP)
class Cocoon {
constructor(container, options) {
this.container = this.getNodeFromOption(container, false)
if (!this.container) {
throw new TypeError('Container must be supplied')
}
this.addFieldsLink = this.getNodeFromOption(options.addFieldsLink, container.querySelector('.add_fields'))