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 / 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 / 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 / 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 / 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 / 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 / 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 / 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()
...