Skip to content

Instantly share code, notes, and snippets.

@hilam
hilam / database_to_parquet.py
Created January 13, 2022 20:38 — forked from rvaidya/database_to_parquet.py
Dump database table to parquet file using sqlalchemy and fastparquet. Useful for loading large tables into pandas / Dask, since read_sql_table will hammer the server with queries if the # of partitions/chunks is high. Using this you write a temp parquet file, then use read_parquet to get the data into a DataFrame
import pandas as pd
import numpy as np
import fastparquet
from sqlalchemy import create_engine, schema, Table
# Copied from pandas with modifications
def __get_dtype(column, sqltype):
import sqlalchemy.dialects as sqld
@hilam
hilam / blink.rpy
Created December 28, 2021 10:59 — forked from RuolinZheng08/blink.rpy
[RENPY] Dynamic Blink
@hilam
hilam / sampleREADME.md
Created January 24, 2020 23:24 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@hilam
hilam / spreadsheet.py
Created January 6, 2018 13:45 — forked from alchemyst/spreadsheet.py
Spreadsheet in 100 lines of Python
#!/usr/bin/env python
import tkinter as tk
import math
import re
from collections import ChainMap
Nrows = 5
Ncols = 5
@hilam
hilam / git-update-fork.sh
Created November 26, 2017 15:15 — forked from rdeavila/git-update-fork.sh
Git: como atualizar um fork com as mudanças do original?
#!/bin/bash
# Adicione um novo remote; pode chamá-lo de "upstream":
git remote add upstream https://github.com/usuario/projeto.git
# Obtenha todos os branches deste novo remote,
# como o upstream/master por exemplo:
git fetch upstream
@hilam
hilam / how-to-split-a-file-into-smaller-chunks.md
Created March 9, 2017 10:24 — forked from nepsilon/how-to-split-a-file-into-smaller-chunks.md
How to split a file into smaller chunks? — First published in fullweb.io issue #90

How to split a file into smaller chunks?

You may want to upload a 100GB file over an unstable network, or feed your scripts smaller inputs to load in RAM. In both cases, just splitting your file into smaller chunks is an easy solution.

Great news is Unix/Linux systems have the split utility already installed. And using it is simple as pie:

Cut a binary file into chunks of X bytes:

split -b X bigfile.avi
@hilam
hilam / how-to-delete-lines-containing-a-given-string.md
Last active February 19, 2017 16:56 — forked from nepsilon/how-to-delete-lines-containing-a-given-string.md
How to delete lines containing a given string? — First published in fullweb.io issue #85

How to delete lines containing a given string?

Just like last week, where we wanted to replace a string, we can use sed for this task:

sed '/pouet/d' file.txt

This will output file.txt on stdout without the lines containing pouet.

@hilam
hilam / how-to-replace-a-string-in-a-file.md
Last active February 19, 2017 16:57 — forked from nepsilon/how-to-replace-a-string-in-a-file.md
How to replace a string in a file? — First published in fullweb.io issue #84

How to replace a string in a file?

The simplest way to proceed is to use sed. It‘s available both on Mac and Linux. Here is the gist of it:

sed -i 's/old/new/g' file.txt

Here we’re replacing old with new.

@hilam
hilam / how-to-find-the-pid-of-a-process-using-a-given-port.md
Created February 19, 2017 14:29 — forked from nepsilon/how-to-find-the-pid-of-a-process-using-a-given-port.md
How to find the PID of a process using a given port? — First published in fullweb.io issue #80

How to find the PID of a process using a given port?

Sometimes you have a process you lost the PID, and would like to kill it.

You can use top (or better htop) to search for your process name and press k to kill it. But this isn’t optimal when you aren’t sure of its name. A better alternative is to search by the port opened, for example port 80:

sudo lsof -i :80
@hilam
hilam / how-to-copy-ssh-keys-to-another-machine.md
Created February 19, 2017 14:28 — forked from nepsilon/how-to-copy-ssh-keys-to-another-machine.md
How to copy SSH keys to another machine? — First published in fullweb.io issue #79

How to copy SSH keys to another machine?

Public key authentication is generally safer than password-based and is way more convenient.

SSH offers a command to set it up, ssh-copy-id (part of the openssh client package) will copy your public key to the remote machine. Use it like this:

ssh-copy-id -i ~/.ssh/my_key.pub remote-machine