Skip to content

Instantly share code, notes, and snippets.

View jonyeezs's full-sized avatar
💼
Focusing on work - maybe slow to respond

Jonathan Yee jonyeezs

💼
Focusing on work - maybe slow to respond
View GitHub Profile
@jonyeezs
jonyeezs / .gitignore
Last active April 16, 2016 06:55
My global gitignore
# Referencing to https://gist.github.com/octocat/9257657#
# Compiled source #
###################
*.com
*.class
# *.dll - some work projects do want to include this
# *.exe - some work projects do want to include this
# *.o
# *.so
@jonyeezs
jonyeezs / SerialHttpCalls.js
Last active November 18, 2016 01:52
How to chain promises that are built dynamically
/* Context:
* We are building an array of http calls that needs to be run synchronously (ie in serial).
* We have no idea how many calls we need to make so we have to go through an array but not have it run async.
*
* What's Involve:
* - angular's $http & $q to deal with promises, so we can resolve the calls when we want to.
* See: http://www.codelord.net/2015/09/24/$q-dot-defer-youre-doing-it-wrong/
* - Array.reduce to cascade down the array, with knowing the current and next value.
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
* - Lodash to do collection manipulation for us.
@jonyeezs
jonyeezs / Program.cs
Last active August 16, 2016 05:45
CSharpAsyncAwait
public class Program
{
/* Demonstrate Async Await
* This is a good starting point to understand async: http://blog.stephencleary.com/2012/02/async-and-await.html
* Slightly confuse between Task and Thread?: https://youtu.be/No7QqSc5cl8
* Here's some good videos:
* * Task Parallel Library - https://youtu.be/gfkuD_eWM5Y
* * Async & Await - https://youtu.be/DqjIQiZ_ql4
* Bad Practice:
* Don't use Wait() use await
@jonyeezs
jonyeezs / .gitconfig
Last active June 21, 2022 02:23
My git config settings
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = YourName
email = test@test.com
# This is Git's per-user configuration file.
[merge]
tool = meld
conflictstyle = diff3
[core]
@jonyeezs
jonyeezs / fakeproviders.js
Last active June 3, 2017 13:38
Faking providers
let customerServiceMock = {/*some fake functions that will be called*/};
angular.mock.module('app', function($provide) {
$provide.service('customerService', customerServiceMock);
});
// or
let customerServiceMock = jasmine.createSpyObj('customerService', ['complain']);
@jonyeezs
jonyeezs / Microsoft.Powershell_profile.ps1
Last active August 20, 2017 23:24
My Powershell profile: setting up posh-git prompt | conemu | posh-docker | powerls | PSReadLine | and some aliases
# ensure you have your public key in C:\Users\<account>\.ssh
Start-SshAgent
function prompt
{
$origLastExitCode = $LASTEXITCODE
# draw out the directory then posh git prompt followed by ">"
Write-Host $ExecutionContext.SessionState.Path.CurrentLocation -NoNewline
Write-VcsStatus
@jonyeezs
jonyeezs / populateInput.js
Created August 22, 2017 02:10
Using DOM to populate rows of inputs
// We have a table with the last column being to inputs.
// We want to put in the same values on all rows.
// This will add in values to inputs on the last column of a row in a table
// The premise is that when there are two inputs in the last column,
// we know that's where we want to add the values
// Use call to "borrow" the forEach function on HTMLCollection
Array.prototype.forEach.call(document.getElementsByTagName('tbody')[1].getElementsByTagName('tr'), function(tr) {
// We know the last column is the forth and that will always be where the inputs are
var lastTD = tr.getElementsByTagName('td')[3];
@jonyeezs
jonyeezs / rbenv-ruby-build.md
Last active February 19, 2023 05:43
Recommended Ruby Dev Setup

rbenv & Ruby-build + Bundler

Manage ruby installion and environment for a non-fuss and non-headache development on multiple supported Ruby versions.

Manage your Ruby version for your application and global environment.

  • Uses environment variable to maintain so it's easily configurable.
  • Application specific versioning.
@jonyeezs
jonyeezs / nvm-node.md
Last active January 21, 2019 06:03
Recommended Node Dev Setup

node with NVM + useful cli plugins

A Node version manager. Useful if you need to support previous versions

Installation

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Keybase proof

I hereby claim:

  • I am jonyeezs on github.
  • I am jonyeezs (https://keybase.io/jonyeezs) on keybase.
  • I have a public key ASC8JHluId2uL70AkaI3mIM04fy0wGyywxTWRu4tjDtEjwo

To claim this, I am signing this object: