Skip to content

Instantly share code, notes, and snippets.

View afr-dt's full-sized avatar
:octocat:

Alejandro Flores afr-dt

:octocat:
  • Personal
  • Mexico City
View GitHub Profile
@mangecoeur
mangecoeur / description.md
Last active March 30, 2021 21:34
Pandas PostgresSQL support for loading to DB using fast COPY FROM method

This small subclass of the Pandas sqlalchemy-based SQL support for reading/storing tables uses the Postgres-specific "COPY FROM" method to insert large amounts of data to the database. It is much faster that using INSERT. To acheive this, the table is created in the normal way using sqlalchemy but no data is inserted. Instead the data is saved to a temporary CSV file (using Pandas' mature CSV support) then read back to Postgres using Psychopg2 support for COPY FROM STDIN.

import pytesseract
import os
import sys
def read_image(img_path, lang='eng'):
"""
Performs OCR on a single image
:img_path: str, path to the image file
@mprajwala
mprajwala / import_csv_to_mongo
Last active July 23, 2023 20:07
Store CSV data into mongodb using python pandas
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
@toddbirchard
toddbirchard / pandas_dataframe_difference.py
Last active August 26, 2023 00:48
Helper function to compare two DataFrames and find rows which are unique or shared.
"""Find Symmetric Differences between two Pandas DataFrames."""
def dataframe_difference(df1, df2, which=None):
"""Find rows which are different."""
comparison_df = df1.merge(
df2,
indicator=True,
how='outer'
)
@shri
shri / pokemon.json
Last active October 21, 2023 16:31
JSON of pokemon to go with my pokemonMoves.json file
{
"1":{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",
@kmaida
kmaida / dynamicPagRepeatAngular.html
Last active December 13, 2023 14:37
AngularJS - Dynamic pagination on ng-repeat with search/filtering. Use with ui.bootstrap
<!DOCTYPE HTML>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Dynamic Pagination w/ Filtering</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Kim Maida">
<!-- JS Libraries -->
@adrienjoly
adrienjoly / fix-dyld-missing-symbol-called-errors-on-m1-macs.md
Last active February 3, 2024 18:01
Fix `dyld[]: missing symbol called` errors when running Node.js programs on M1 Macs (apple silicon)

Problem

If you're getting this kind of error when running Node.js programs with binary dependencies that don't support M1 yet, e.g.:

$ yarn test
dyld[51175]: missing symbol called
dyld[51176]: missing symbol called
@joshatxantie
joshatxantie / gist:4bcf5d0243fba63845fce7cc40365a3a
Created September 2, 2021 04:18
Dockerize Pyodbc/SQL Server
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
WORKDIR /app
ENV ACCEPT_EULA=Y
RUN apt-get update -y && apt-get update \
&& apt-get install -y --no-install-recommends curl gcc g++ gnupg unixodbc-dev
@primaryobjects
primaryobjects / react-confirm.js
Created November 1, 2017 19:03
A simple example of a confirm alert dialog in ReactJs / React.
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } />

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by