Skip to content

Instantly share code, notes, and snippets.

View arkenidar's full-sized avatar

Dario Cangialosi arkenidar

View GitHub Profile
@arkenidar
arkenidar / prime_as_sum_of_primes.py
Last active July 18, 2018 12:58
Does every Prime Number >= 3 have the property of being obtainable from a summation of prime numbers themselves? e.g. 2+3=5
#https://repl.it/@dariocangialosi/primesassumofprimes-1
def is_prime(n):
prime=True
for i in range(2,n):
if n%i==0:
prime=False
break
return prime
def primes_iterator(start,limit):
for n in range(start,limit):
@arkenidar
arkenidar / primes_as_sum_of_primes.js
Last active July 23, 2018 11:26
// algorithm for sums of non-composites (see the concept of composite number) errata corrige: non-composites not primes
// @ repl.it: https://repl.it/@dariocangialosi/primesassumofprimesjs
// @ gist.github.com: https://gist.github.com/arkenidar/91198b654b119c97284588d6451117c6/
////////////////////////////////////////
primeSum()
// the algorithm for: "a prime as sum of primes"
function primeSumPrimes(limit=NaN){
var primes=[]
for(let n of primesGenerator(0,limit+1)){
@arkenidar
arkenidar / bash_snippets_LAMP.sh
Created September 15, 2018 18:33
bash_snippets_LAMP.sh
#PHP+apache+databases
#-----------------------------
#apache2
#php
#php-xdebug
#php-sqlite3
#mariadb-server
#phpmyadmin
#-----------------------------
@arkenidar
arkenidar / pdo.php
Created January 18, 2019 20:25
php mysql
<?php
/*
-- configure as needed:
extension=pdo_mysql
alter user 'root'@'localhost' identified with mysql_native_password by 'password';
*/
@arkenidar
arkenidar / php_mysql_demo.php
Last active January 20, 2019 17:00
php plus mysql demo
<!doctype html>
<!-- submit text -->
<form method="get"> <input name="text"> </form>
<?php
require 'credentials.php'; $dbname='testdb';
$dbh=initpdo($user,$password,$dbname);
<!doctype html><html><head>
<meta charset="utf-8"><title></title>
</head><body>
<form name="fattura_form"><input type="submit"></form>
<template id="template_fattura">
<fieldset class="fatture">
quantita
<input type="text" name="qta[]" value="1">
prezzo unitario
@arkenidar
arkenidar / page.php
Last active February 22, 2019 19:49
very basic login/logout system
<?php
function handle_request($REQUEST){
// Note: To use cookie-based sessions, session_start()
// must be called before outputting anything to the browser.
@session_start();
?>
<!doctype html>
<body>
<?php
//$REQUEST=$_REQUEST;//['action'=>'login','user'=>'user@gmail.com','password'=>'secret'];//$_REQUEST;
<?php
$path='download.php'; // CHANGE IT
$finfo = finfo_open(FILEINFO_MIME_TYPE);
header('Content-Type: '.finfo_file($finfo, $path));
$finfo = finfo_open(FILEINFO_MIME_ENCODING);
header('Content-Transfer-Encoding: '.finfo_file($finfo, $path));
@arkenidar
arkenidar / login.html
Last active February 26, 2019 17:16
FB login in JS
<!DOCTYPE html><meta charset="UTF-8">
<title>Facebook Login in JavaScript</title>
<body>
<script>
function checkLoginState(){
FB.getLoginStatus(response=>statusChangeCallback(response))
}
function statusChangeCallback(response) {
if(response.status === 'connected')
FB.api('/me',function(response){document.all.status.innerHTML='Thanks for logging in, '+response.name})
<?php
@session_start();
// https://github.com/facebook/php-graph-sdk
//composer require facebook/graph-sdk
require_once __DIR__ .'/vendor/autoload.php';
require 'app_settings.php';
function fb(){
require 'app_settings.php';