Skip to content

Instantly share code, notes, and snippets.

@vjaro
vjaro / grokking_to_leetcode.md
Created April 23, 2022 19:36 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@vjaro
vjaro / createStoredFunctionDBAL.php
Created April 8, 2020 18:16
How to create MySQL Stored Functions using Doctrine DBAL in SugarCRM
<?php
if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
require_once('include/entryPoint.php');
function getPDOConnection()
{
global $sugar_config, $db;
@vjaro
vjaro / getAge.sql
Created April 8, 2020 17:07
How to create MySQL Stored Functions using PDO in SugarCRM
DROP FUNCTION IF EXISTS getAge;
CREATE FUNCTION getAge(date_of_birth DATE) RETURNS INT
BEGIN
DECLARE age INT DEFAULT 0;
SELECT TIMESTAMPDIFF(YEAR,date_of_birth,CURDATE()) INTO age;
RETURN age;
END;
@vjaro
vjaro / createStoredFunction.php
Created April 8, 2020 17:07
How to create MySQL Stored Functions using PDO in SugarCRM
<?php
if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
require_once('include/entryPoint.php');
function getPDOConnection()
{
global $sugar_config;
@vjaro
vjaro / RegisterCaseStatusCommand.php
Created April 8, 2020 14:50
SugarCRM custom console command registration
<?php
//define in custom/Extension/application/Ext/Console/RegisterCaseStatusCommand.php
Sugarcrm\Sugarcrm\Console\CommandRegistry\CommandRegistry::getInstance()
->addCommand(new Sugarcrm\Sugarcrm\custom\Console\Command\CaseStatusCommand())
;
@vjaro
vjaro / CaseStatusCommand.php
Last active April 8, 2020 14:56
SugarCRM Custom Command Definition
<?php
namespace Sugarcrm\Sugarcrm\custom\Console\Command;;
use Sugarcrm\Sugarcrm\Console\CommandRegistry\Mode\InstanceModeInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\Table;
//Create the file in custom/src/Console/Command/CaseStatusCommand.php
@vjaro
vjaro / Email Server (Linux, Unix, Mac).md
Created February 27, 2020 15:22 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@vjaro
vjaro / mysql-docker.sh
Created September 8, 2017 04:43 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
// iMacro CheatSheet - Command Reference
// http://wiki.imacros.net/Command_Reference
// iMacros supports 3 types of variables:
// * The macro variables !VAR0 thru !VAR9. They can be used with the SET and ADD command inside a macro.
// * Built-in variables. They contain certain values set by iMacros.
// * User-defined variables. They are defined in-macro using the SET command.
DEVICE=eth0
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.44
NETMASK=255.255.255.0
Setup NAT and Host Only adapter