Skip to content

Instantly share code, notes, and snippets.

View HDias's full-sized avatar
🏠
God is Better

Horecio Araújo Dias HDias

🏠
God is Better
View GitHub Profile
@HDias
HDias / cns.rb
Created December 23, 2022 03:24
CNS validator
def valid_cns?(cns)
# Verifica se o tamanho do CNS está correto
return false unless cns.length == 15
# Verifica se os primeiros 14 dígitos são números
return false unless cns[0..13].scan(/\D/).empty?
# Verifica se o último dígito é um número ou uma letra
return false unless cns[14] =~ /[\dX]/
@HDias
HDias / docker-rm.sh
Last active February 24, 2023 14:54
Docker remove images ans containers
# remove containers exited
docker rm $(docker ps -a -f status=exited -q)
# remove unused images
docker rmi $(docker images -f dangling=true -q)
# get IP from container
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
@HDias
HDias / rspec_model_testing_template.rb
Created September 23, 2022 14:23 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@HDias
HDias / terminal-colors-branch
Created September 2, 2020 02:49 — forked from danielalvarenga/terminal-colors-branch.sh
Show branch in terminal Ubuntu
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
@HDias
HDias / gist:37c3a725251696f66d73ca2d3f058d99
Last active September 6, 2018 21:52
Controller Action to Store Using POST and service Provider
<?php
/*In Provider*/
...
/**
* Register the application services.
*
* @return void
*/
public function register()
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'password' => '',
'dbname' => 'ecommerce',
'driverOptions' => array(
<?php
namespace User;
use Base\Hydrator\Strategy\DateTimeStrategy;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\FormElementProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
use Zend\ModuleManager\ModuleManager;
@HDias
HDias / designer.html
Last active August 29, 2015 14:18
designer
<link rel="import" href="../core-ajax/core-ajax.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
@HDias
HDias / composer.json
Created January 24, 2015 03:39
Composer.json Zf2
{
"name": "zendframework/limpeza-facil",
"description": "E-commerce",
"authors": [
{
"name": "HorecioDias",
"email": "horecio@gmail.com"
}
],
"keywords": [
@HDias
HDias / AnyContoller.php
Created December 29, 2014 20:46
In Controller
/**
* @return EntityManager
*/
protected function getEm()
{
if (null === $this->em)
$this->em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
return $this->em;
}