Skip to content

Instantly share code, notes, and snippets.

View arkenidar's full-sized avatar
🎯
Focusing @Elmiguys

Dario Cangialosi arkenidar

🎯
Focusing @Elmiguys
View GitHub Profile
<?php
$pdo = new PDO("sqlite:db.sqlite3", "", "", [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] );
$sql = "CREATE TABLE IF NOT EXISTS chat_messages (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
message_text TEXT NOT NULL,
sender TEXT NOT NULL,
creation_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL )";
$pdo->query($sql); // init db tables
@arkenidar
arkenidar / pyside.py
Created April 12, 2016 16:55
simple pyside test app
#!/usr/bin/env python
'''
required:
sudo apt-get install python python-pyside pyside-tools
'''
import sys
from PySide.QtGui import *
@arkenidar
arkenidar / examples.html
Created May 22, 2016 19:49
Javascript examples (#ractivejs, #jquery)
<!doctype html>
<html>
<head>
<title>Examples</title>
<meta charset="UTF-8">
</head>
<body>
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
@arkenidar
arkenidar / field.py
Last active April 25, 2017 17:40
python program about fields of primes
# python program about fields of primes
def divnr(a,b): # a/b , div.ide n.on r.repeating
la=[]
string=''
psum=0
idx=-1
while True:
a*=10
# if a in la: break
@arkenidar
arkenidar / flask_app_ctx.py
Last active May 1, 2017 21:09
Flask's "Application Context" test
#!/usr/bin/env python3
from flask import Flask, current_app
app = Flask(__name__)
app_ctx = app.app_context()
with app_ctx:
print(current_app.name)
current_app.paths=[]
@arkenidar
arkenidar / tagfound.com.md
Last active July 18, 2017 13:25
TagFound.com web services idea (summary in English and in Italian)

TagFound.com

A user's personal account can have many profiles. Each profile has the tags applied to it. The negotiated anonymity could be useful and an optional extra function.

Possible uses

  • This web service could be used as a way for human resources to find humans and to be found as a human resource. The anonymity negotiated is similar to the partial disclosure of information already practiced today in this field.
  • This web service could be used as a purchase-sale of articles or services
  • This web service could be used for every use in which there are human needs of reciprocal contact and find a "relational agreement" on something they have or offer, symbolized by the tags.

Details

@arkenidar
arkenidar / multiplication.py
Created August 2, 2017 19:39
Simple algorithm implementation (multiplication with sums), simple concept of optimization (with measurement of performance improvement), PyLint applied (10/10)
#!/usr/bin/env python
''' Multiplication with sums. '''
def multiplication(first, second):
''' Multiply: first*second. '''
accumulator = 0
for _ in range(second):
@arkenidar
arkenidar / toggler.py
Created September 10, 2017 17:12
Testing an algorithm (I don't know its name).
#!/usr/bin/env python3
""" Testing an algorithm (I don't know its name). """
def tests():
""" Tests. """
if [0, 0, 0, 1, 1, 1, 0, 1] == list(produced([0, 0, 0, 1, 0, 0, 1, 1])):
print('test success')
@arkenidar
arkenidar / crud.php
Last active October 24, 2017 18:59
a simple PHP CRUD example. BTW I suggest to use Visual Studio Code + XDebug for coding and debugging.
<!doctype html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
</head>
<body>
<form method="post">
<input name="name" placeholder="name">
<input name="cost" placeholder="cost">
@arkenidar
arkenidar / select.py
Created April 3, 2018 14:11
select first or all callables based on check of conditions specified in callables
#select.py
#select first or all callables based on check of conditions specified in callables
def select(cases, mode='first'): # all or first
returned=[]
for icase in cases:
if icase[0]():
returned.append(icase[1]())
if mode=='first': return returned[0]