Skip to content

Instantly share code, notes, and snippets.

View wholypantalones's full-sized avatar

Jason Dare wholypantalones

View GitHub Profile
@wholypantalones
wholypantalones / .bash_aliases
Last active January 21, 2020 14:38
Bash Aliases
alias push="git pull; git push"
alias zuul="cd ~/git/zuul/; java -Dzuul.host.socket-timeout-millis=250000 -jar target/*.jar"
webstorm="cd ~/WebStorm-193.5662.54/bin/webstorm.sh"
alias nodeapp="nodemon -e jsx,js,json,html,css,yml,ts app.js"
alias go="npm start"
alias start="a & b"
a() {
echo "running zuul"
cd ~/git/zuul/; java -Dzuul.host.socket-timeout-millis=250000 -jar target/*.jar
@wholypantalones
wholypantalones / package.json
Created November 7, 2019 13:17
Angular Universal package.json scripts
{
"scripts": {
"ng": "ng",
"start": "npm run noreload",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"lint-fix": "ng lint --fix",
"e2e": "ng e2e",
"update": "ng update --all",
@wholypantalones
wholypantalones / git-undo-commit-push.sh
Created May 16, 2019 12:10
Undo git commit and push to origin master
#!/bin/bash
#### https://git-scm.com/docs/git-reset
git reset @~
git push -f origin <hash>:<branch>
@wholypantalones
wholypantalones / obj-from-obj.ts
Last active April 18, 2019 14:46
TypeScript params obj from obj
/**
* loop through the config obj and delete the things we do not need
* to make a params obj from the config obj
*/
static objFromConfig(params) {
const newObj = JSON.parse(JSON.stringify(params));
Object.entries(newObj).map(([k, v]) => {
if (v === null || v === '') {
delete newObj[k];
}
@wholypantalones
wholypantalones / sort-earliest-date.ts
Created April 18, 2019 14:45
Typescript sort array by earliest date
sortByEarliestDate(arr) {
return arr.sort((a: number, b: number) => {
return +new Date(a['sort']) - +new Date(b['sort']);
});
}
@wholypantalones
wholypantalones / array-diff.js
Last active April 5, 2019 16:59
Compare two arrays of objects for differences
b.filter(o => !a.find(o2 => o.id === o2.id))
b.filter(({ value: id1 }) => !a.some(({ value: id2 }) => id2 === id1));
@wholypantalones
wholypantalones / velvet-resolver.ts
Last active April 18, 2019 14:47
Angular / Typescript Promise Resolver
purchaseOrderIds = ['12345', '67890'];
getPurchaseOrderDetails() {
const promises = [];
this.purchaseOrderIds.map(x => {
promises.push(new Promise((resolve) => {
this.purchaseOrderService.getPurchaseOrder(x)
.subscribe(
res => {
resolve(res);
@wholypantalones
wholypantalones / async.js
Created October 11, 2018 17:54
JavaScript Async Map
const arr = [ { key: 1 }, { key: 2 }, { key: 3 } ]
const results = arr.map(async (obj) => { return obj.key; });
Promise.all(results).then((completed) => console.log('done', arr);
@wholypantalones
wholypantalones / white-space-array.js
Last active September 28, 2018 12:44
White-space string to array using match
// Fiddle: http://jsfiddle.net/wholypantalones/eL6zys0c/
const classString = 'btn-lg btn-block btn-success';
const classArray = classString.match(/\S+/g);
//output ["btn-lg", "btn-block", "btn-success"];
@wholypantalones
wholypantalones / params-from-config.js
Last active September 11, 2018 14:37
Params obj from config block
config = {
page: 0,
pageSize: 25,
sortColumn: 'publishDate',
sortDirection: 'ASC'
};
/**
* loop through the config block and delete the things we do not need
* to make a params obj from the config obj