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 / Fingerprinting.swift
Last active July 28, 2023 14:03
(iOS) Fingerprinting, identifying a device
//https://nshipster.com/device-identifiers/
//Besides identifierForVendor..
/*
Locale information is the greatest source of identifying information on Apple platforms.
The combination of your preferred languages, region, calendar, time zone,
and which keyboards you have installed say a lot about who you are
especially if you have less conventional preferences.
*/
@lamprosg
lamprosg / demo_workers.js
Created April 22, 2012 09:43
HTML5 Web Workers example
var i=0;
function timedCount()
{
i=i+1;
postMessage(i); //posts a message back to the HTML page.
setTimeout("timedCount()",500);
}
timedCount();
@lamprosg
lamprosg / main.php
Created July 22, 2012 21:11
Resize image on the fly in PHP
<?php
//How to use it
//Just call timthumb.php with appropriate arguments, For example:
<img src="/script/timthumb.php?src=/some/path/myimage.png&w=100&h=80" alt="resized image" />
/* http://viralpatel.net/blogs/resize-image-dynamically-php/ */
?>
@lamprosg
lamprosg / AwakeAfter.swift
Last active March 25, 2023 14:34
(iOS) Load custom UIview in xib
//Create the xib CustomView.xib and add the View class as CustomView (this one)
override func awakeAfter(using aDecoder: NSCoder) -> Any? {
if self.subviews.isEmpty {
let nib = UINib(nibName: "CustomView", bundle: nil)
let viewArray = nib.instantiate(withOwner: nil, options: nil)
guard let view = viewArray.first as? CustomView else {
return self
}
view.translatesAutoresizingMaskIntoConstraints = false
@lamprosg
lamprosg / appDelegate.mm
Last active February 11, 2023 08:55
(iOS) Running location updates in the background
-(void) applicationDidEnterBackground:(UIApplication *) application
{
// You will also want to check if the user would like background location
// tracking and check that you are on a device that supports this feature.
// Also you will want to see if location services are enabled at all.
// All this code is stripped back to the bare bones to show the structure
// of what is needed.
[locationManager startMonitoringSignificantLocationChanges];
@lamprosg
lamprosg / 1.CustomClass.h
Last active November 14, 2022 02:33
(iOS) Creating custom delegates
//Class will be declared later
@class CustomClass;
//Define the protocol for the delegate
@protocol CustomClassDelegate
@required
//Required methods go here
//If there are optional functions, they go here
@lamprosg
lamprosg / 0.Swift Evolution
Last active September 9, 2022 12:12
(iOS) Swift tutorial
https://github.com/apple/swift-evolution
@lamprosg
lamprosg / quicksort.cpp
Last active August 17, 2022 17:24
Quicksort algorithm
void quickSort(int arr[], int left, int right) {
int i = left, j = right;
int tmp;
int pivot = arr[(left + right) / 2];
/* partition */
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
@lamprosg
lamprosg / c-mask.mm
Last active May 26, 2022 15:29
(iOS) Image masking Objective-C / Swift
//http://www.innofied.com/implementing-image-masking-in-ios/
- (UIImage*) maskImage:(UIImage *) image withMask:(UIImage *) mask
{
CGImageRef imageReference = image.CGImage;
CGImageRef maskReference = mask.CGImage;
CGImageRef imageMask = CGImageMaskCreate(CGImageGetWidth(maskReference),
CGImageGetHeight(maskReference),
CGImageGetBitsPerComponent(maskReference),