Skip to content

Instantly share code, notes, and snippets.

View rstriquer's full-sized avatar
🎯
focused

Ricardo Striquer Soares rstriquer

🎯
focused
View GitHub Profile
@rstriquer
rstriquer / README.md
Created April 19, 2023 19:23
How to try a composer package hosted on a specific branch/tag version on a remote git repository

Let's consider we want to try the v1.0.0-rc2 on our package rstriquer/eloquent-logger hosted on github.

First you got to add the repository definition at your project's composer.json file:

  "repositories": [
    {
      "type":"package",
      "package": {
 "name": "rstriquer/eloquent-logger",
@rstriquer
rstriquer / simpleHTTPServer.sh
Created December 6, 2022 18:30
Simplest http server on python3
## with simple python:
#python -m SimpleHTTPServer 8009
# If you use Python 3, you should instead write
python3 -m http.server 8009
@rstriquer
rstriquer / udp-simple-wrapper.php
Last active November 11, 2022 01:30
Implements an UDP protocol server that will receive data packets through a port bind from any of the IPs available on the local machine and write the same content (in its entirety) to a third-party server specified in the command line.
<?php
// code inspired from https://www.binarytides.com/udp-socket-programming-in-php/
error_reporting(~E_WARNING);
$argv = RearrangeArguments([
['name' => '--localPort', 'type' => 'optional', 'cast' => 'string', 'default' => '9999'],
['name' => '--targetHost', 'type' => 'required', 'cast' => 'string', 'default' => ''],
['name' => '--targetPort', 'type' => 'required', 'cast' => 'string', 'default' => ''],
@rstriquer
rstriquer / Dockerfile
Last active March 15, 2022 12:44
PHP Dockerfile
# inspired on https://gist.github.com/Mikulas/449746102591d636640467910eaf8aad
# https://www.digitalocean.com/community/tutorials/how-to-install-and-set-up-laravel-with-docker-compose-on-ubuntu-20-04-pt
FROM php:8.1.3-alpine AS php8.1-local
# Arguments defined in docker-compose.yml
ARG user
ARG uid
ARG gid
RUN echo "UTC" > /etc/timezone
@rstriquer
rstriquer / DatabaseHelper.php
Last active June 16, 2022 18:40
dump sql no laravel
<?php
/**
* Return (Laravel) Eloquent Query Builder object as an SQLs with switched values.
* - add the function to app/helpers/database.php file and the file to autoload.
* files in the composer.json, the dquery will be available to all code over
* debug env
* @param \Illuminate\Database\Query\Builder $builder
*/
function dquery(Builder $builder) : string
{
@rstriquer
rstriquer / fooModel.php
Last active August 26, 2021 13:08
update model illuminate eloquent (laravel database)
# once i come accross this, seams to be a good thing to remember ..
# it creates a new record on database table and automatically replace objects attributes with the new created record
class fooModel
{
public function create(array $data)
{
if (!isset($data['id'])) {
$data['id'] = rand(0,999);
}
@rstriquer
rstriquer / instalike.js
Last active November 23, 2021 09:16 — forked from jadeallencook/instalike.js
Scripts that auto likes posts on instagram via tag.
// javascript function to use on terminal.
// based on code from https://gist.github.com/jadeallencook/139a3d5f9291c2d612d91c8b8c72a755
// more to considere: https://www.youtube.com/watch?v=yM0NIZ6wbEc
// script do login: https://github.com/mateovrb/instafollow
// script feito em phyton https://www.youtube.com/watch?v=0PdIP2Q2X4U
/**
* Get element by XPath
* - Get the xpath thrught the browser and use it to select that element.
* @param string path
@rstriquer
rstriquer / simple_mysql_procedure.sql
Created March 12, 2020 16:33
Exemplo de criação simples de procedures e funcions no mysql
DELIMITER //
DROP FUNCTION IF EXISTS `TSTE_BVASE`//
CREATE FUNCTION `TSTE_BVASE`() RETURNS TINYINT
BEGIN
DECLARE agora DATETIME;
SET agora = now();
@rstriquer
rstriquer / README.md
Last active August 4, 2022 07:47
Git command automation shell

Script for git command automation

Script to automate git day-to-day and validate of Pull Request code.

It presented some inconsistencies when used on windows (I had some problems, mainly with the command git stash).

For Linux it seems to be very functional, regardless of the installation.