Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DIRECTORY=$1
echo "--------------------------------"
echo " Running script in:<$DIRECTORY> "
echo " <$DIRECTORY> "
echo "--------------------------------"
echo "Processing asset:"
find "$DIRECTORY" -name '*png' -print0 | while read -d $'\0' file;
do
@giulio92
giulio92 / In_your_networking_class.swift
Last active February 1, 2023 03:59
NSURLSession Proxy configuration
let sessionConfiguration: URLSessionConfiguration = .default
let proxyConfiguration: [AnyHashable : Any] = [
kCFNetworkProxiesHTTPEnable as AnyHashable: true,
kCFNetworkProxiesHTTPPort as AnyHashable: [Place-proxy's-port-number-here],
kCFNetworkProxiesHTTPProxy as AnyHashable: "Place-your-proxy-address-here"
]
sessionConfiguration.connectionProxyDictionary = proxyConfiguration
@giulio92
giulio92 / CollectionViewFlowLayoutSubclass.m
Last active November 29, 2016 08:51
Top aligned UICollectionViewCells
@implementation CollectionViewFlowLayoutSubclass
- (void)awakeFromNib {
[super awakeFromNib];
}
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *attributesToReturn = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in attributesToReturn) {
@giulio92
giulio92 / EasterDay.swift
Last active July 19, 2016 10:59
Calculate Easter day in Swift
import UIKit
func easterDay(Y : Int) -> NSDate {
let a: Int = Y % 19
let b: Int = Int(floor(Double(Y) / 100))
let c: Int = Y % 100
let d: Int = (19 * a + b - Int(floor(Double(b) / 4)) - Int(floor(Double(b - Int(floor(Double(b + 8) / 25)) + 1) / 3)) + 15) % 30
let e: Int = (32 + 2 * (b % 4) + 2 * Int(floor(Double(c) / 4)) - d - (c % 4)) % 7
let f: Int = Int(floor(Double(a + 11 * d + 22 * e) / 451))
@giulio92
giulio92 / GMSMapView+DisableDoubleTapZoom.h
Last active July 15, 2016 15:28
Google Maps iOS SDK wrong GMSOverlay in didTapOverlay fix
#import <GoogleMaps/GoogleMaps.h>
@interface GMSMapView (DisableDoubleTapZoom)
- (void)setDoubleTapZoomEnabled:(BOOL)enabled;
@end
@giulio92
giulio92 / getPixelColor.swift
Last active December 4, 2018 09:13
Get pixel color from UIImage in Swift
func getColorForPixel(image:CGImageRef, point:CGPoint) -> UIColor {
let imageWidth = CGImageGetWidth(image)
let imageHeight = CGImageGetHeight(image)
let imageRect = CGRect(x: 0, y: 0, width: imageWidth, height: imageHeight)
let bitmapBytesForRow = Int(imageWidth * 4)
let bitmapByteCount = bitmapBytesForRow * Int(imageHeight)
let colorSpace = CGColorSpaceCreateDeviceRGB()
@giulio92
giulio92 / InYourAppDelegate.swift
Last active March 2, 2016 15:13
Manage multiple networkActivityIndicator(s) just by calling a single function and passing a BOOL, the function will take care of the rest. Simple and easy.
var networkActivityIndicatorCount = 0
func setNetworkActivityIndicatorVisible(visible:Bool) {
if visible {
networkActivityIndicatorCount++
} else {
networkActivityIndicatorCount--
}
if networkActivityIndicatorCount < 0 {