Skip to content

Instantly share code, notes, and snippets.

View sfelix-martins's full-sized avatar
πŸ’­

Samuel Martins sfelix-martins

πŸ’­
View GitHub Profile
@JesseObrien
JesseObrien / gist:7418983
Last active December 4, 2024 10:13
Bind parameters into the SQL query for Laravel ORM
<?php
class MyModel extends Eloquent {
public function getSql()
{
$builder = $this->getBuilder();
$sql = $builder->toSql();
foreach($builder->getBindings() as $binding)
{
@rmariuzzo
rmariuzzo / sprintf.js
Created February 2, 2014 01:16
Simple and minimal `sprintf` function in JavaScript.
function sprintf(format) {
var args = Array.prototype.slice.call(arguments, 1);
var i = 0;
return format.replace(/%s/g, function() {
return args[i++];
});
}
@vluzrmos
vluzrmos / paginate.php
Created July 20, 2016 14:31
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginaΓ§Γ£o dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@flyingluscas
flyingluscas / UsingFakerInPT-BR.md
Last active October 25, 2025 21:15
Utilizando Faker em pt-BR

Utilizando Faker em pt-BR

Acesse o seu arquivo app/Providers/AppServiceProvider.php, e no mΓ©todo register adicione o seguinte :

/**
 * Register any application services.
 *
 * @return void
 */
@veny
veny / gist:6c72c7bf89fd464b28c7512d2c472a5e
Last active February 27, 2021 17:57
PHP, RSA, Encrypt/Decrypt
<?php
// generate private/public key as follows:
// > openssl genrsa -out private.pem 2048
// > openssl rsa -in private.pem -outform PEM -pubout -out public.pem
$data = "String to encrypt";
$privKey = openssl_pkey_get_private('file:///path/to/private.pem');
$encryptedData = "";
@josephhanson
josephhanson / MockFile.js
Last active June 13, 2025 14:19
Mock file for JavaScript based file upload - with basic test harness
// mock file
function MockFile() { };
MockFile.prototype.create = function (name, size, mimeType) {
name = name || "mock.txt";
size = size || 1024;
mimeType = mimeType || 'plain/txt';
function range(count) {
var output = "";
@virolea
virolea / upload.js
Last active December 12, 2024 16:14
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@antoniopresto
antoniopresto / banco_codigo.json
Last active September 30, 2025 16:57
JSON bancos do brasil com cΓ³digo
[
{
"value": "001",
"label": "Banco do Brasil S.A."
},
{
"value": "003",
"label": "Banco da AmazΓ΄nia S.A."
},
{
```zshrc
#β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–„β–ˆ β–ˆβ–„ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
#β–ˆβ–ˆβ–€ β–„β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ
# β–„β–ˆβ–ˆβ–ˆβ–€ β–ˆβ–ˆβ–ˆ β–ˆβ–€ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–€
#β–€β–ˆβ–€β–„β–ˆβ–ˆβ–ˆβ–€β–„β–„ β–ˆβ–ˆβ–ˆ β–„β–ˆβ–ˆβ–ˆβ–„β–„β–„β–„β–ˆβ–ˆβ–ˆβ–„β–„ β–„β–ˆβ–ˆβ–ˆβ–„β–„β–„β–„β–ˆβ–ˆβ–€ β–ˆβ–ˆβ–ˆ
# β–„β–ˆβ–ˆβ–ˆβ–€ β–€ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–€β–€β–ˆβ–ˆβ–ˆβ–€β–€β–€β–€β–ˆβ–ˆβ–ˆβ–€ β–€β–€β–ˆβ–ˆβ–ˆβ–€β–€β–€β–€β–€ β–ˆβ–ˆβ–ˆ
#β–„β–ˆβ–ˆβ–ˆβ–€ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–„
#β–ˆβ–ˆβ–ˆβ–„ β–„β–ˆ β–„β–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ
#β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€ β–ˆβ–ˆβ–ˆ β–ˆβ–€ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€
# β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ
sudo apt-get install apache2-dev
# or yum install httpd-tools
ab -n 9999 -c 333 http://localhost:80/

(9999 nr re requisiΓ§Γ΅es)
(333 quantidade de vezes)
```sh