Skip to content

Instantly share code, notes, and snippets.

View mvalipour's full-sized avatar
🚴‍♂️
Cycling...

| Mo Valipour mvalipour

🚴‍♂️
Cycling...
View GitHub Profile
@mvalipour
mvalipour / readme.md
Last active November 8, 2016 17:04
Redux application structure

Folder Structure

/act
  /auth
    actions.js
    actiontypes.js
    reducer.js
  /...
  actions.js
@mvalipour
mvalipour / readme.md
Created November 7, 2016 23:10
Login form in React

using:

  • react-router
  • react-router-redux
  • react-act
// reducers.js
@mvalipour
mvalipour / readme.md
Created November 3, 2016 14:06
A note on using EF utilizing lazy loading

When using EF (or any other ORM utilizing lazy loading) DO NOT pass your entity objects around different layered of your application.

Just turn them into a purpose-built DTO ASAP.

Gotcha: otherwise you will get a ObjectContext disposed error whenever the code retrieving your eneity changes the way it handles the retrieval (context dispose).

in other words: this code:

using(var context = new MyContext())
@mvalipour
mvalipour / abdoo.md
Created October 26, 2016 15:40
Abdoo proposed stack
  • Front-End

    • react + redux (+ redux-act + react-route)
    • babel (preset-latest)
    • webpack
  • Back-End

    • asp.net core
    • mediator
  • OrientDB

@mvalipour
mvalipour / kill-all.bat
Created October 26, 2016 10:59
Kill all docker containers on windows
$ powershell
$ docker ps -q | % { docker kill $_ }
@mvalipour
mvalipour / array-zip.js
Created October 24, 2016 13:22
zip many arrays in javascript
// given this is an array of arrays
Array.prototype.zip = function () {
return this
.filter(a => a.length > 0)
.reduce((r, a, ix) => {
a.forEach((e, jx) => r.splice(jx*ix + ix + jx, 0, e));
return r;
}, []);
}
var config = settings.domains[this.url.domain];
if(!config) {
return this.error("invalid domain");
}
if(config.subdomains && this.user.subdomain !== this.url.subdomain) {
return this.redirectToSubDomain();
}
@mvalipour
mvalipour / nuget-consolidation.ps1
Created October 3, 2016 10:57
Check for nuget consolidation across your solution
Get-ChildItem -Recurse -Depth 5 -Path "." |
? { $_.Name -eq "packages.config" } |
% { ([xml](Get-Content -Path $_.FullName)).packages.package | select id, version } |
Group-Object -Property id |
select Name, @{ Name="Versions"; Expression= { $_.Group | select -ExpandProperty version -Unique }} |
? { $_.Versions.Count -gt 1 } |
Sort-Object -Property Name |
% { Write-Error "Package '$($_.Name)' has multiple versions used across the solution! $($_.Versions)" }
@mvalipour
mvalipour / GetTableName.cs
Created August 8, 2016 15:46
Get Table name from type in Entity Framework
public static string GetTableName(this ObjectContext context, Type t)
{
var entityName = t.Name;
var storageMetadata = context.MetadataWorkspace.GetItems<EntityContainerMapping>(DataSpace.CSSpace);
foreach (var ecm in storageMetadata)
{
EntitySet entitySet;
if (ecm.StoreEntityContainer.TryGetEntitySetByName(entityName, true, out entitySet))
{
@mvalipour
mvalipour / Generate-ReleaseNotes.ps1
Last active September 7, 2016 00:18
Generate-ReleaseNotes from Git Commits and Target Process Entities
Param(
[Parameter(Mandatory=$true)][string]$git_url,
[Parameter(Mandatory=$true)][string]$github_token,
[string]$github_base = "master",
[string]$github_head = "develop",
[string]$version_build = "0",
[Parameter(Mandatory=$true)][string]$tp_domain,
[Parameter(Mandatory=$true)][string]$tp_username,
[Parameter(Mandatory=$true)][string]$tp_password
)