Skip to content

Instantly share code, notes, and snippets.

@ptsakyrellis
ptsakyrellis / ArrayDataSource.swift
Created February 15, 2016 15:17
Swift Class aimed to simplify the implementation of datasource methods for table or collection views where the data is an array.
/**
Class aimed to simplify the implementation of datasource methods for table or collection
views where the data is an array.
This allows us to re-use code and slim our view Controllers.
*/
import Foundation
import UIKit
class ArrayDataSource<CellType: UIView, ItemType>: NSObject, UITableViewDataSource, UICollectionViewDataSource {
var items: [ItemType]
@ptsakyrellis
ptsakyrellis / UICollection+.swift
Created March 14, 2016 21:14
CollectionType and MutableCollectionType extensions to be able to easily shuffle items
/**
CollectionType and MutableCollectionType extensions to be able to easily shuffle
items
*/
import Foundation
extension CollectionType {
/// Return a copy of "self" with its elements shuffled
func shuffle() -> [Generator.Element] {
var list = Array(self)
@ptsakyrellis
ptsakyrellis / UIFont+.swift
Created March 14, 2016 21:15
UIFont extensions to be able to get bold and bold italic fonts directlky from a UIFont object
/**
UIFont extensions to be able to get bold and bold italic fonts directlky
from a UIFont object
*/
import Foundation
import UIKit
extension UIFont {
func withTraits(traits:UIFontDescriptorSymbolicTraits...) -> UIFont {
@ptsakyrellis
ptsakyrellis / UIView+.swift
Created March 25, 2016 15:54
UIView extension to programmatically round specific corners of an UIView
extension UIView {
/**
Rounds the given set of corners to the specified radius
- parameter corners: Corners to round
- parameter radius: Radius to round to
*/
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
_roundCorners(corners, radius: radius)
}
@ptsakyrellis
ptsakyrellis / googleapiClient.php
Created February 11, 2018 16:45
Connect to Google API in PHP
<?php
$scope = 'https://www.googleapis.com/auth/analytics.readonly';
$jsonKeyFilePath = '../config/client_secrets.json';
$client = new \Google_Client();
$client->setScopes([$scope]);
$client->setAuthConfigFile($jsonKeyFilePath);
$client->useApplicationDefaultCredentials();
$client->fetchAccessTokenWithAssertion();
@ptsakyrellis
ptsakyrellis / gapi.js
Created February 11, 2018 19:03
Displays a google analytics chart
gapi.analytics.ready(function() {
/**
* Authorize the user with an access token obtained server side.
*/
gapi.analytics.auth.authorize({
'serverAuth': {
'access_token': '{{ token.access_token }}'
}
});
@ptsakyrellis
ptsakyrellis / php-config.yml
Created March 16, 2018 15:51
PuPHPet yaml config - PHP
php:
install: '1'
settings:
version: '70'
modules:
php:
- cli
- intl
- mbstring
- opcache
@ptsakyrellis
ptsakyrellis / apache-config.yml
Created March 16, 2018 15:54
PuPHPet config file apache section
apache:
install: '1'
settings:
version: 2.4
user: www-data
group: www-data
default_vhost: false
manage_user: false
manage_group: false
sendfile: 0
@ptsakyrellis
ptsakyrellis / AppKernel.php
Created March 16, 2018 15:56
Symfony AppKernel cache and log directories change
<?php
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test'))) {
return '/dev/shm/votre_appli/cache/' . $this->environment;
}
return parent::getCacheDir();
}
@ptsakyrellis
ptsakyrellis / config-nfs.yml
Created March 16, 2018 15:57
PuPHPet configuration file nfs section
sync_type: nfs #default
nfs:
mount_options: ['nfsvers=3','vers=3','actimeo=1','rsize=8192','wsize=8192','timeo=14','rw', 'vers=3', 'tcp']
linux__nfs_options: ['rw','no_subtree_check','all_squash','async']