Skip to content

Instantly share code, notes, and snippets.

View dkesberg's full-sized avatar

Daniel Kesberg dkesberg

View GitHub Profile
@TadejPolajnar
TadejPolajnar / windowsTerminalSetup.md
Last active March 5, 2024 06:28
Windows WSL 2 terminal setup

Windows WSL 2 terminal setup

Prerequisites

Windows 10 version 2004 (Build 10941) or higher.

Enabled Windows Subsystem for Linux feature. To enable following enter in Powershell

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active April 29, 2025 19:26
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@Machy8
Machy8 / jquery.on.js
Last active November 23, 2024 23:41
jQuery .on() alternative in pure javascript (this handles events on dynamically added elements) 😎
/**
* @param {string} eventType
* @param {string} selector
* @param {function} callback
*/
function on(eventType, selector, callback) {
document.body.addEventListener(eventType, function (event) {
if (event.target.matches(selector)) {
callback.call(event.target);
}
@rodrigopedra
rodrigopedra / BelongsToManyInDifferentConnections.php
Created June 22, 2018 17:29
Laravel BelongsToMany in different connections
<?php
namespace App\Models;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class BelongsToManyInDifferentConnections extends BelongsToMany
@garywoodfine
garywoodfine / pbcopyfy
Last active March 13, 2025 00:52
Simple Script to configure pbcopy like functionality on ubuntu
#!/bin/sh
# Copyright (C) 2009-2017 Three Nine Consulting
# Always good practice to update packages. However ask user if they would like to do so
# For explanation on how this works and why check out https://garywoodfine.com/use-pbcopy-on-ubuntu/
read -p "Do you want to update your package repositories before proceeding ? " -n 1 -r
echo #adding new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
fi
@jrmadsen67
jrmadsen67 / gist:bd0f9ad0ef1ed6bb594e
Last active August 19, 2024 10:37
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@sscovil
sscovil / gist:d1927f8fd0a1da53e62e
Last active December 25, 2015 01:19
Sass drop shadow mixin for PNG images with transparent backgrounds
@mixin dropShadow($offX: 2, $offY: 2, $blur: 2, $rgba: rgba(0, 0, 0, 0.3), $hex: #B2B2B2) {
-webkit-filter: drop-shadow(#{$offX}px #{$offY}px #{$blur}px $rgba);
filter : url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='drop-shadow'><feGaussianBlur in='SourceAlpha' stdDeviation='" + $blur +"'/><feOffset dx='" + $offX + "' dy='" + $offY + "' result='offsetblur'/><feFlood flood-color='#{$rgba}'/><feComposite in2='offsetblur' operator='in'/><feMerge><feMergeNode/><feMergeNode in='SourceGraphic'/></feMerge></filter></svg>#drop-shadow");
-ms-filter : "progid:DXImageTransform.Microsoft.Dropshadow(OffX=" + $offX + ", OffY=" + $offY + ", Color='" + $hex + "')";
filter : "progid:DXImageTransform.Microsoft.Dropshadow(OffX=" + $offX + ", OffY=" + $offY + ", Color='" + $hex + "')";
}
@elena-kolevska
elena-kolevska / validators.php
Last active June 24, 2021 14:44
Custom alphabetic validator that allows spaces
<?php
/* app/validators.php */
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s]+$/u', $value);
});
/*
@eyecatchup
eyecatchup / GetPlusOnesByURL.php
Last active February 13, 2024 16:39
Several PHP functions to get the +1 count from Google+ users for a given URL.
<?php
/**
* GetPlusOnesByURL()
*
* Get the numeric, total count of +1s from Google+ users for a given URL.
*
* Example usage:
* <code>
* $url = 'http://www.facebook.com/';
* printf("The URL '%s' received %s +1s from Google+ users.", $url, GetPlusOnesByURL($url));
@didats
didats / nationality.html
Created December 28, 2013 00:00
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>