Skip to content

Instantly share code, notes, and snippets.

View huhn511's full-sized avatar
🐔
🤖

huhn511

🐔
🤖
View GitHub Profile
@huhn511
huhn511 / storage.yml
Last active December 15, 2018 15:41
Declare a Google Cloud Storage service in config/storage.yml:
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
@huhn511
huhn511 / model.rb
Last active December 15, 2018 16:14
Custom validation method to validate correct image types
has_one_attached :image
validate :image_type
private
def image_type
if image.attached? == false
errors.add(:image, "is missing!")
end
@huhn511
huhn511 / _form.html.erb
Last active December 16, 2018 22:13
administrate trix editor field views app/views/fields/trix_field
<div class="field-unit__label">
<%= f.label field.attribute %>
</div>
<div class="field-unit__field">
<%= f.hidden_field field.attribute, id: field.attribute %>
<trix-editor input="<%= field.attribute %>"></trix-editor>
</div>
require "administrate/field/base"
class TrixField < Administrate::Field::Base
def to_s
data
end
end
<template>
<div>
<div class="info" style="height: 15%">
<span>Center: {{ center }}</span>
<span>Zoom: {{ zoom }}</span>
<span>Bounds: {{ bounds }}</span>
</div>
<l-map
style="height: 400px; width: 400px"
:zoom="zoom"
@huhn511
huhn511 / esp8266_connect_to_wlan.ino
Last active April 24, 2019 17:06
ESP8266 connec to wlan
#include <ESP8266WiFi.h>
const char* ssid="<YOUR SSID>";
const char* password="<YOUR PASSWORD>";
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
@huhn511
huhn511 / esp8266_NeoPixel_example.ino
Last active April 25, 2019 10:44
Light example with NeoPixel and ESP8266
#include <Adafruit_NeoPixel.h>
#define PIN 5
int numPixels = 12;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(15);
strip.show();
@huhn511
huhn511 / rfid_example.ino
Created April 24, 2019 21:22
ESP8266 RFID Example with MF522 Reader
#include "MFRC522.h"
#define RST_PIN 0
#define SS_PIN 15
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
@huhn511
huhn511 / esp8622_connect_to_wlan_with_light_feedback.ino
Created April 25, 2019 10:54
ESP8622 connect to wlan with light feedback
#include <Adafruit_NeoPixel.h>
#define PIN 5
int numPixels = 12;
#include <ESP8266WiFi.h>
const char* ssid="<YOUR WLAN SSID";
const char* password="<YOUR WLAN PASSWORD>";
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, PIN, NEO_GRB + NEO_KHZ800);
@huhn511
huhn511 / config.js
Created September 22, 2019 23:56
MagicMirror module mamfeed example configuration (config/config.js)
modules: [
{
module: "mamfeed",
position: "bottom_bar", // This can be any of the regions.
config: {
// The config property is optional.
// If no config is set, an example calendar is shown.
// See 'Configuration options' for more information.
feeds: [