Skip to content

Instantly share code, notes, and snippets.

View bohoffi's full-sized avatar

Basti Hoffmann bohoffi

View GitHub Profile
@bohoffi
bohoffi / getStringAndFretFromKeyAndTuning.ts
Created May 19, 2017 12:04
Shows how to calculate a note's position on a fretboard (e.g. guitar or bass) providing the note's key (e.g. 'e/4'), a string tuning and a maximum fret limit.
type Tuning = string[];
// provide the standard 6-string guitar tuning (high to low)
const standardTuning: Tuning = ['E4', 'B3', 'G3', 'D3', 'A2', 'E2'];
// provide a limit for the fretboard length (24 frets => 0 to 24)
const maxFretLimit: number = 24;
interface FretBoardNote {
string: number;
@bohoffi
bohoffi / paging.tpl.html
Created December 13, 2016 09:16
Angular 1 paging directive
<div class="paging">
<a ng-if="currentPage > 1" href="{{paging.prevLink}}" class="prev-link">{{paging.prevLabel}}</a>
<span ng-if="currentPage > 1 && currentPage < totalPages" class="sep">{{paging.sep}}</span>
<a ng-if="currentPage < totalPages" href="{{paging.nextLink}}" class="next-link">{{paging.nextLabel}}</a>
</div>
@bohoffi
bohoffi / paging.directive.js
Last active December 13, 2016 09:16
Angular 1 paging directive
(function () {
'use strict';
angular.module('app.directives', [])
.directive('paging', PagingDirective);
function PagingDirective() {
return {
restrict: 'EA',
templateUrl: 'paging.tpl.html',
@bohoffi
bohoffi / paging.component.ts
Created December 13, 2016 08:30
Angular 2 paging component utilizing the router
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'paging',
templateUrl: './paging.component.html',
styleUrls: ['./paging.component.css']
})
export class PagingComponent implements OnInit {
@Input()
@bohoffi
bohoffi / paging.component.html
Last active December 13, 2016 08:31
Angular 2 paging component utilizing the router
<div>
<a *ngIf="currentPage > 1" [routerLink]="prevRouterLink" class="prev-link">{{prevLabel}}</a>
<span *ngIf="currentPage > 1 && currentPage < totalPages" class="sep">{{sep}}</span>
<a *ngIf="currentPage < totalPages" [routerLink]="nextRouterLink" class="next-link">{{nextLabel}}</a>
</div>
@bohoffi
bohoffi / paging.component.css
Last active December 13, 2016 08:31
Angular 2 paging component utilizing the router
div {
text-align: center;
margin-top: 1rem;
}
div a {
color: #0d47a1;
text-decoration: none;
}
div a:hover {
text-decoration: underline;