Skip to content

Instantly share code, notes, and snippets.

View vielhuber's full-sized avatar
🍐
❹❷

David Vielhuber vielhuber

🍐
❹❷
View GitHub Profile
@vielhuber
vielhuber / README.MD
Last active January 10, 2023 12:21
github actions

setup

  • add /.github/workflows/ci.yml
  • see preset below that supports phpunit, npm, mysql, postgres, sqlite
  • push with new version tag to github
  • add a badge to README.MD: [![build status](https://github.com/username/repo/actions/workflows/ci.yml/badge.svg)](https://github.com/username/repo/actions)
  • enjoy

environment variables

@vielhuber
vielhuber / _index.html
Last active February 2, 2023 15:42
hcaptcha #js #php
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, minimum-scale=1" />
<title>hcaptcha</title>
<script>
class App {
init() {
window.addEventListener('load', (e) => {
@vielhuber
vielhuber / post.php
Last active March 7, 2023 08:33
enable embed youtube get_the_content() shortcode #wordpress
apply_filters('the_content', get_the_content());
@vielhuber
vielhuber / README.MD
Last active December 14, 2022 09:24
sessions #php
  • if you want to store sensitive information very easily on the server (and not on the client) and don't want to use a database
  • a session cookie is stored on the client to identify the user
  • the session cookie ends until the user closes the browser (but it can be extended)
  • sessions can also be used on backends that are called via javascript

start session

session_start();
@vielhuber
vielhuber / functions.php
Created November 24, 2022 14:17
wpml programmatically insert post in all languages #wordpress
// this should be run e.g. on a rest api route
// don't run this on admin_init hook (since it conflicts with the users session)
add_action('rest_api_init', function () {
register_rest_route('v1', '/debug', [
'methods' => \WP_REST_Server::READABLE,
'permission_callback' => function (\WP_REST_Request $request) { return true; },
'callback' => function (\WP_REST_Request $request) {
global $sitepress;
// insert post in default language
$sitepress->switch_lang('de');
@vielhuber
vielhuber / index.html
Last active April 23, 2023 19:12
cursor effect #css #js
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, minimum-scale=1" />
<title>.</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.body.insertAdjacentHTML('beforeend', '<div class="smooth-cursor"></div>');
let smoothCursor = document.querySelector('.smooth-cursor');
@vielhuber
vielhuber / 0.README.MD
Last active May 10, 2023 09:58
use uuids as primary keys in laravel #php

laravel >=9

  • on laravel 9 you can use the built in trait

  • however if you want to have more control you also can use the custom trait below

    • see 0.Test.php

laravel <=8

@vielhuber
vielhuber / functions.php
Created October 11, 2022 22:17
allow editors role to edit wpml > string translations in backend #wordpress
// add this ONCE, then open up the backend, then remove this again (because this modifies the database!)
$role_object = get_role( 'editor' );
$role_object->add_cap( 'wpml_manage_string_translation' );
// alternative: Capability Manager Enhanced
@vielhuber
vielhuber / README.MD
Last active October 4, 2022 21:36
circular dependency tailwindcss #css

html

<div class="
    w-full
    h-96
    text-white
    bg-black
    after:relative
    after:-top-8