Skip to content

Instantly share code, notes, and snippets.

View bjornbjorn's full-sized avatar

Bjørn Børresen bjornbjorn

View GitHub Profile
@bjornbjorn
bjornbjorn / app.js
Last active February 25, 2022 21:08
Laravel Livewire tiptap.dev editor with blade component saving content on blur
import Tiptap from './tiptap';
Alpine.data('tiptapEditor', Tiptap);
window.Alpine = Alpine
Alpine.start()
...
@bjornbjorn
bjornbjorn / TwigBridge.php
Created January 19, 2022 07:56
Getting innocenzi/laravel-vite to work with TwigBrigde
// In TwigBridge.php (or a better location if you don't want to be too hacky)
use Innocenzi\Vite\Vite;
use Twig\TwigFunction;
lass ViteExtension extends Twig\Extension\AbstractExtension {
public function getFunctions()
{
return [
@bjornbjorn
bjornbjorn / switch.sh
Created September 30, 2019 08:27
Flutter "flavoring"
#!/usr/bin/env bash
flavorName=$1;
[ "$flavorName" == "" ] && { echo "Usage: $0 <client name>"; exit 1; }
if [ -d "clients/$flavorName" ]; then
echo "Client $flavorName found .."
plutil -replace CFBundleIdentifier -string no.lastfriday.heyho.rebusloep.$flavorName ios/Runner/Info.plist
@bjornbjorn
bjornbjorn / main.dart
Created August 28, 2019 07:03
Todo app main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@bjornbjorn
bjornbjorn / map.html
Last active November 20, 2017 13:17
Search bar + drag and drop pin to let users specify a geolocation - results saved to lat/long input fields (which can be hidden in the form)
<!DOCTYPE html>
<html lang="nb">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body>
<title>{title}{site_name}</title>
<meta name='keywords' content='{meta_keywords}' />
<meta name='description' content='{meta_description}' />
<link rel='canonical' href='{canonical_url}' />
<meta property="og:url" content="{canonical_url}"/>
<meta property="og:title" content="{entry_title}"/>
<meta property="og:description" content="{extra:desc}"/>
<meta property="og:image" content="{extra:image}"/>
@bjornbjorn
bjornbjorn / structure_views_index.php.diff
Created January 6, 2014 12:26
Hack for enabling Structure (3.3.13) to allow url_title "/" on root node
---
third_party/structure/views/index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/third_party/structure/views/index.php b/third_party/structure/views/index.php
index 2bf7e9d..2db600f 100755
--- a/third_party/structure/views/index.php
+++ b/third_party/structure/views/index.php
@@ -47,7 +47,7 @@ $level_lock_delete = is_numeric(substr($permissions['delete'], -1)) ? (int)subst
@bjornbjorn
bjornbjorn / api.total.php
Created April 10, 2013 16:58
Replacing {filedir_1} in channel_data
$grid_image = str_replace('{filedir_1}', '/uploads/', $grid_image);
/**
This is how the above _should_ be done:
if (preg_match('/^{filedir_(\d+)}/', $src, $matches))
{
$filedir_id = $matches[1];
$this->EE->load->model('file_upload_preferences_model');
@bjornbjorn
bjornbjorn / functions.php
Created November 19, 2015 08:44
Remove "Page Analysis" + "Focus Keyword" functionality from Yoast SEO
// Note, I used Timber so my functions.php includes a class that extends TimberSite, but the gist here will be the same;
// add an action that outputs css in the admin to hide some Yoast SEO features.
// in functions.php, add this action:
add_action('admin_head', array($this, 'wpseo_css'));
// Then you need this wpseo_css function in the same class:
/**
@bjornbjorn
bjornbjorn / ext.oktan_web.php
Created October 1, 2012 14:00
Norwegian URL titles conversion array
/**
* Make sure url-titles look good for non-english entries also
*/
public function on_foreign_character_conversion_array()
{
return array(
'216' => 'o', // ø
'248' => 'o', // Ø
'198' => 'a', // æ
'230' => 'a', // Æ