Skip to content

Instantly share code, notes, and snippets.

View devhero's full-sized avatar
😁

Andrea Parisi devhero

😁
  • devhero
  • Milan
View GitHub Profile
@devhero
devhero / redux-observable-serial-dispatch.js
Last active February 21, 2018 09:31
rxjs redux-observable
// https://github.com/redux-observable/redux-observable/issues/62
// simple
const myCoordinator = actions$ =>
actions$.ofType('MY_COOL_ACTION')
.flatMap(action =>
Observable.concat(
// Fire 2 actions, one after the other
Observable.of(someCoolAction),
Observable.of(someOtherAction)
@devhero
devhero / python_load_module.py
Last active April 19, 2018 10:57
python runtime import/load module/library
import importlib
module = importlib.import_module('module', 'package')
@devhero
devhero / zsh_shortcuts.md
Created January 26, 2018 09:08
zsh shortcuts

Source

Shortcuts to improve your bash & zsh productivity

So, you hate using a terminal? That might be, because you use the arrow keys to navigate character by character through a long command just to change a paramater at the other end of the line, right? Here's a list of my most-used bash & zsh shortcuts, that will definitely boost your productivity and will help you to improve your command line experience.

Shortcut Action
CTRL + A Move to the beginning of the line
@devhero
devhero / jupyter_pyenv_ModuleNotFoundError
Created January 25, 2018 11:24
jupyter pyenv ModuleNotFoundError
# https://stackoverflow.com/questions/36382508/packages-from-conda-env-not-found-in-jupyer-notebook/36395096#36395096
# Here are two possible solutions:
# You can register a new kernel based on your my-venv environment. The kernel will start from the my-venv environment and thus sees all its packages.
source activate my-venv
pip install ipykernel
ipython kernel install --name my-venv
@devhero
devhero / py_remote_extract_tar_gzip.py
Last active September 9, 2024 14:06
python download and extract remote file tar.gzip
# Instruct the interpreter to create a network request and create an object representing the request state. This can be done using the urllib module.
import urllib.request
import tarfile
thetarfile = "http://file.tar.gz"
ftpstream = urllib.request.urlopen(thetarfile)
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz")
thetarfile.extractall()
# The ftpstream object is a file-like that represents the connection to the ftp server. Then the tarfile module can access this stream. Since we do not pass the filename, we have to specify the compression in the mode parameter.
@devhero
devhero / selenium_tab_window.py
Last active November 29, 2017 11:46
selenium tabs and windows
# opening a new tab
self.driver = webdriver.Firefox()
self.driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
# this is the solution for MAC OSX. In other cases you can use the standard Keys.CONTROL + 't'
# opening a new webdriver
driver = webdriver.Firefox() #1st window
@devhero
devhero / ffmpeg cookbook
Last active January 19, 2023 10:56
ffmpeg cookbook
# rotate
ffmpeg -i input.mp4 -map_metadata 0 -c copy -metadata:s:v rotate="180" output.mp4
# extract subs from mp4
# https://superuser.com/questions/393762/how-to-extract-subtitles-from-mp4-and-mkv-movies
ffmpeg -i video.mp4 subtitle.srt
# convert audio (using vbr)
ffmpeg -i input.mkv -c:a libopus -b:a 256k -vbr 1 -af "channelmap=channel_layout=5.1" output.mkv
@devhero
devhero / eslintrc_tips.js
Created October 19, 2017 13:59
.eslintrc.json tips
// ignores hyperapp:
// import {h} from "hyperapp"
{
"rules":{
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "h"
}
]
@devhero
devhero / rxjs_serial_ajax
Created October 11, 2017 09:55
rxjs serial ajax
import { Observable } from "rxjs/Observable"
import "rxjs/add/observable/dom/ajax"
import "rxjs/add/observable/from"
import "rxjs/add/operator/map"
import "rxjs/add/operator/reduce"
import "rxjs/add/operator/concatAll"
import Cookie from "js-cookie"
const responses = []
const request$ = (method, url, payload) => Observable
@devhero
devhero / git_ignore_skip
Created October 5, 2017 08:38
.gitignore exclude folder but include specific subfolder
# you can skip this first one if it is not already excluded by prior patterns
!application/
application/*
!application/language/
application/language/*
!application/language/gr/