Skip to content

Instantly share code, notes, and snippets.

View Oldenborg's full-sized avatar

Henrik Oldenborg

View GitHub Profile
@Oldenborg
Oldenborg / AssertJson.php
Last active October 2, 2023 22:50
Laravel test trait: assert JSON exact
<?php
namespace Tests\Traits;
use Illuminate\Testing\TestResponse;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Assert as PHPUnit;
trait AssertJson
{
@Oldenborg
Oldenborg / how-to-not-bem.scss
Last active May 28, 2020 13:35
BEM grandchildren - yes or no?
// Example #1
.tree__branch--green {
.twig__leaf {
color: green;
}
}
// Example #2
.tree__branch--green__twig__leaf {
color: green;
<a href="#" onclick="document.getElementById("block-order-detail").scrollIntoView();">This is my link text</a>
@Oldenborg
Oldenborg / triangle-of-doom.js
Created November 12, 2018 12:16
Example of the triangle of doom
const verifyUser = function(username, password, callback){
dataBase.verifyUser(username, password, (error, userInfo) => {
if (error) {
callback(error)
}else{
dataBase.getRoles(username, (error, roles) => {
if (error){
callback(error)
}else {
dataBase.logAccess(username, (error) => {
@Oldenborg
Oldenborg / products.vue
Last active November 5, 2018 10:28
NetliftyCMS prerender folders
<template>
...
</template>
<script>
export default {
data() {
return {
product: Object
}
@Oldenborg
Oldenborg / vue.config.js
Last active October 2, 2018 11:19
This snippet will allow index files from the public folder to be copied to dist folder, this is nessesary in a Vue+NetlfiyCMS setup
module.exports = {
chainWebpack: config => {
config
.plugin('copy')
.use(require('copy-webpack-plugin'), [[{
from: 'public',
ignore: ['./index.html', '.DS_Store']
}]])
}
}
@Oldenborg
Oldenborg / diode.sass
Last active November 22, 2017 10:42
sass / css component to make a simple diode
$block: diode
$diameter: 0.5rem
+component
width: $diameter
height: $diameter
background: $idle
display: inline-block
border: 2px solid white
margin-right: $margin_xs
@Oldenborg
Oldenborg / mix.sass
Last active November 11, 2021 23:39
=vendor($attribute, $value)
-webkit-#{$attribute}: #{$value}
-moz-#{$attribute}: #{$value}
-ms-#{$attribute}: #{$value}
-o-#{$attribute}: #{$value}
#{$attribute}: #{$value}
=rotate($deg)
display: inline-block
+vendor(transform, rotate(#{$deg}deg))
@Oldenborg
Oldenborg / getSpecificModelRelationships.php
Last active September 27, 2016 08:00
Laravel - Get Model with specific relations
<?php
$clinics = new Clinic;
if($request->modules)
{
foreach($request->modules as $module)
{
$clinics = $clinics->whereHas('modules', function ($query) use ($module) {
$query->where('modules.id',$module);
});
}
@Oldenborg
Oldenborg / global.sass
Last active June 23, 2021 12:52
Remove antpaths from focused elements
// Remove antpaths from focused elements
a:focus,
select:focus,
input:focus
outline: medium none !important
button:focus
outline: 0
button::-moz-focus-inner,