Skip to content

Instantly share code, notes, and snippets.

View jredrejo's full-sized avatar

José L. Redrejo Rodríguez jredrejo

View GitHub Profile
@jredrejo
jredrejo / remove_google_tag.py
Last active March 7, 2024 18:07
Remove google tag and google ads code from an html file using bs4
from bs4 import BeautifulSoup, Comment
SESSION = requests.Session()
def download_page(url):
"""
Download `url` (following redirects) and soupify response contents.
Returns (final_url, page) where final_url is URL afrer following redirects.
"""
headers = {
const isQuick = context => {
return context.quick;
};
const isNewFacility = context => {
return context.setupType === 'new';
};
const isLODSetup = context => {
--- a/kolibri/plugins/oidc_provider_plugin/__init__.py
+++ b/kolibri/plugins/oidc_provider_plugin/__init__.py
@@ -1,6 +1,13 @@
+import os
+
+
def kolibri_userinfo(claims, user):
"""
Fill claims with the information available in the Kolibri database
"""
@jredrejo
jredrejo / machine.js
Last active July 1, 2020 16:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jredrejo
jredrejo / pr.md
Created April 6, 2020 18:26 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jredrejo
jredrejo / pdf-thumbnail-php.md
Created February 24, 2020 18:09 — forked from umidjons/pdf-thumbnail-php.md
Creating PDF thumbnails in PHP

Creating PDF thumbnails in PHP

Install Ghostscript

Download and install right version of ghostscript. In my case my PHP was x86 architecture, so I download Ghostscript 9.14 for Windows (32 bit).

Enable ImageMagick

@jredrejo
jredrejo / email.diff
Created July 17, 2019 17:26
un-women oidc email hack
diff --git a/kolibri/plugins/oidc_provider_plugin/__init__.py b/kolibri/plugins/oidc_provider_plugin/__init__.py
index 0276a6d09..2afa7693b 100644
--- a/kolibri/plugins/oidc_provider_plugin/__init__.py
+++ b/kolibri/plugins/oidc_provider_plugin/__init__.py
@@ -1,6 +1,13 @@
+import os
+
+
def kolibri_userinfo(claims, user):
"""
@jredrejo
jredrejo / pskill.sh
Created May 16, 2019 16:31
kill process running giving its name
#!/bin/sh
# usage: pskill.sh kk.py
# to kill process kk.py
PID="$(ps aux|grep $1|grep -v grep|grep -v pskill|awk '{print $2}')"
[ -z "$PID" ] && exit 1
kill $PID
@jredrejo
jredrejo / mysql_backups
Last active April 6, 2016 09:58
mysql backups
A database:
backup: # mysqldump -u user -p [database_name] > dumpfilename.sql
restore:# mysql -u user -p [database_name] < dumpfilename.sql
Several databases:
mysqldump -u root -p --databases bugs sugarcrm > bugs_sugarcrm.sql
All the databases:
mysqldump -u root -p --all-databases > /tmp/all-database.sql
@jredrejo
jredrejo / gist:794ba6002de0b94d5f5b
Created November 10, 2015 08:48
Using repeatable -v and -q to select the logging level in Python scripts
parser.add_argument('-v', '--verbose', action='count', default=0)
parser.add_argument('-q', '--quiet', action='count', default=0)
logging_level = logging.WARN + 10*args.quiet - 10*args.verbose
# script -vv -> DEBUG
# script -v -> INFO
# script -> WARNING
# script -q -> ERROR
# script -qq -> CRITICAL