Skip to content

Instantly share code, notes, and snippets.

@visoft
visoft / controllers.application\.js
Last active May 1, 2020
Bootstrap Changeset Form
View controllers.application\.js
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 Sep 25, 2018
Ember Sample Counter
View application.hbs
{{counter-component}}
{{outlet}}
@visoft
visoft / application.controller.js
Last active Feb 23, 2016
Complex Computed Property Test
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Complex Computed Property Test'
});
@visoft
visoft / currency_helpers.coffee
Created Dec 19, 2014
Formatting numbers with commas using an Ember helper
View currency_helpers.coffee
Ember.Handlebars.helper 'formatCurrency', (value) ->
value = value || 0
Number(value).toFixed(0).replace /(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,"
@visoft
visoft / plugin.coffee
Created Oct 10, 2014
Simple jQuery Plugin with CoffeeScript
View plugin.coffee
$ = jQuery
$.myPlugin = (element) ->
plugin = this
plugin.init = ->
# Do stuff here
# initialize the plugin
plugin.init()
View Ember-Delete-Button-Component.markdown

Ember Delete Button Component

Using Zurb Foundation and Font Awesome, I came up with a delete button that changes to a confirmation button. If you confirm, the delete goes through, otherwise if you move your mouse off the button, it resets back to just a normal delete button.

A Pen by Damien White on CodePen.

License.

View DateHelpers.cs
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 Mar 24, 2013
Simple CSS close button
View close_button.css
.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 Mar 24, 2013
String extensions to make pluralization, etc. easier. Inspiration for these came from Ruby on Rails.
View StringExtensions.cs
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 Jul 7, 2011
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
View application.html.haml
// Usage
= render_breadcrumbs :builder => BreadcrumbBuilder