Skip to content

Instantly share code, notes, and snippets.

View jeremieweldin's full-sized avatar

Jeremie Weldin jeremieweldin

  • Summerville, SC
  • 18:10 (UTC -04:00)
View GitHub Profile
@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",
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@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!
@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>
@jeremieweldin
jeremieweldin / SaveIconsForiOSIcons.jsx
Created September 13, 2010 18:31
Illustrator automation script for exporting an icon artboard to all the sizes needed for iOS apps.
var destFolder = null;
destFolder = Folder.selectDialog( 'Select the folder where you want to save the exported files.', app.activeDocument.path );
var baseDestName = app.activeDocument.name;
if (baseDestName.indexOf('.') < 0)
{
//nothing
} else {
@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)
#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
@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
@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
@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