Skip to content

Instantly share code, notes, and snippets.

View angelmartz's full-sized avatar

Juan Angel Martínez Lopez angelmartz

  • CDMX, Mexico
  • 03:26 (UTC -06:00)
View GitHub Profile
/*
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@angelmartz
angelmartz / DemoSpringAppApplication.java
Created September 22, 2022 04:20 — forked from vy/DemoSpringAppApplication.java
How to pass a Spring property to Log4j in a Spring Boot application
package com.vlkan.demo.spring;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.annotation.PostConstruct;
@angelmartz
angelmartz / Optional.php
Created October 17, 2021 10:25 — forked from derekmd/Optional.php
Laravel global helper function `optional()`
<?php
namespace App\Support;
class Optional
{
/**
* The target being transformed.
* Use _ prefix to avoid namespace conflict on __get()
*
@angelmartz
angelmartz / WSSoapClient.php
Created September 18, 2021 23:15 — forked from johnkary/WSSoapClient.php
WS-Security for PHP SoapClient
<?php
/**
* Copyright (c) 2007, Roger Veciana
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
E70JHCOV2H-eyJsaWNlbnNlSWQiOiJFNzBKSENPVjJIIiwibGljZW5zZWVOYW1lIjoi5bGx5Lic55CG5bel5aSn5a2mIiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMjEtMDItMTgifSx7ImNvZGUiOiJBQyIsInBhaWRVcFRvIjoiMjAyMS0wMi0xOCJ9LHsiY29kZSI6IkRQTiIsInBhaWRVcFRvIjoiMjAyMS0wMi0xOCJ9LHsiY29kZSI6IlBTIiwicGFpZFVwVG8iOiIyMDIxLTAyLTE4In0seyJjb2RlIjoiR08iLCJwYWlkVXBUbyI6IjIwMjEtMDItMTgifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAyMS0wMi0xOCJ9LHsiY29kZSI6IkNMIiwicGFpZFVwVG8iOiIyMDIxLTAyLTE4In0seyJjb2RlIjoiUlMwIiwicGFpZFVwVG8iOiIyMDIxLTAyLTE4In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMjEtMDItMTgifSx7ImNvZGUiOiJSRCIsInBhaWRVcFRvIjoiMjAyMS0wMi0xOCJ9LHsiY29kZSI6IlBDIiwicGFpZFVwVG8iOiIyMDIxLTAyLTE4In0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMjEtMDItMTgifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAyMS0wMi0xOCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDIxLTAyLTE4In0seyJjb2RlIjoiREMiLCJwYWlkVXBUbyI6IjIwMjEtMDItMTgifSx7I
'use strict';
/** @type {!Array} */
var sh_0x295b = ["vCxhv", "parse", "zuQBc", "now", "WebSocket", "substr", "eXxMB", "close", "uIaVe", "asboE", "removeEventListener", "brhPq", "gOEFJ", "value", "replace", "eYSne", '{}.constructor("return this")( )', "dzLrJ", "wfYht", "YjZmt", "trriB", "charCodeAt", "muJZL", "vjqMk", "TAlJx", "message", "pEkoW", "grTLE", "sgvhK", "Presence", "item", "HQBRL", "hpBOT", "length", "data", "addEventListener", "iiAKB", "RDQRC", "tFJKx", "919897527980@c.us", "rJiXa", "apply", "vvaZV", "YfLjs", "return (function() ",
"ZLwwv", "lastseen", "QLtCF", "tVLLU", "iezjr", "tSJkN", "IBKxS", "nQCfZ", "open", "cOmna", "oABJu", "mAOGl", "fXZrV", "ARmMv", "gsmwU", "Kwnes", "iqsVl", "fsdbL", "RImqa", "[WMuYzLMuXGikOxLjyzZfgPGqTPMOCIGgyyZuSOrS]", "send", "log", "split", "KUofk", "indexOf", "VDPWB", "lNhvE", "pFWMT", "type", "CSyZZ", "cxqeM", "IgEPy", "ITrrU", "FYEQg", "WzCOr", "jdWeC", "ZOTaA", "gkgro", "fnAqC", "attribute", "bZPwU", "YPPzq", "zMVQG", "FRxyy", "IbjiS"];
(function(data, i) {
/**
@angelmartz
angelmartz / AppName.php
Created March 21, 2020 23:10 — forked from isluewell/AppName.php
[6.0] Command app:name
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Composer;
use Symfony\Component\Finder\Finder;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
@angelmartz
angelmartz / aes_enc_dec.php
Created March 9, 2020 17:50 — forked from turret-io/aes_enc_dec.php
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@angelmartz
angelmartz / CreatesWithLock.php
Created March 6, 2020 00:39 — forked from troatie/CreatesWithLock.php
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@angelmartz
angelmartz / Laravel-Container.md
Created January 29, 2020 22:24
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).