Skip to content

Instantly share code, notes, and snippets.

View angelparras's full-sized avatar
🤓
Updating 99%...

Ángel Parras angelparras

🤓
Updating 99%...
View GitHub Profile
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 "link to youtube video"
@angelparras
angelparras / databases_size.sql
Last active December 2, 2019 19:06
MySQL query databases size
SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
@angelparras
angelparras / gist:fb929b67747d4d29395426fe466a7afc
Created November 25, 2019 12:56
Must-have packages for Finance and Data Science
import os
import numpy
import pandas
import matplotlib
import math
import random
import statsmodels
import pandas_datareader
@angelparras
angelparras / special_methods.md
Last active November 19, 2019 09:43
Python special method names

Python special method names

String/bytes representation __repr__ , __str__ , __format__ , __bytes__

Conversion to number __abs__ , __bool__ , __complex__ , __int__ , __float__ , __hash__ , __index__

Emulating collections __len__ , __getitem__ , __setitem__ , __delitem__ , __contains__

Iteration __iter__ , __reversed__ , __next__

@angelparras
angelparras / curl.php
Created November 14, 2019 09:21
curl request php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.example.com/example/.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'hi, im a bot'); /* Don't forget to name yourself! */
$posts = curl_exec($ch);
curl_close($ch);
$posts = json_decode($posts, true);
print_r($posts);
@angelparras
angelparras / load_csv_with_header_to_table.sql
Created November 3, 2019 14:29
Load csv with header row into table in MySQL
LOAD DATA LOCAL INFILE '/<absolute path>/<filename>.csv' INTO TABLE table_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES;
from enum import Enum, unique
@unique
class HttpStatusCode(Enum):
""" Http Status Code Enum.
Example usage:
HttpStatusCode.OK.value # 100
mkdir -p /home/username/.ssh
mkdir -p /home/username/.ssh
touch /home/username/.ssh/authorized_keys
useradd -d /home/username username
usermod -aG username
chown -R username:username /home/username/
chown root:root /home/username
chmod 700 /home/username/.ssh
chmod 644 /home/username/.ssh/authorized_keys
$classMetaData = $em->getClassMetadata($className);
$connection = $em->getConnection();
$dbPlatform = $connection->getDatabasePlatform();
$connection->beginTransaction();
try {
$connection->query('SET FOREIGN_KEY_CHECKS=0');
$q = $dbPlatform->getTruncateTableSql($classMetaData->getTableName());
$connection->executeUpdate($q);
$connection->query('SET FOREIGN_KEY_CHECKS=1');
$connection->commit();