Skip to content

Instantly share code, notes, and snippets.

View gist:91dc6d2364eda519e2357749aa5058f0
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 / avoid_memoize_during_test.py
Created May 5, 2017
how to avoid django-memoize during test
View avoid_memoize_during_test.py
# 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()
# ...
# ...
@greenkey
greenkey / gcj-2017-C.py
Last active Apr 12, 2017
My solution for the Problem C of the qualification of 2017's edition of Google Code Jam: Bathroom Stalls
View gcj-2017-C.py
#! /usr/bin/env python
import sys
def progress(s):
print("%-80s\r" % s, file=sys.stderr, end='')
def solve2(line):
@greenkey
greenkey / gcj-2017-B.py
Last active May 31, 2017
My solution for the Problem A of the qualification of 2017's edition of Google Code Jam: Oversized Pancake Flipper Raw
View gcj-2017-B.py
#! /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 / gcj-2017-A.py
Created Apr 10, 2017
My solution for the Problem A of the 2017's edition of Google Code Jam: Oversized Pancake Flipper
View gcj-2017-A.py
#! /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 / tablespace_shrink.sql
Created Jun 14, 2016
Shrink an oracle tablespace
View tablespace_shrink.sql
/*
It is not possible to shrink a tablespace that's being used, in order to reclaim the unused space you can use this script (remember to change the value of OLD_TBSP variable)
The script essentially does the following:
- create a new tablespace appending "_TMP" at the end, it's going to use a datafile with the same name, adding (or incrementing) an id;
- move all the object from the old tablespace to the new one;
(this means that on the filesystem there should be enough space for the new datafile, consider also the extra space for the index rebuild!)
- prints the commands to execute in order to drop the old tablespace and rename the new.
At the end it is possible that the space on the filesystem is not freed, follow the instructions here: http://serverfault.com/questions/501963/how-to-recover-free-space-on-deleted-files-without-restarting-the-referencing-pr
@greenkey
greenkey / fraction_exercise_generator.py
Last active Mar 2, 2016
To help my daughters learn fractions, I made an exercise generator. Now they hate me.
View fraction_exercise_generator.py
#!/usr/bin/python3
from random import randrange, random
from fractions import Fraction
from functools import reduce
from operator import mul
def pf(f):
'''Pretty print the fraction'''
return "{}/{}".format(f.numerator,f.denominator)
@greenkey
greenkey / JDBC_guide_SoapUI.md
Created Feb 29, 2016
How to easily use JDBC in a SoapUI Test Case
View JDBC_guide_SoapUI.md

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:

@greenkey
greenkey / sql_parametric.vbs
Last active Feb 25, 2016
VBScript, ADO and query parameters (question marks), a handy function
View sql_parametric.vbs
' inspired by:
' http://stackoverflow.com/questions/2557606/how-do-i-associate-parameters-to-command-objects-in-ado-with-vbscript
' http://stackoverflow.com/questions/10352211/vba-ado-connection-and-query-parameters
' The function takes three parameters: ADOConnection; sql (string); params, an Array() of parameters
Function sqlOperationParametric(ADOConnection,sql,params)
Dim Cm, Pm, i, p
Set Cm = CreateObject("ADODB.Command")
With Cm
@greenkey
greenkey / ddl_audit.sql
Last active Feb 6, 2018
Oracle DDL audit - made simple
View ddl_audit.sql
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),
You can’t perform that action at this time.