This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkParseWithStringManipulation(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
parseWithStringManipulation("7PM") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseWithStringManipulation(inputString string) int { | |
isAm := strings.HasSuffix(inputString, "AM") | |
number, _ := strconv.Atoi(inputString[:len(inputString) - 2]) | |
if !isAm { | |
number += 12 | |
} | |
return number | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkParseWithReplaceAllTrimSuffix(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
parseWithReplaceAllTrimSuffix("7PM") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseWithReplaceAllTrimSuffix(inputString string) int { | |
isAm := strings.HasSuffix(inputString, "AM") | |
if isAm { | |
inputString = strings.TrimSuffix(inputString, "AM") | |
} else { | |
inputString = strings.TrimSuffix(inputString, "PM") | |
} | |
number, _ := strconv.Atoi(inputString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkParseWithReplaceAll(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
parseWithReplaceAll("7PM") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseWithReplaceAll(inputString string) int { | |
isAm := strings.HasSuffix(inputString, "AM") | |
if isAm { | |
inputString = strings.ReplaceAll(inputString, "AM", "") | |
} else { | |
inputString = strings.ReplaceAll(inputString, "PM", "") | |
} | |
number, _ := strconv.Atoi(inputString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
) | |
func BenchmarkParseWithDateTime(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
parseWithDateTime("7PM") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseWithDateTime(inputString string) int { | |
t, _ := time.Parse("3PM", inputString) | |
number, _ := strconv.Atoi(t.Format("15")) | |
return number | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
pihole: | |
container_name: pihole | |
image: pihole/pihole:v5.1.2 | |
restart: always | |
environment: | |
TZ: 'Europe/Berlin' # Put your own timezone here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\User; | |
use Illuminate\Http\Request; | |
class PlansController extends Controller | |
{ | |