Skip to content

Instantly share code, notes, and snippets.

View michaelchadwick's full-sized avatar
🤘

Michael Chadwick michaelchadwick

🤘
View GitHub Profile
@michaelchadwick
michaelchadwick / about-this-computer.sh
Created January 9, 2024 18:29
Bash script to get OS information, as well as applications
# about: display info about current system
function about() {
# OS info
if hash neofetch 2>/dev/null; then
neofetch
else
if hash archey 2>/dev/null; then
archey -c "$1"
else
if [ -f /etc/redhat-release ]; then
@michaelchadwick
michaelchadwick / lpxnotes_dump.sh
Last active November 13, 2023 21:28
Extract Notes field from Logic Pro X session file (.logicx)
#!/usr/bin/env bash
## get the Notes field from a Logic Pro X project (e.g. lyrics)
function lpxnotes_dump() {
# Check if a filename is provided as an argument
if [ "$#" -ne 1 ]; then
echo "Usage: lpxnotes_dump <filename>"
else
# assuming only one Alternative
filename=$1/Alternatives/000/ProjectData
@michaelchadwick
michaelchadwick / app.module.ts
Created June 14, 2017 21:11
angular 2 testing - AppModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { DaveService } from './_services/dave.service';
import { HomeComponent } from './home/index';
@michaelchadwick
michaelchadwick / dave.service.ts
Created June 14, 2017 21:10
angular 2 testing - DaveService
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { devlog } from '../_helpers/devlog';
@Injectable()
export class DaveService {
@michaelchadwick
michaelchadwick / app.routing.ts
Last active June 14, 2017 21:13
angular 2 testing - AppRouting
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/index';
import { HomeComponent } from './home/index';
import { AuthGuard } from './_guards/index';
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: 'logout', component: LoginComponent, canActivate: [AuthGuard] },
{ path: '', component: HomeComponent, canActivate: [AuthGuard] },
@michaelchadwick
michaelchadwick / app.component.html
Created June 14, 2017 16:31
angular 2 testing - AppComponent template
...
<div class="jumbotron">
<div class="container">
<div class="col-sm-8 col-sm-offset-2">
<router-outlet></router-outlet>
</div>
</div>
</div>
@michaelchadwick
michaelchadwick / home.component.ts
Last active June 14, 2017 21:12
angular 2 testing - HomeComponent
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Response } from '@angular/http';
import { Subscription } from 'rxjs/Subscription';
import { DaveService } from '../_services/dave.service';
import { devlog } from '../_helpers/devlog';
@Component({
moduleId: module.id,
templateUrl: './home.component.html',
@michaelchadwick
michaelchadwick / service.spec.ts
Last active May 11, 2017 15:51
async service testing
// src/app/service.spec.ts
//import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs/Rx';
import { TestBed, inject, async } from '@angular/core/testing';
import { MockBackend, MockConnection } from '@angular/http/testing';
import { Http, BaseRequestOptions, Response, ResponseOptions, RequestMethod } from '@angular/http';
import 'rxjs/add/observable/from';
import 'rxjs/add/observable/throw';
@michaelchadwick
michaelchadwick / service.ts
Created May 10, 2017 22:57
async service
// src/app/service.ts
import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class MyService {
private headers = new Headers({'Content-Type': 'application/json'});
private apiUrl = 'http://localhost:8000'; // URL to web api
@michaelchadwick
michaelchadwick / equalHeights.js
Created May 1, 2017 22:37
Dynamically resize elements based on tallest one
// dynamically size elements based on tallest one
equalheight = function(container) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPostion = 0;
$(container).each(function() {
$el = $(this);