This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.IO; | |
using System.Xml.Linq; | |
using System.Threading; | |
namespace TumblrAPI.ConsoleApp | |
{ | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake' | |
def foo(task, name, *args) | |
args || args = [] | |
args.insert 0, task | |
body = lambda { | |
puts 'Hello, ' + name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult UpdateProfile(ProfileInputModel input, Individual individual){ | |
if(!ModelState.IsValid) | |
return View(new ProfileInputModel()); | |
Mapper.Map<ProfileInputModel, Individual>(input, individual); | |
foreach(var email in input.Emails) | |
individual.UpdateEmailAddress(email.Key, email.Value); | |
return RedirectToAction("ViewProfile"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IndividualController : BaseController{ | |
[HttpPost] | |
public ActionResult UpdateProfile(UpdateProfileInputModel inputModel) | |
{ | |
return Form(inputModel, View("UpdateSucceeded"), View("UpdateFailed")); | |
} | |
} | |
public class UpdateProfileInputModelHandler : IFormHandler<UpdateProfileInputModel> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// survey definitions | |
public abstract class SurveyDefinition{ | |
public string Id{ get; set; } | |
public string Survey{ get; set; } | |
public string Version{ get; set; } | |
public abstract Survey Generate(); | |
} | |
public class MySurvey2010 : SurveyDefinition{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup Schema | |
// ------------ | |
var | |
mongoose = require('mongoose'), | |
Schema = mongoose.Schema; | |
mongoose.model('Bug', new Schema({ | |
someNumber: Number | |
})); | |
var Bug = mongoose.model('Bug'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int pageSize = 10; | |
var allProducts = database.Products.All(); //15 products | |
//products 1-10 | |
var firstPage = allProducts.ToPagedList(0, pageSize); | |
Assert.Equal(10, firstPage.Count); | |
Assert.False(firstPage.HasPreviousPage); | |
Assert.True(firstPage.HasNextPage); | |
//products 11-15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Out-of-the-box Pager Configurations</h2> | |
<h3>Default Paging Control</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page })) | |
<h3>Minimal Paging Control</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.Minimal) | |
<h3>Minimal Paging Control w/ Page Count Text</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.MinimalWithPageCountText) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyRenderOptions : PagedList.Mvc.PagedListRenderOptions{ | |
public MyRenderOptions() : base(){ | |
DisplayLinkToFirstPage = false; | |
DisplayLinkToLastPage = false; | |
DisplayLinkToIndividualPages = false; | |
LinkToPreviousPageFormat = "< Go Back"; | |
LinkToNextPageFormat = "Go Forward >"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(contact, activities, config){ | |
var sortByActivityDateDescending = function(activity1, activity2){ | |
if (activity1.activityDate > activity2.activityDate) return -1; | |
if (activity1.activityDate < activity2.activityDate) return 1; | |
return 0; | |
}; | |
if(config.timeframe) | |
var earliestDateToProcess = new Date().setDate(newDate().getDate() - config.timeframe); | |
var sortedActivities = activities.sort(sortByActivityDateDescending); |
OlderNewer