Skip to content

Instantly share code, notes, and snippets.

View lanekatris's full-sized avatar

Lane Katris lanekatris

View GitHub Profile
public class Item
{
public ObjectId Id { get; set; }
public string Sku { get; set; }
[BsonDateTimeOptions(Representation = BsonType.Document)]
public DateTime DateCreated { get; set; }
}
# Function / CmdLet that compares the MD5 hash of a file to a expected hash passed in via an argument
# Put in powershell profile ($profile) if you want it as a global function, or put it into a module to be imported
function Check-Hash ($file, $expectedHash)
{
$result = (Get-FileHash $file -Algorithm MD5).Hash.ToLower() -eq $expectedHash.Trim().ToLower()
if ($result -eq $true) {
Write-Host $result -ForegroundColor Green
} else {
Write-Host $result -ForegroundColor Red
// From this URL: http://stackoverflow.com/questions/3642371/how-to-update-only-one-field-using-entity-framework
public void ChangePassword(int userId, string password)
{
var user = new User() { Id = userId, Password = password };
using (var db = new MyEfContextName())
{
db.Users.Attach(user);
db.Entry(user).Property(x => x.Password).IsModified = true;
db.SaveChanges();
}
var data = [
{ name: 'item 1', status: 'Pending', qtyShipped: 0},
{ name: 'item 2', status: 'Shipped', qtyShipped: 10},
{ name: 'item 3', status: 'Pending', qtyShipped: 0},
{ name: 'item 2', status: 'Shipped', qtyShipped: 5}
];
_.chain(data)
.uniq(function (item) { return item.name; })
.countBy(function (item) { return item.status })
<div ui-view="main" auto-scroll="false"></div>
var data = [
{ refNum: 'a1', items: [{name: 'item 1'}, {name: 'item 2'}] },
{ refNum: 'b4', items: [{name: 'item 3'}, {name: 'item 4'}] }
];
var items = [];
$scope.$watch('data',function ( nv, ov ) {
angular.forEach(nv, function ( item ) {
items.push(item);
// Query teams and players in those teams, a relationship table between
// Team << UserTeams >> User
// Team.Id || UserTeam.TeamId, UserTeam.UserId || User.Id
// Basic select
var query = from x in Teams
select x;
// Inner Join (Give me teams that only have users in them)
var query = from t in Teams
var domainTeam = new Team() { Name = "Team 1", Description = "..." };
public class TeamRepository
{
public void Create(Team team)
{
var entityFrameworkTeam = new Entities.Team() {
Name = team.Name,
Description = team.Description
};
var domainTeam = new Team() { Name = "Team 1", Description = "..." };
public class TeamRepository
{
public void Create(Team team)
{
// Don't forget to do your Mapper.Map<> in your bootstrap code in Global.asax or something or you'll get an unknown map error
var entityFrameworkTeam = Mapper.Map<Entities.Team>(team);
// db.add
string dir = "c:\sites\app\Content\Images\Rank\1000\";
string fileName = "image1.jpg";
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
file.SaveAs(dir + fileName);