Skip to content

Instantly share code, notes, and snippets.

View ndaifallah's full-sized avatar
🤧

Nasreddine ndaifallah

🤧
View GitHub Profile
@ndaifallah
ndaifallah / s3_upload.sh
Created May 1, 2021 02:28 — forked from tuxfight3r/s3_upload.sh
AWS - Upload files to S3 via curl
#!/bin/bash -x
#Date: 21/7/2017
#Author: Mohan
#Purpose: To upload files to AWS S3 via Curl
#Uploads file at the top level folder by default
#S3 parameters
S3KEY="XXXXXXXXXXX"
S3SECRET="XXXXXXXXXXXXXXXX"
@ndaifallah
ndaifallah / open-utf-8-file.py
Last active July 11, 2018 21:11
Open any text file, with the basic encodings utf-8 and widnows-1252
# The solution for usual problems of opening files with specific encoding, french, englis,arabic ....
def openHoweverFile(filename):
f = None
try:
f = open(filename, 'r', encoding='utf-8')
except UnicodeDecodeError:
f = open(filename, 'r', encoding='windows-1252')
return f
@ndaifallah
ndaifallah / array_bitwise.py
Created May 14, 2018 00:47
This gist is made to help selecting rows, with one or more conditions,
# Author: Nasreddine DAIFALLAH
# Mail: n_daifallah@esi.dz
# This piece of code helps us to select rows in pandas dataframes using bitwise operations,
# personnnaly it helped me when I wanted to select rows which contain "Ingredients" OR "ingredients
# returns an array contains values of (Array AND Array)
def andArray(a=[], b=[]):
if len(a) != len(b):
@ndaifallah
ndaifallah / tag_encoder.py
Last active May 11, 2018 11:47
This gist is made for some data formats preprocessing, When you have a column in dataset which contains ingredients for food recipes, you can use this class to help you in tags binarizing.
# I needed this in some unprepared datasets
# Author Nasreddine DAIFALLAH
import pandas as pn
class TagLabelEncoder:
def __init__(self, strip=',', tolower=True):
self.strip = strip
self.tolower = tolower
pass