Skip to content

Instantly share code, notes, and snippets.

View mou55's full-sized avatar

Moussa IDARDAR mou55

View GitHub Profile
@mou55
mou55 / boto-elastic-transcoder-manager-example.py
Created August 7, 2019 20:31 — forked from mingrammer/boto-elastic-transcoder-manager-example.py
Python script for AWS Elastic Transcoder with boto api
# -*- coding: utf-8 -*-
import hashlib
import boto3
class ETSManager:
"""
@todo: manages and provides the ets services
@mou55
mou55 / ecssh
Created April 24, 2019 11:33 — forked from AaronTorgerson/ecssh
SSH into a running Docker container on ECS (depends on awless)
#!/bin/bash
set -e
cluster=$1
service=$2
container=$3
debug=$4 # pass word "debug" as 4th arg to see debug output
check_val () {
if [[ -z "${1}" ]]; then
@mou55
mou55 / Unicode.md
Created April 18, 2018 10:00 — forked from gornostal/Unicode.md
Python 2.7. Unicode Errors Simply Explained

Python 2.7. Unicode Errors Simply Explained

I know I'm late with this article for about 5 years or so, but people are still using Python 2.x, so this subject is relevant I think.

Some facts first:

  • Unicode is an international encoding standard for use with different languages and scripts
  • In python-2.x, there are two types that deal with text.
    1. str is an 8-bit string.
  1. unicode is for strings of unicode code points.
  • 🎨 when improving the format/structure of the code
  • πŸš€ when improving performance
  • ✏️ when writing docs
  • πŸ’‘ new idea
  • 🚧 work in progress
  • βž• when adding feature
  • βž– when removing feature
  • πŸ”ˆ when adding logging
  • πŸ”‡ when reducing logging
  • πŸ› when fixing a bug
@mou55
mou55 / curl.md
Created February 20, 2018 21:22 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mou55
mou55 / API.md
Created April 25, 2017 11:20 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@mou55
mou55 / app__init__.py
Created April 3, 2017 03:20 — forked from gcetusic/app__init__.py
Override Django project global settings on application load
def inject_app_defaults(application):
"""Inject an application's default settings"""
try:
__import__('%s.settings' % application)
import sys
# Import our defaults, project defaults, and project settings
_app_settings = sys.modules['%s.settings' % application]
_def_settings = sys.modules['django.conf.global_settings']
_settings = sys.modules['django.conf'].settings
@mou55
mou55 / selenium_multiprocess.py
Created January 31, 2017 16:44 — forked from svschannak/selenium_multiprocess.py
Multiprocessing with Selenium and Python for website crawling
from multiprocessing import Pool, cpu_count
def run_parallel_selenium_processes(datalist, selenium_func):
pool = Pool()
# max number of parallel process
ITERATION_COUNT = cpu_count()-1
count_per_iteration = len(datalist) / float(ITERATION_COUNT)
@mou55
mou55 / caller_name.py
Created August 9, 2016 16:06 — forked from techtonik/caller_name.py
Python - inspect - Get full caller name (package.module.function)
# Public Domain, i.e. feel free to copy/paste
# Considered a hack in Python 2
import inspect
def caller_name(skip=2):
"""Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
@mou55
mou55 / temp_perm_failure.md
Created July 31, 2016 08:32
Handling temporary and perm failures on Context.IO 2.0

##Temporary failures

To clear temporary failures POST https://api.context.io/2.0/accounts/id/sources/label and use the param status=1 to clear the temporary failure. Do not combine this with any other params.

Sample payload:

{"account_id":"5690***************4569","user_id":"5690***************4569","server_label":"test::gmail","email_account":"test::gmail","timestamp":1234567890,"failure":"temporary"}