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 / 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 / https redirect
Last active August 29, 2015 14:11
secure http -> https redirect in master config (EE)
/**
* Force HTTPS on prod & staging. This functionality was previously in the .htaccess'es but we moved
* it here to ease multiple environment development.
*/
if(FORCE_HTTPS && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "")){
$redirect_url = filter_var("https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], FILTER_VALIDATE_URL);
if($redirect_url) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: $redirect_url");
die();
@bjornbjorn
bjornbjorn / gist:c5c6b59492b5ae2cc245
Created August 26, 2014 06:26
Freeform AJAX submit
var validated = false;
$('body').on('submit', '.upload-cv-form', function(e) {
if(validated) {
return true;
}
// else do validation
e.preventDefault();
@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 / 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>
@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');