Skip to content

Instantly share code, notes, and snippets.

View leonardorifeli's full-sized avatar
🏡
Working from home

Leonardo Rifeli leonardorifeli

🏡
Working from home
View GitHub Profile
@leonardorifeli
leonardorifeli / Users.class.php
Created June 21, 2014 17:51
88bit - Classe de usuários
<?php
class Users extends DataBase {
public $id;
public $email;
public $birthDate;
public $fullName;
public $city;
public $state;
@leonardorifeli
leonardorifeli / generator.php
Created October 15, 2015 14:08 — forked from tawfekov/generator.php
Doctrine2 Generate Entities form Existing Database
<?php
include '../vendor/autoload.php';
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();
// config
$config = new \Doctrine\ORM\Configuration();
@karmi
karmi / tagcloud.sh
Last active September 4, 2017 02:01
Simple tag cloud with ElasticSearch `terms` facet
# (Re)create the index
curl -X DELETE "http://localhost:9200/tagcloud"
curl -X PUT "http://localhost:9200/tagcloud"-d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
@leonardorifeli
leonardorifeli / People.php
Last active September 22, 2017 14:46
Working with annotations using the doctrine annotation reader
<?php
/**
* @PeopleAnnotation(description="Get all information about a people", type="class")
*/
class People {
/**
* @PeopleAnnotation(description="Use to people name", type="attribute")
*/
@xthiago
xthiago / Approach 01 - rely on a third-party service.md
Last active July 16, 2019 19:37
Alternatives to test classes that rely on system time.

Value object that depends on system time:

<?php

declare(strict_types=1);

namespace Xthiago;

final class BirthDate
// the wizare functions
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
@pjrt
pjrt / S3Puller.scala
Created May 14, 2015 19:15
S3 List Status ad-infinitude
import com.amazonaws.services.s3._, model._
import com.amazonaws.auth.BasicAWSCredentials
val request = new ListObjectsRequest()
request.setBucketName(bucket)
request.setPrefix(prefix)
request.setMaxKeys(pageLength)
def s3 = new AmazonS3Client(new BasicAWSCredentials(key, secret))
val objs = s3.listObjects(request) // Note that this method returns truncated data if longer than the "pageLength" above. You might need to deal with that.
@satendrakumar
satendrakumar / DataFrameWithFileName.scala
Last active October 21, 2020 14:48
Add file name as Spark DataFrame column
import org.apache.spark.sql.functions._
import org.apache.spark.sql.SparkSession
object DataFrameWithFileNameApp extends App {
val spark: SparkSession =
SparkSession
.builder()
.appName("DataFrameApp")
.config("spark.master", "local[*]")
@netojoaobatista
netojoaobatista / gitcowsay.sh
Last active January 4, 2021 18:58
Random commit messages
git config --global alias.cowsay '!git commit -m "`fortune | cowsay -f tux`"'
@juliandunn
juliandunn / postgresql-on-aws-tips.md
Last active September 27, 2022 10:55
Notes on PostgreSQL performance optimization on RDS

Deep Dive: PostgreSQL on AWS

When loading data

  • disable backups (backup_retention=0)
  • disable multi-AZ and autovacuum
  • pg_dump -Fc (compressed) and pg_restore -j (parallel)
  • Increase maintenance_work_mem