Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
@jrgcubano
jrgcubano / .tmux.conf
Created October 18, 2015 19:19 — forked from v-yarotsky/.tmux.conf
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@jrgcubano
jrgcubano / overview-for-angular-apps-with-roles-and-permissions.md
Created November 23, 2015 11:18 — forked from bvaughn/overview-for-angular-apps-with-roles-and-permissions.md
RE: Reddit Angular JS question "Advice on separating the logical parts of an application"

This gist is in response to a question asked on the Reddit Angular JS forum about how to structure an Angular app with roles and permissions.

There are many ways to approach this, but I'll share one that I've used before and maybe it will give you an idea. I'd combine all of the above into a single app and control who gets to see what using permissions. There are a few components to this approach...

A local session service

First off I'd advise creating some sort of local session management service. This should be able to track whether you have an authenticated user and- if so- what types of permissions that user has. (Lots of ways to manage permissions. I'll assume your user object has either a 'role' enum or something simple like an array of string permissions.) You could roll your own session service or you could check out something like satellizer.

Let's assume yo

@jrgcubano
jrgcubano / AsyncMethodCaller.cs
Created December 9, 2015 15:52 — forked from hjerpbakk/AsyncMethodCaller.cs
C# classes for calling methods asynchronously and continue with with other methods after execution completes. Very useful in View Models.
/// <summary>
/// Used to call methods asynchronously and continue with with other methods
/// after execution completes. Very useful in View Models.
/// </summary>
public class AsyncMethodCaller : IAsyncMethodCaller
{
/// <summary>
/// The final <see cref="Task"/> to be executed, can be awaited.
/// </summary>
protected Task CurrentTask;
public class ViewModelWithBackgroundWorker {
private readonly BackgroundWorker worker;
public ViewModelWithBackgroundWorker() {
worker = new BackgroundWorker();
worker.DoWork += DoSomething;
worker.RunWorkerCompleted += WorkCompleted;
}
public string Message { get; set; }
@jrgcubano
jrgcubano / currying.md
Created February 2, 2016 08:54 — forked from donnut/currying.md
TypeScript and currying

TypeScript and currying

In functional programming you often want to apply a function partly. A simple example is a function add. It would be nice if we could use add like:

var res2 = add(1, 3); // => 4

var add10To = add(10);
var res = add10To(5); // => 15
@jrgcubano
jrgcubano / 01_folds.fs
Created February 3, 2016 17:09 — forked from cloudRoutine/01_folds.fs
F# Transducers - they work for the most part
open System.Collections.Generic
open Microsoft.FSharp.Collections
[<RequireQualifiedAccess>]
module Folds =
// These are the fast implementations we actually want to use
@jrgcubano
jrgcubano / FizzBuzz.fsx
Created February 4, 2016 17:35 — forked from tcshao/FizzBuzz.fsx
FizzBuzz in F#
let fizzBuzz x =
match x with
| _ when (x % 15) = 0 -> "FizzBuzz"
| _ when (x % 3) = 0 -> "Fizz"
| _ when (x % 5) = 0 -> "Buzz"
| _ -> ""
let fizzBuzzTo max =
[1..max]
|> List.iter (fun number -> printfn "%d %s" number (fizzBuzz number))
@jrgcubano
jrgcubano / dev_setup.ps1
Created February 5, 2016 17:07 — forked from thitemple/dev_setup.ps1
A PowerShell script for installing a dev machine using Chocolatey.
function Add-Path() {
[Cmdletbinding()]
param([parameter(Mandatory=$True,ValueFromPipeline=$True,Position=0)][String[]]$AddedFolder)
# Get the current search path from the environment keys in the registry.
$OldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
# See if a new folder has been supplied.
if (!$AddedFolder) {
Return 'No Folder Supplied. $ENV:PATH Unchanged'
}
# See if the new folder exists on the file system.
@jrgcubano
jrgcubano / SQLPackageDeploy.ps1
Created February 16, 2016 10:21
Script to publish SQL Server database dacpac using PowerShell and SQLPackage.exe
#=================================================================================
# Designed to deploy a database from a dacpac
#
# Usage:
# .\sqlPackageDeploymentCMD.ps1 -targetServer "LOCALHOST" -targetDB "IamADatabase" -sourceFile "C:\ProjectDirectory\bin\Debug\IamADatabase.dacpac" -SQLCMDVariable1 "IamASQLCMDVariableValue"
#
# So, why would you do this when you could just call the sqlpackage.exe directly?
# Because Powershell provides a higher level of orchestration; I plan to call this script from another script that
# first calls a script to build the dacpac that is then used in this script.
#=================================================================================
@jrgcubano
jrgcubano / merge.ps1
Last active February 17, 2016 15:43 — forked from Novakov/merge.ps1
TFS Powershell scripts
param([string]$repo, [string]$source,[string]$dest,[string]$comment)
$base = "$/MAPS /Dev/$repo"
set-alias tf 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe'
tf get /recursive "$base/$source"
tf merge /recursive "$base/$source" "$base/$dest"