Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Southworth ksouthworth

  • Web Ascender
  • Michigan, USA
View GitHub Profile
@ksouthworth
ksouthworth / form.html.haml
Last active Feb 6, 2019
SimpleForm Sticky Association Input
View form.html.haml
-# form.html.haml
= simple_form_for @project do |f|
-# normal SimpleForm association
= f.association :company
-# new and improved "sticky" association
= f.sticky_association :company
= f.input :name
= f.submit
@ksouthworth
ksouthworth / alloy.jmk.js
Last active Sep 2, 2015
Basic Theme support for Ti Alloy
View alloy.jmk.js
/*
This custom JMK file hacks in some basic "Theme" support for this Alloy project
You can put .tss files under the app/styles/themes/ directory and they will be auto-injected
into the main app.tss file (at the end of the file)
It will also convert plain TSS style rules into "Custom Query Styles" so that the rules
in each theme file will only apply if that theme is "active" in the app.
http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Styles_and_Themes-section-35621526_AlloyStylesandThemes-CustomQueryStyles
@ksouthworth
ksouthworth / gist:a8e008b83cf089e57249
Last active Aug 29, 2015
Titanium Image Resizing : Comparing built-in BLOB methods vs Titanium "ImageFactory" module methods
View gist:a8e008b83cf089e57249
var photoDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "photos");
if(!photoDir.exists()) {
photoDir.createDirectory();
}
function takePhoto(e) {
// https://github.com/appcelerator-modules/ti.imagefactory
var ImageFactory = require('ti.imagefactory');
Ti.Media.showCamera({
@ksouthworth
ksouthworth / ruby-int-to-bcd.rb
Last active Mar 16, 2016
Ruby code to convert an Integer to a Binary Coded Decimal (BCD) array of bytes
View ruby-int-to-bcd.rb
# Convert an Integer to a "Packed" Binary Coded Decimal (BCD) formatted array of bytes
# http://en.wikipedia.org/wiki/Binary-coded_decimal
def int_to_bcd_bytes(int)
# BCD format takes each digit of an integer value and encodes it into a nibble (4 bits)
# It maintains the order of the original digits, so 15 would be 00010101
# Since we're dealing with nibbles, we have to zero-pad-left if the number has an odd number of digits
# Decimal digit Binary
# 0 0000
# 1 0001
# 2 0010
@ksouthworth
ksouthworth / refresh-all-sql-views.sql
Last active Sep 28, 2015
Refresh all SQL Views in database
View refresh-all-sql-views.sql
DECLARE @view AS VARCHAR(255) ;
DECLARE ListOfViews CURSOR FOR
SELECT TABLE_SCHEMA + '.' +TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'VIEW'
AND OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'IsMsShipped') = 0
ORDER BY TABLE_SCHEMA,TABLE_NAME