Skip to content

Instantly share code, notes, and snippets.

View fcaldarelli's full-sized avatar

Fabrizio Caldarelli fcaldarelli

View GitHub Profile
// This two values identify the entry, together they become the
// primary key in the database
let myAttrService = "app_name"
let myAttrAccount = "first_name"
// DELETE keychain item (if present from previous run)
let delete_query: NSDictionary = [
kSecClass: kSecClassGenericPassword,
kSecAttrService: myAttrService,
// Inizializza il selettore della data di nascita
dateBirthDatePicker = UIDatePicker()
dateBirthDatePicker?.datePickerMode = .date
txtDateBirth.inputView = dateBirthDatePicker
let dateBirthAccessory = UIToolbar()
dateBirthAccessory.sizeToFit()
dateBirthAccessory.items = [ UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(onDateBirthDateBtnDoneTapped)) ]
txtDateBirth.inputAccessoryView = dateBirthAccessory
@fcaldarelli
fcaldarelli / .htaccess
Created March 13, 2019 10:40
Add this entry to avoid that Apache truncates Authorization header
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j SNAT --to 1.2.3.4
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl --system
@fcaldarelli
fcaldarelli / UIImageView-SFmobile.swift
Created December 17, 2018 23:49
UIImageView tint not change from xib
import UIKit
// fixing Bug in XCode
// http://openradar.appspot.com/18448072
extension UIImageView {
override open func awakeFromNib() {
super.awakeFromNib()
self.tintColorDidChange()
}
}
@fcaldarelli
fcaldarelli / custom_uiview_inspectable.swift
Created December 4, 2018 15:18
Custom UIView Inspectable
import Foundation
import UIKit
@IBDesignable
class MyButton: UIButton {
// Connect the custom button to the custom class
@IBOutlet weak var view: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
@fcaldarelli
fcaldarelli / GZipLogginInterceptor.java
Created November 27, 2018 09:05
GZip logging interceptor for OkHttp and Retrofit
package myapp;
import java.io.IOException;
import java.nio.charset.Charset;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
@fcaldarelli
fcaldarelli / apache2-allow-access-to-password-protected-folder.conf
Created September 25, 2018 19:53
apache2 allow access to password protected folder
<Directory "/path-to-protected">
AuthType Basic
AuthName "auth"
AuthUserFile "/auth-user-file-path"
require valid-user
SetEnvIf Request_URI "path-to-allow" allowed_restricted
Order allow,deny
@fcaldarelli
fcaldarelli / add-properties-swift-extensions.swift
Created September 7, 2018 22:07
Add properties to swift extensions
typealias IMG_VIEW_REQUESTS_TYPE = [ UIImageView : [String] ]
private struct AssociatedKey {
static var imgViewRequests = "imageCache_imgViewRequests"
}
var imgViewRequests : IMG_VIEW_REQUESTS_TYPE {
get {
return objc_getAssociatedObject(self, &AssociatedKey.imgViewRequests) as! SmartSingleton.IMG_VIEW_REQUESTS_TYPE
}
@fcaldarelli
fcaldarelli / file_provider_paths.xml
Created September 7, 2018 13:05
Uri file android target >= api 24
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>