Skip to content

Instantly share code, notes, and snippets.

View j2deme's full-sized avatar

Jaime Jesús Delgado Meraz j2deme

  • TecNM Campus Ciudad Valles
  • Ciudad Valles, San Luis Potosi, México
  • 18:19 (UTC -06:00)
View GitHub Profile
@pekka
pekka / TaskObserver.php
Last active October 17, 2023 09:15
Addition to Laravel Daily's mini tutorial "Filament & Laravel: Delete Unused Files if Model is Updated/Deleted" - a "saved()" method that can handle the image field set to multiple
public function saved(Task $task): void
{
if ($task->isDirty('attachment')) {
$originalFieldContents = $task->getOriginal('attachment');
$newFieldContents = $task->attachment;
# We attempt to JSON decode the field. If it is an array, this is an indication we have ->multiple() activated
$originalFieldContentsDecoded = json_decode($task->getOriginal('attachment'));
@dlech
dlech / multitask.py
Last active March 28, 2023 14:09
Example of LEGO SPIKE Prime scratch program translated to MicroPython using generator functions as coroutines
# spike.control.wait_for_seconds doesn't allow decimal points
# so we replace it with the standard MicroPython sleep function instead
from utime import sleep as wait_for_seconds
from utime import ticks_diff, ticks_ms
# See https://docs.micropython.org/en/latest/library/utime.html for more info on the utime module
from spike import (PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor,
Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair)
from spike.control import wait_until
<?php
/**
* Generate a random human-readable passwort
* Including the modifications by Josh Hartman made on 12/30/2010. https://github.com/joshhartman
* Josh added the ability to append a double digit number
* I added a parameter to decide on whether to append the number
*
* Also, if the length is not dividable by 2, the length of the password will be $length + 1
*
* @param int $length

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

<?php
$email = isset( $_GET['email'] ) ? $_GET['email'] : 'null';
$salt = isset( $_GET['salt'] ) ? $_GET['salt'] : '';
// hash email, split it up
$hash = str_split( sha1( $email . $salt ), 2 );
// use first 3 values for foreground
$foreground = "{$hash[0]}{$hash[1]}{$hash[2]}";
@bryangreen
bryangreen / Inflector.php
Last active October 24, 2020 00:50
Twig Inflector Extension - For plural and singular English words
<?php
/**
* ReadySetData 2009-2013
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@bosconian-dynamics
bosconian-dynamics / abbreviate.php
Last active March 2, 2020 04:45
PHP function to calculate an alphanumeric abbreviation for a string based on capitalization and length. Useful for generating semi-unique (but still human-interpretable) identifiers from things like class or plugin names.
<?php
/**
* PHP function to calculate an alphanumeric abbreviation for a string based on capitalization and
* length. Useful for generating semi-unique (but still human-interpretable) identifiers from things
* like class or plugin names.
*
* PHP version 5
*
* LICENSE: GPL v3 - Look it up!
*
@MinecrafterJPN
MinecrafterJPN / BlockItemList.md
Last active February 1, 2019 12:47
Minecraft PE Block / Item List

Block List

ID => BlockName

		0 => "Air"
		1 => "Stone"
		2 => "Grass"
		3 => "Dirt"
		4 => "Cobblestone"

5 => "WoodenPlank"

@bhgraham
bhgraham / marblemousefix.sh
Created November 12, 2012 18:03
marblemouse fix stupid scrolling/copy paste action
xinput set-button-map "Logitech USB Trackball" 1 8 3 4 5 6 7 2 9
@sway
sway / commits-by-hour
Created July 11, 2012 20:25 — forked from bobuss/commits-by-hour
Git commits funstats
#!/usr/bin/env bash
for i in $(seq -f %02g 0 23); do echo $( echo -e "$i\t"; git shortlog -n --format='%ad %s' | grep " $i:" | wc -l); done