Skip to content

Instantly share code, notes, and snippets.

View jerome-diver's full-sized avatar
🏠
Working from home

Jérôme Lanteri jerome-diver

🏠
Working from home
  • Thailand
View GitHub Profile
@jerome-diver
jerome-diver / Install.pm6
Last active July 31, 2017 04:20
Hash and Associative Hash definition and argument functions...
#----Install.pm6----
unit module Install;
use Prompt::Gruff::Export;
use Git::Wrapper;
use Check;
use Datas;
my %q = "select_groups" => "Select some groups of repos you want to install ?",
"select_repos" => "Select some repos to install: ",
"select_group" => "Choose a group from where you will install some repos: ";
@jerome-diver
jerome-diver / config.php
Created December 28, 2018 16:49
nginx-passenger with nextcloud-14 (nextcloud faile to print app/files after login with a loop)
<?php
$CONFIG = array (
'instanceid' => '[private]',
'passwordsalt' => '[private]',
'secret' => '[private]',
'trusted_domains' =>
array (
0 => 'cloud.my_domain.tk',
),
'datadirectory' => '/usr/local/www/nextcloud/data',
@jerome-diver
jerome-diver / ipython.test
Last active May 16, 2019 05:32
error unexpected (missundertsand inherited class in python 3)
In [129]: class A:
def __init__(self, x):
super().__init__(x)
self._x = x
self._a_var = "Variable A"
@property
def a_var(self, x):
return self._a_var
class B:
"""Please, let me know which child is calling me: 'parent' ? """
def read_childs(cls):
"""Return childs of cls"""
return cls.__subclasses__()
class A:
"""This is a mixin class to share code for DRY"""
# Test zope.interface to get abstract class with Python (from jupyter)
from zope.interface import Interface
from zope.interface.declarations import implementer
from PyQt5.QtCore import QObject
class Base(zope.interface.Interface, QObject):
"""My base cabstract class"""
name = zope.interface.Attribute("Base abstract class")
@jerome-diver
jerome-diver / try QThread list of threads managment
Last active June 7, 2019 18:32
I'm trying to manage a list of threads and from own signal emit self at end of run job, slot connected should remove thread (but it doesn't). Why ?
from PyQt5.QtCore import QObject, QThread, QSemaphore, QReadWriteLock, pyqtSignal, pyqtSlot
import random, time
class Share():
data = dict()
def __init__(self, key, value):
Share.data[key] = value
@staticmethod
def get(key):
return Share.data[key]
@staticmethod
@jerome-diver
jerome-diver / spectrwm.conf
Last active November 6, 2019 17:41
spectrwm config file
# PLEASE READ THE MAN PAGE BEFORE EDITING THIS FILE!
# https://htmlpreview.github.io/?https://github.com/conformal/spectrwm/blob/master/spectrwm.html
# NOTE: all rgb color values in this file are in hex! see XQueryColor for examples
# workspace_limit = 22
# focus_mode = default
# focus_close = previous
# focus_close_wrap = 1
# focus_default = last
# spawn_position = next
@jerome-diver
jerome-diver / assets.rb
Created February 10, 2020 16:31
ruby-2.7 ActionView:Template:Error (undefined method 'start_with?' for /\.(?:svg|eot|woff|ttf)\z:Regexp)
Rails.apoplication.config.assets.precompile << (/\.(?:svg|eot|woff|ttf)\z)
@jerome-diver
jerome-diver / custom_failure.rb
Created March 18, 2020 18:57
trying to redirect_to controller users/session action new as JS, but get back 422 error due to forgery protection
class CustomFailureApp < Devise::FailureApp
def redirect
store_location!
message = warden.message || warden_options[:message]
puts("Messages from Warden: #{message}")
case message
when :timeout
redirect_to root_path
when :unconfirmed
redirect_to new_user_session_path(format: :js)
@jerome-diver
jerome-diver / subprocess_out_to_json
Last active April 21, 2020 19:25
trying to get json object from command returning json through subprocess call
import json
import subprocess
# you need to have taskwarrior application installed on the Linux system to rich the shell command to return a json data
j = json.loads(subprocess.run(["task", "status:pending", "export"], capture_output=True, check=True).stdout)