Skip to content

Instantly share code, notes, and snippets.

@greenkey
greenkey / testing_issue.py
Last active March 21, 2024 16:55
An issue I just discovered
import itertools
import pytest
def sum(a, b):
return a + b
def minimum(*numbers):
@greenkey
greenkey / urlencode.vbs
Created April 29, 2015 08:31
vbscript: URLEncode
' Encode special characters of a string
' this is useful when you want to put a string in the URL
' inspired by http://stackoverflow.com/questions/218181/how-can-i-url-encode-a-string-in-excel-vba
Public Function URLEncode( StringVal )
Dim i, CharCode, Char, Space
Dim StringLen
StringLen = Len(StringVal)
ReDim result(StringLen)
@greenkey
greenkey / subform.py
Last active January 27, 2023 08:31
how to change one attribute of a Django form field
from django import forms
class MyGenericForm(forms.Form):
valid_from = forms.DateField(
required=False,
label='Validity Start',
help_text="The first date that this rate is valid.",
widget=forms.DateInput(attrs={"placeholder": "YYYY-MM-DD"}, format="%Y-%m-%d"),
input_formats=["%Y-%m-%d"],
)
@greenkey
greenkey / Day_31_Kids_will_be_all_right.md
Last active January 24, 2023 09:58
Day 31: Kids will be all right

Day 31: Kids will be all right

Babbo Natale vuole assicurarsi che ogni regalo possa essere dato ad un bambino.

Ogni regalo ha delle caratteristiche che lo rendono adatto per alcune classi di bambini.

Ad esempio un regalo potrebbe essere adatto ai bambini che amano l’avventura, oppure potrebbe essere adatto solo per bambini con un’eta’ tra 6 e 10 anni.

Le caratteristiche che prende in considerazione Babbo Natale sono:

@greenkey
greenkey / JDBC_guide_SoapUI.md
Created February 29, 2016 17:09
How to easily use JDBC in a SoapUI Test Case

How to easily use JDBC in a SoapUI Test Case

Choose the DB and get the JDBC driver

First we need to know to which DBMS we want to connect. You can find all the supported driver in the JDBC Driver List page of the SoapUI website. Take note of the Driver name, i.e. oracle.jdbc.driver.OracleDriver and download the .jar file.

Put the jar file in the ext directory, it should be in ithe same folder as the SoapUI start script. In Linux, you can find it in this way:

La Johns Hopkins University ha inviato questo eccellente riassunto per evitare il contagio, condividilo perché è molto chiaro:
* Il virus non è un organismo vivente, ma una molecola proteica (DNA) coperta da uno strato protettivo di lipidi (grassi) che, se assorbito dalle cellule della mucosa oculare, nasale o della bocca, modifica il loro codice genetico. (mutazione) e li converte in cellule di moltiplicatori e aggressori.
*Poiché il virus non è un organismo vivente ma una molecola proteica, non viene ucciso, ma decade da solo. Il tempo di disintegrazione dipende dalla temperatura, dall'umidità e dal tipo di materiale in cui si trova.
* Il virus è molto fragile; l'unica cosa che lo protegge è un sottile strato esterno di grasso. Ecco perché qualsiasi sapone o detergente è il miglior rimedio, perché la schiuma ROMPE IL GRASSO (ecco perché devi strofinare così tanto: per almeno 20 secondi o più, e fare molta schiuma). Dissolvendo lo strato di grasso, la molecola proteica si disperde e si scompone da sola.
@greenkey
greenkey / gcj-2017-A.py
Created April 10, 2017 11:56
My solution for the Problem A of the 2017's edition of Google Code Jam: Oversized Pancake Flipper
#! /usr/bin/env python
import sys
def solve(line):
pancake_row = [p == '+' for p in line.split()[0]]
pan_size = int(line.split()[1])
flips = 0
@greenkey
greenkey / ddl_audit.sql
Last active February 6, 2018 14:21
Oracle DDL audit - made simple
CREATE TABLE ddl_log (
operation VARCHAR2(30),
obj_owner VARCHAR2(30),
obj_name VARCHAR2(30),
obj_type VARCHAR2(30),
sql_text CLOB,
attempt_by VARCHAR2(30),
attempt_dt DATE,
user_name VARCHAR2(50),
@greenkey
greenkey / gcj-2017-B.py
Last active May 31, 2017 16:18
My solution for the Problem A of the qualification of 2017's edition of Google Code Jam: Oversized Pancake Flipper Raw
#! /usr/bin/env python
import sys
def solve(line):
if len(line) == 1:
return line
prev = "0"
for i, digit in enumerate(line):
@greenkey
greenkey / avoid_memoize_during_test.py
Created May 5, 2017 18:29
how to avoid django-memoize during test
# Supposing you're using the django-memoize package, you could have the
# following view memoized:
# file: your_module/views.py
# ...
@memoize(timeout=60)
def very_heavy_view(request):
time_consuming_function()
# ...
# ...