Skip to content

Instantly share code, notes, and snippets.

View jeremieweldin's full-sized avatar

Jeremie Weldin jeremieweldin

  • Summerville, SC
  • 00:22 (UTC -04:00)
View GitHub Profile
#ThermoZztat
# These are example segments meant to be copied into the 3 main files.
############### Examples for Configuration.yaml ###############
switch:
- platform: mqtt
name: "Upstairs Fan"
command_topic: "cmnd/ThermoZztat/POWER1"
state_topic: "stat/ThermoZztat/POWER1"
qos: 1
@primaryobjects
primaryobjects / json2csharp.txt
Last active March 25, 2024 07:14
Neat trick to convert JSON to a C# class in Visual Studio.
1. Copy some JSON to your clipboard. Need some JSON? Here you go http://goo.gl/mWZSEL
2. In Visual Studio, right-click your project and select Add->Class.
3. Highlight the following code in your class:
class Class1
{
}
4. From the top menu, select Edit->Paste Special->Paste JSON as Classes.
5. Rename "Rootobject" to your desired class name. Done!
@kristopherjohnson
kristopherjohnson / pretty_backtrace.rb
Last active October 17, 2018 14:04
Ruby: Pretty-printed exception backtrace
# Generate a backtrace string for given exception.
# Generated string is a series of lines, each beginning with a tab and "at ".
def pretty_backtrace(exception)
"\tat #{exception.backtrace.join("\n\tat ")}"
end
# Generate a string containing exception message followed by backtrace.
def pretty_exception(exception)
"#{exception.message}\n#{pretty_backtrace(exception)}"
end
@turowicz
turowicz / swift-json-class.md
Last active February 21, 2017 07:00
Apple Swift strong type object serialization to JSON
@higepon
higepon / API.swift
Last active July 31, 2023 16:00
An example of JSON API call in Swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@bigfive
bigfive / 20120118012543_create_site_configuration.rb
Created January 20, 2012 02:01
Ruby on Rails. Key value table for site configuration integrated with Active admin and formtastic forms
# db/migrations/20120118012543_create_site_configuration.rb
class CreateSiteConfigurations < ActiveRecord::Migration
def change
create_table :site_configurations do |t|
t.string :key
t.text :value
t.string :form_type
t.string :form_collection_command
@cbmeeks
cbmeeks / bootstrap_form_builder.rb
Created December 28, 2011 03:59
Twitter Bootstrap Form Builder
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
delegate :capture, :content_tag, :tag, to: :@template
%w[text_field text_area password_field collection_select].each do |method_name|
define_method(method_name) do |name, *args|
errors = object.errors[name].any?? " error" : ""
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : ""
content_tag :div, class: "clearfix#{errors}" do
@watson
watson / ability.rb
Created October 5, 2011 09:50
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)