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 / sitecake_open_basedir.php
Last active May 20, 2017 22:30
sitecake: Warning: is_writable(): open_basedir restriction in effect - https://forum.sitecake.com/t/open-basedir-restriction-in-effect/403/2
// sitecake/x.x.x/config/config.php
// change empty array in # SESSION CONFIGURATION SECTION
$app['session.options'] = [];
// add path of current www location
$app['session.options'] = [
'save_path' => '/home/www-data/.../html'
];
@devhero
devhero / jupyter_ipykernel_launcher
Created May 17, 2017 12:57
jupyter No module named ipykernel_launcher
# MacOS
# edit file:
/Users/username/Library/Jupyter/kernels/python3/kernel.json
# change ___ENVPATH___ to a working one
{
"argv": [
"/____ENVPATH____/bin/python",
# every item
all(item.prop == '' for item in items)
# at least one item
any(item.prop == '' for item in items)
# any item of a is in b
any(any(x==y for y in b) for x in a)
function getParam(param){
return new URLSearchParams(window.location.search).get(param);
}
@devhero
devhero / osx_preview_text
Created February 28, 2017 10:39
osx preview everything with text reader
brew cask install qlstephen
ul {
list-style-type: none;
padding-left: 20px;
}
li {
position: relative;
padding-left: 20px;
margin-bottom: 10px
}
$(function() {
var map = '#gmap-holder';
$(map).find('iframe').css('pointer-events', 'none');
$(map).click(function(e) {
$(this).find('iframe').css('pointer-events', 'all');
}).mouseleave(function(e) {
$(this).find('iframe').css('pointer-events', 'none');
});
})
chmod +x SomeApp.app/Contents/MacOS/*
# AND/OR disable app security restrictions
sudo spctl --master-disable
from django.db import connection
def idseq(model_class):
return '{}_id_seq'.format(model_class._meta.db_table)
def get_next_id(model_class):
cursor = connection.cursor()
sequence = idseq(model_class)
cursor.execute("select nextval('%s')" % sequence)
row = cursor.fetchone()
@devhero
devhero / selenium_firefox_plugin.py
Created February 3, 2017 09:40
selenium firefox profile plugin
ffp = webdriver.FirefoxProfile()
# for example load websocket monitor
websocket = os.path.join(os.getcwd(), 'path/websocket_monitor-0.6.4-fx.xpi')
ffp.add_extension(websocket)
context.browser = webdriver.Firefox(firefox_profile=ffp)