Skip to content

Instantly share code, notes, and snippets.

View carlosequiz's full-sized avatar
🎯
Focusing

Carlos Equiz carlosequiz

🎯
Focusing
  • The Internet
View GitHub Profile
<?php
namespace NoxLogic\DemoBundle\Form\Type;
use Doctrine\ORM\EntityManager;
use NoxLogic\DemoBundle\Entity\Province;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@carlosequiz
carlosequiz / intro-functional-programming.js
Created April 29, 2019 17:18
A Functional Programmer’s Introduction to JavaScript from Eric Elliot's Composing Software
// EXPRESSIONS AND VALUES
// A variable declared with the const keyword can’t be reassigned. This restriction is a good thing.
const hola = 'Hola';
// TYPES
const arreglo = [1, 2, 3];
const a = 'a';
const b = 'b';
@carlosequiz
carlosequiz / python-cheat-sheet.py
Last active October 21, 2020 15:53
Personal Python Cheat Sheet
# Getting class name
MyClass(x).__name__
# UTC timestamp 2020-03-04T17:50:26.376Z
now = datetime.datetime.utcnow()
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \
'.%03d' % (now.microsecond / 1000) + 'Z'
# Jupyter arguments
import itertools
from operator import itemgetter
sorted_animals = sorted(animals, key=itemgetter('size'))
animals = [{'name':'cow', 'size':'large'},{'name':'bird', 'size':'small'},{'name':'fish', 'size':'small'},{'name':'rabbit', 'size':'medium'},{'name':'pony', 'size':'large'},{'name':'squirrel', 'size':'medium'},{'name':'fox', 'size':'medium'}]
for key, group in itertools.groupby(sorted_animals, key=lambda x:x['size']):
print key,
print list(group)
@carlosequiz
carlosequiz / bobp-python.md
Created September 10, 2019 16:39 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@carlosequiz
carlosequiz / datetime_timezone.py
Created January 5, 2021 14:14
Dealing with Timezones and datetime
import datetime as dt
import pytz
date_time_str = '2021-01-06T01:10:54.269'
date_time_obj = dt.datetime.strptime(date_time_str, '%Y-%m-%dT%H:%M:%S.%f')
timezone = pytz.timezone('UTC')
timezone_date_time_obj = timezone.localize(date_time_obj)
timezone_date_time_now = dt.datetime.now(pytz.utc)