Skip to content

Instantly share code, notes, and snippets.

Fabrizio Caldarelli FabrizioCaldarelli

Block or report user

Report or block FabrizioCaldarelli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View date-trait-query.php
class DateTraitQuery
public function andWhereDate($attribute, $value, $separators = ['/','-'])
$array = null;
foreach($separators as $separator)
if(strpos($value, $separator) !== false) $array = explode($separator, $value);
View ios-wkwebview-cookies.m
- (void)initWebView
// add session cookie to ajax calls
WKUserContentController* userContentController =;
WKUserScript * cookieScript =
[[WKUserScript alloc]
initWithSource: [[User sharedInstance] getJavscriptCookieString]
injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];

1. Create a script and place in /etc/init.d (e.g /etc/init.d/myscript). The script should have the following format:

# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions
View keychain-with-touch-id.swift
// 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,
View uitextfield-with-date-picker.swift
// Inizializza il selettore della data di nascita
dateBirthDatePicker = UIDatePicker()
dateBirthDatePicker?.datePickerMode = .date
txtDateBirth.inputView = dateBirthDatePicker
let dateBirthAccessory = UIToolbar()
dateBirthAccessory.items = [ UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(onDateBirthDateBtnDoneTapped)) ]
txtDateBirth.inputAccessoryView = dateBirthAccessory
FabrizioCaldarelli / .htaccess
Created Mar 13, 2019
Add this entry to avoid that Apache truncates Authorization header
View .htaccess
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
View Plesk forward traffic through
iptables -t nat -A POSTROUTING -s -j SNAT --to
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl --system
FabrizioCaldarelli / UIImageView-SFmobile.swift
Created Dec 17, 2018
UIImageView tint not change from xib
View UIImageView-SFmobile.swift
import UIKit
// fixing Bug in XCode
extension UIImageView {
override open func awakeFromNib() {
View custom_uiview_inspectable.swift
import Foundation
import UIKit
class MyButton: UIButton {
// Connect the custom button to the custom class
@IBOutlet weak var view: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
FabrizioCaldarelli /
Created Nov 27, 2018
GZip logging interceptor for OkHttp and Retrofit
package myapp;
import java.nio.charset.Charset;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
You can’t perform that action at this time.