Skip to content

Instantly share code, notes, and snippets.

View visoft's full-sized avatar

Damien White visoft

View GitHub Profile
@visoft
visoft / controllers.application\.js
Last active May 1, 2020 23:33
Bootstrap Changeset Form
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { Changeset } from 'ember-changeset';
import { action } from '@ember/object';
import FormValidator from '../validators/form';
import lookupValidator from 'ember-changeset-validations';
export default class ApplicationController extends Controller {
@tracked formModel = { name: null, foo: null };
@visoft
visoft / application.hbs
Last active September 25, 2018 19:02
Ember Sample Counter
{{counter-component}}
{{outlet}}
@visoft
visoft / application.controller.js
Last active February 23, 2016 01:50
Complex Computed Property Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Complex Computed Property Test'
});
public static DateTime EasterSunday(int year)
{
int day = 0;
int month = 0;
int g = year % 19;
int c = year / 100;
int h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 30;
int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * (int)((21 - g) / 11));
@visoft
visoft / close_button.css
Created March 24, 2013 23:07
Simple CSS close button
.close_button {
-moz-box-shadow:inset 0px 1px 0px -23px #f29c93;
-webkit-box-shadow:inset 0px 1px 0px -23px #f29c93;
box-shadow:inset 0px 1px 0px -23px #f29c93;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #fe1a00), color-stop(1, #ce0100) );
background:-moz-linear-gradient( center top, #fe1a00 5%, #ce0100 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fe1a00', endColorstr='#ce0100');
background-color:#fe1a00;
-moz-border-radius:5px;
-webkit-border-radius:5px;
@visoft
visoft / StringExtensions.cs
Created March 24, 2013 23:05
String extensions to make pluralization, etc. easier. Inspiration for these came from Ruby on Rails.
using System;
using System.Data.Entity.Design.PluralizationServices;
using System.Globalization;
namespace VisoftInc.Common.Extensions
{
public static class StringExtensions
{
public static string ToTitleCase(this string value)
{
@visoft
visoft / application.html.haml
Created July 7, 2011 23:02
Custom Breadcrumb Builder that handles a render action from the controller using breadcrumbs_on_rails. Instead of highlighting the "middle" item as active, e.g. Home >> **Widgets** >> New, the last item will be highlighted instead (so New in the previous
// Usage
= render_breadcrumbs :builder => BreadcrumbBuilder
The following code throws an exception: "Error HRESULT E_FAIL has been returned from a call to a COM component."
<telerik:RadWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
mc:Ignorable="d"
x:Class="Sample.UserControl1"
@visoft
visoft / currency_helpers.coffee
Created December 19, 2014 13:54
Formatting numbers with commas using an Ember helper
Ember.Handlebars.helper 'formatCurrency', (value) ->
value = value || 0
Number(value).toFixed(0).replace /(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,"
@visoft
visoft / plugin.coffee
Created October 10, 2014 12:35
Simple jQuery Plugin with CoffeeScript
$ = jQuery
$.myPlugin = (element) ->
plugin = this
plugin.init = ->
# Do stuff here
# initialize the plugin
plugin.init()