Skip to content

Instantly share code, notes, and snippets.

View lamprosg's full-sized avatar

Lampros Giampouras lamprosg

  • Athens, Greece
View GitHub Profile
@lamprosg
lamprosg / findLocation_with_php.php
Last active March 28, 2024 12:08
Geocode location in PHP (Google Maps API)
<?php
session_start();
define("MAPS_HOST", "maps.google.com");
define("KEY", "YOURGOOGLEMAPSAPIKEY"); //Personal Google Maps API key
//Get address from which we will geocode the coordinates
$address=$_GET['address'];
if( $address!=NULL)
@lamprosg
lamprosg / link.url
Created August 7, 2012 15:00
Create a mobile website with jQuery Mobile
@lamprosg
lamprosg / map.html
Created January 2, 2013 15:34
Google Maps API
<script src="map_code.js"></script> <!-- My map code -->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&key=YOURKEY"></script> <!-- Map API -->
<!-- No GPS sensor -->
<body onLoad="initialize()">
div id="map_canvas"></div>
@lamprosg
lamprosg / IP.pro
Last active February 17, 2019 00:01
TCP/IP Programming (Qt SDK)
QT += core gui
QT += network
@lamprosg
lamprosg / connection.cpp
Last active December 10, 2015 16:48
Qt Databases (MySQL)
//Create a default connection
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //Or whatever database in use
/*We could add a second argument which is the connection name**
Example:
QSqlDatabase firstDB = QSqlDatabase::addDatabase("QMYSQL", "first");
*/
//Set connection information
db.setHostName("xxx.xxx.xxx.xxx"); //localhost if it's local
@lamprosg
lamprosg / showdialog.cpp
Created January 6, 2013 13:21
Qt - Create and show a new dialog
void SomeClass::showDialog() //Show dialog if not showing
{
if ( dialog )
delete dialog;
dialog = new DialogClass(this);
dialog->show();
dialog->raise(); //Raise in front of the parent window
//dialog->activateWindow(); //Active window
}
@lamprosg
lamprosg / main.cpp
Last active September 23, 2021 14:14
Qt threading - Basic use of QThread.
#include <QThread>
#include "mythread.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QThread thread; //Thread object
MyThread cObject; //My class object
@lamprosg
lamprosg / main.cpp
Created January 20, 2013 20:29
Qt - qSort Algorithm
int main()
{
//Let's say we have a listof integers
QList<int> List;
//insert some numbers
List << 2 << 3 << 1 << 0; //Yes you could use List.append
qSort(List)
@lamprosg
lamprosg / Information
Last active January 16, 2017 17:27
Qt - Multithreaded Server
Create 2 classes.
One class for the server:
We call it ex. MyServer, with Base class QTcpServer
Second class, every connection will have a new thread:
We call it MyThread, with Base class QThread
@lamprosg
lamprosg / Information
Last active February 7, 2021 06:48
Qt - QTcpServer using QThreadPool (The way to go of making a server)
Classes:
MyServer, with Base class QTcpServer
MyRunnable (this is a QRunnable task), with Base class QRunnable. (With no QObject, cause it's not a QObject)