Skip to content

Instantly share code, notes, and snippets.

View niladam's full-sized avatar

Madalin Tache niladam

View GitHub Profile
<?php
namespace App\Helper;
trait WpTrait
{
/**
* Replaces double line-breaks with paragraph elements.
@niladam
niladam / romanian-cif-validate.js
Created May 30, 2023 07:15 — forked from brokenthorn/romanian-cif-validate.js
Functie Javascript pentru validarea CIF (Cod Identificare Fiscala) / CUI (Cod Unic Identificare)
/**
* Validates if a string conforms to a valid Romanian Fiscal Code.
*
* See Romanian Law no. 359 from 8 September 2004.
* @param v {string} input string to be validated
* @returns {string|boolean} `true` if the input is a valid CIF or an error message,
* describing where validation failed
*/
function validateRomanianCIF (v) {
if (typeof v !== 'string') {
exiftool -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" "-FileCreateDate<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json .
@niladam
niladam / nginx-webp-sample.conf
Created March 6, 2023 13:00 — forked from uhop/nginx-webp-sample.conf
Serving WEBP with nginx conditionally.
user www-data;
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
@niladam
niladam / CreateBarCode.php
Created May 20, 2022 07:01 — forked from kaystrobach/CreateBarCode.php
Convert UUIDs into BigInt with ramsey/uuid
<?php
// needs picqer/php-barcode-generator
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
$barcode = $generator->getBarcode($data, $generator::TYPE_CODE_128, 3, 100, [0,0,0]);
// ensure the char count is even for CODE_128_C
$barcodeData = (strlen($data) % 2) === 0 ? $data : '0' . $data;
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
@niladam
niladam / box-shadow.html
Created October 22, 2020 12:47 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@niladam
niladam / User.php
Last active September 24, 2020 10:41
Laravel 8 use gravatar as default profile photo
<?php
namespace App\Models;
use Illuminate\Support\Str;
class User extends Authenticatable
{
// [...] Your other User methods/properties here
@niladam
niladam / mv.sh
Created April 19, 2020 12:22 — forked from premek/mv.sh
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@niladam
niladam / generate-ssh-key.sh
Created March 22, 2020 09:54 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
<?php
namespace App\Concerns;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
trait Resourceable
{
public function toResourceArray(?string $class = null, ?Request $request = null): array