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
<?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 =
WKUserContentController.new;
WKUserScript * cookieScript =
[[WKUserScript alloc]
initWithSource: [[User sharedInstance] getJavscriptCookieString]
injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
View create-new-linux-service.md

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

#!/bin/bash
# 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.sizeToFit()
dateBirthAccessory.items = [ UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(onDateBirthDateBtnDoneTapped)) ]
txtDateBirth.inputAccessoryView = dateBirthAccessory
@FabrizioCaldarelli
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
</IfModule>
View Plesk forward traffic through VPN.sh
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
@FabrizioCaldarelli
FabrizioCaldarelli / UIImageView-SFmobile.swift
Created Dec 17, 2018
UIImageView tint not change from xib
View UIImageView-SFmobile.swift
import UIKit
// fixing Bug in XCode
// http://openradar.appspot.com/18448072
extension UIImageView {
override open func awakeFromNib() {
super.awakeFromNib()
self.tintColorDidChange()
}
}
View custom_uiview_inspectable.swift
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)
@FabrizioCaldarelli
FabrizioCaldarelli / GZipLogginInterceptor.java
Created Nov 27, 2018
GZip logging interceptor for OkHttp and Retrofit
View GZipLogginInterceptor.java
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;
You can’t perform that action at this time.