Skip to content

Instantly share code, notes, and snippets.

View eramella's full-sized avatar

Emanuele Ramella-Paia eramella

View GitHub Profile
@eramella
eramella / .gitconfig
Last active March 11, 2022 08:44
PS Win 10 Set up
[push]
default = simple
[core]
pager = cat
editor = code --wait
autocrlf = true
[color]
ui = true
[color "status"]
changed = red bold
@eramella
eramella / Git commands
Last active February 21, 2018 03:29
As a reminder and to learn Git
1) git branch -d <branch_name>
2) git checkout -b <branch name>
3) git show-branch
4) git add --all
5) git push -u origin <branchName>
6) git fetch origin
7) git push origin --delete <branch name>
8) Add remote Github repo to local exisitng:
git remote add origin <remote repository URL>
# Sets the new remote
@eramella
eramella / RestoreSQLEXPtoLocalDb
Last active July 12, 2016 01:02
Restore SQLExpress backup to a LocalDb
-check file names first
restore filelistonly
from disk = 'c:\dev\EMS.2016-07-11.bak'
-Then restore filename to a local disk location of your choice (make sure the entire path is already created before running this)
restore database EMS
from disk = 'c:\dev\EMS.2016-07-11.bak'
with move 'EMS' to 'c:\dev\SQLData\EMS.mdf',
move 'EMS_log' to 'c:\dev\SQLData\EMS_log.ldf',
replace;
@eramella
eramella / EF-TrackDataHistory.cs
Created August 5, 2015 18:20
Great pattern created by Julie Lerman. This makes it easy to track data modification. The IsDirty property is mainly for Non-Disconnected applications.
public override int SaveChanges(){
foreach (var history in this.ChangeTracker.Entries()
.Where(e => e.Entity is IModificationHystry && (e.State == EntityState.Added || e.State == EntityState.Modified))
.Select(e => e.Entity as IModificationHistory)
){
history.DateModified = DateTime.Now;
if(history.DateCreated == DateTime.MinValue){
history.DateCreated = DateTime.Now;
}
}
@eramella
eramella / Custom Styling Directive for Bootstrap
Last active August 29, 2015 14:18
Custom Styling Directive for Bootstrap
(function(module){
var setupDom = function (element){
var input = element.querySelector("input, textarea, select, custom-directive");
var type = input.getAttribute("type");
if (type !== "checkbox" && type != "radio"){
input.classList.add("form-control");
} //we can add an else to add different classes for radio and checkbox since
//form-control doesn't render nicely with these 2 input types