Skip to content

Instantly share code, notes, and snippets.

View einnar82's full-sized avatar
🎯
Doing nice things.

Rannie Ollit einnar82

🎯
Doing nice things.
View GitHub Profile
@einnar82
einnar82 / QueryParameterSearchFilter
Created June 9, 2023 01:59
Query filter using request routes in Laravel
<?php
namespace App\Filters\Search;
use Closure;
use Illuminate\Support\Arr;
use Laravel\Scout\Builder;
class QueryParameterSearchFilter
{
@einnar82
einnar82 / IERC20.sol
Last active August 15, 2022 11:46
ERC20 Token standard
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
@einnar82
einnar82 / config.txt
Created February 10, 2022 11:30
Docker config DNS
Just change the nameserver lines in /etc/resolv.conf to:
nameserver 8.8.8.8
nameserver 8.8.4.4
@einnar82
einnar82 / index.php
Created December 15, 2021 06:26
PHP refresher
<?php
$name = 'rannie';
print $name;
function greetPerson($person)
{
// return '<br />hi '.$person;
return "<br />hi $person";
@einnar82
einnar82 / BaseRepository.php
Created November 21, 2021 07:25
Sample Repository Pattern for Laravel
<?php
namespace App\Repositories;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\Paginator;
abstract class BaseRepository
{
protected Model $model;
@einnar82
einnar82 / gist:4f8c3054448157db14daf608f35715be
Created October 25, 2021 07:23 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
<?php
//answer for https://www.testdome.com/questions/php/file-owners/11840?visibility=17&skillId=5
class FileOwners
{
public static function groupByOwners($files)
{
$result=array();
foreach($files as $key=>$value)
{
$result[$value][]=$key;
@einnar82
einnar82 / README.md
Created September 8, 2021 09:01 — forked from hakre/README.md

Extend from SoapClient Examples

Just a collection gist of some assorted example SOAPClients. Code must not be stable or useful under all circumstances, these are examples. Most of the code is outdated, so you won't need to use it any longer in production code. I've just collected and compiled this together out of interest, the information normally is scattered around.

If you need to a start with PHP's SOAPClient start with the PHP manual page of it and read through the comments as well. Double check with exisiting bug-reports if given as many things are fixed since a comment was left.

@einnar82
einnar82 / hmac-sha512.js
Created August 25, 2021 13:14
HMAC SHA512 Encryption
var crypto = require("crypto");
function encrypt(key, str) {
var hmac = crypto.createHmac("sha512", key);
var signed = hmac.update(new Buffer(str, 'utf-8')).digest("base64");
return signed
}
@einnar82
einnar82 / docker-compose.yml
Last active July 21, 2021 05:57
Kong DB Less config
version: "3.7"
services:
kong:
image: kong:latest
volumes:
- ./kong.yml:/usr/local/kong/declarative/kong.yml
environment:
- KONG_DATABASE=off
- KONG_DECLARATIVE_CONFIG=/usr/local/kong/declarative/kong.yml
- KONG_PROXY_ACCESS_LOG=/dev/stdout