Skip to content

Instantly share code, notes, and snippets.

View victor-torres's full-sized avatar
🏠
Working from home

Victor Torres victor-torres

🏠
Working from home
View GitHub Profile
@victor-torres
victor-torres / ignoring_duplicated_decorator.py
Last active August 1, 2019 23:46
How to avoid decorating a function with the same decorator again in Python
def dec(func):
_decorators = getattr(func, '_decorators', [])
if dec in _decorators:
print('Ignoring...')
return func
_decorators.append(dec)
def inner(*args, **kwargs):
print('Calling...')
@victor-torres
victor-torres / reboot_calix_router.sh
Last active June 19, 2019 01:09
Rebooting Calix 844G (800 series) with cURL and Shell Script
# Authorization contains your username and password encoded in Base 64
# Example: admin:password => YWRtaW46cGFzc3dvcmQ=
curl -X GET https://192.168.1.1/rebootinfo.cgi -H 'Cookie: Authorization=YWRtaW46cGFzc3dvcmQ=' -k
@victor-torres
victor-torres / dpkg_repack.sh
Created February 22, 2019 19:55
Create a .deb file from an installed package
sudo apt-get install dpkg-repack
sudo dpkg-repack <package name>
@victor-torres
victor-torres / __init__.py
Created November 29, 2018 15:05
[Scrapy] Remove elements from the document based on a selector or list of selectors.
def remove_selector(selector):
"""
Remove elements from the document based on a selector or list of selectors.
:param selector: Selector object or Selector iterable.
"""
if not hasattr(selector, '__iter__'):
selector = [selector]
for sel in selector:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Boot Banner</key>
<string>No</string>
<key>EthernetBuiltIn</key>
<string>Yes</string>
<key>GraphicsEnabler</key>
<string>No</string>
@victor-torres
victor-torres / .ssh_config
Created April 24, 2018 19:23
Remote pbcopy and pbpaste
Host <your host ip>
User <your host user>
Port <your host port>
@victor-torres
victor-torres / delete-tweets.js
Last active February 4, 2024 12:40
This JavaScript code snippet can be pasted into Chrome's developer console in order to remove tweets.
/*
Copyright (c) 2017 Victor Torres
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@victor-torres
victor-torres / .hgrc
Created November 17, 2017 14:28
configuring meld merge tool in mercurial
[ui]
merge = meld
[extensions]
extdiff =
[merge-tools]
meld.args = $local $base $other --output=$output
@victor-torres
victor-torres / compress_gopro_videos.sh
Created October 25, 2017 20:17
Convert and compress GoPro videos to reduce file size keeping regular quality
# Convert and compress GoPro videos to reduce file size keeping regular quality
# Run in the same directory as the original files
# Output is MP4 H.264
# Be awere that convertions may take several minutes or even hours!
# I do recommend to run with small sets of video files for each iteraction
time find . -type f -name "G*PR*.MP4" -exec handbrakecli -i {} -o /<dest dir>/{} -e x264 -x "level=4.0:vbv-maxrate=20000:weightp=1:vbv-bufsize=25000:ref=1:8x8dct=0:subme=2:mixed-refs=0:trellis=0:rc-lookahead=10" \;
@victor-torres
victor-torres / uninstall_shell_integration.sh
Created March 1, 2016 12:51
Uninstalling shell integration from iTerm 2
#!/bin/bash
function die() {
echo "${1}"
exit 1
}
which printf > /dev/null 2>&1 || die "Shell integration requires the printf binary to be in your path."
which sed > /dev/null 2>&1 || die "Shell integration requires the sed binary to be in your path."