Skip to content

Instantly share code, notes, and snippets.

View cymen's full-sized avatar

Cymen Vig cymen

  • Vig Consulting, LLC
  • Remote
View GitHub Profile
Mapper.CreateMap<Person, Person>()
.ForMember(x => x.BrainSize, opt => opt.Ignore());
var person = Mapper.Map<Person, Person>(anotherPerson);
using System;
using System.Collections.Generic;
namespace ApacheMimeTypes
{
class Apache
{
public static Dictionary<string, string> MimeTypes = new Dictionary<string, string>
{
{ "123", "application/vnd.lotus-1-2-3" },
ViewBag.MyObject = myObjectManager
.GetAllMyObjectBy(isForFoo: true, orderBy: MyObjectColumns.Name)
.AsSelectList(myObjectId)
.WithDefault();
public static class SelectListExtension
{
public static IEnumerable<selectlistitem> WithDefault(this IEnumerable<selectlistitem> list, string defaultLabel = "Select one...", string value = "")
{
return (new[] { new SelectListItem { Text = defaultLabel, Value = value } }).Concat(list);
}
}
public static class MyObjectManagerExtensions
{
public static IEnumerable<selectlistitem> AsSelectList(this IEnumerable<myobject> list, int? value)
{
return (from item in list
select new SelectListItem
{
Selected = value.HasValue && item.Id == value.Value,
Text = item.Name,
Value = item.Id.ToString()
describe("ContactEdit", function() {
beforeEach(function() {
loadFixtures('contacts/_edit.html.erb');
...
@cymen
cymen / rails-fixtures.js
Created May 15, 2012 02:50
Jasmine fixtures path for Rails
$(function() {
jasmine.getFixtures().fixturesPath = '../../../app/views';
})
class Person < Base
hash_attr_accessor :name, :phone
end
class Base
def self.hash_attr_accessor(*accessors)
accessors.each do |m|
define_method(m) do
@attributes[m]
end
define_method("#{m}=") do |value|
@attributes = {} if @attributes.nil?
class Person
attr_accessor :name, :phone
def initialize hash
@name = hash['name']
@phone = hash['phone']
end
end