Skip to content

Instantly share code, notes, and snippets.

View fcaldarelli's full-sized avatar

Fabrizio Caldarelli fcaldarelli

View GitHub Profile
@fcaldarelli
fcaldarelli / Prevent Safari loading from cache when back button is clicked.js
Last active April 16, 2021 10:17
Prevent Safari loading from cache when back button is clicked
// Javascript
window.onpageshow = function(event) {
if (event.persisted) {
window.location.reload()
}
};
// JQuery
$(window).bind("pageshow", function(event) {
if (event.originalEvent.persisted) {
@fcaldarelli
fcaldarelli / FullWidthTableViewCell.h
Last active August 29, 2015 14:23
UITableViewCell full width
#import <UIKit/UIKit.h>
@interface FullWidthTableViewCell : UITableViewCell
@end
@fcaldarelli
fcaldarelli / Launch Images iOS
Last active August 29, 2015 14:27
Launch screen image size in info.plist
UILaunchImage = Default // This is for iOS 6, if you need it
UILaunchImages // iOS 7, 8
- [0]
- UILaunchImageName = Default
- UILaunchImageMinimumOSVersion = 7.0
- UILaunchImageSize = {320, 480}
- UILaunchImageOrientation = Portrait
- [1]
- UILaunchImageName = Default-568h
@fcaldarelli
fcaldarelli / RadialGradientBackgroundView.m
Last active August 29, 2015 14:27
UIView with radial background color
#import "RadialGradientBackgroundView.h"
#define COLOR_VERDE_1 [UIColor colorWithRed:((float)0x00/0xFF) green:((float)0x9A/0xFF) blue:((float)0xA1/0xFF) alpha:1]
#define COLOR_VERDE_2 [UIColor colorWithRed:((float)0x28/0xFF) green:((float)0xB2/0xFF) blue:((float)0xA2/0xFF) alpha:1]
@implementation RadialGradientBackgroundView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
@fcaldarelli
fcaldarelli / UIButtonWithImageAndBottomTextCentered.m
Created August 12, 2015 15:40
UIButton with scaled image and bottom text centered
#import "ButtonWithImageAndBottomText.h"
@interface ButtonWithImageAndBottomText()
@property (nonatomic, assign) float imageScaleFactor;
@end
@implementation ButtonWithImageAndBottomText
@fcaldarelli
fcaldarelli / UIView+ChangeConstraint.h
Last active August 29, 2015 14:28
iOS Category methods to change constraints to UIView
#import <UIKit/UIKit.h>
@interface UIView(ChangeConstraint)
- (void)constraintChangeHeight:(CGFloat)fH;
@end
@fcaldarelli
fcaldarelli / CustomHttpHeader.java
Created September 10, 2015 23:58
Custom header in HTTP Request with Volley
public void requestWithSomeHttpHeaders() {
RequestQueue queue = Volley.newRequestQueue(this);
String url = "http://www.somewebsite.com";
StringRequest postRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
// response
Log.d("Response", response);
@fcaldarelli
fcaldarelli / AppTransportSecurityHTTP.plist
Last active March 31, 2016 20:40
Enable App Transport Security over HTTP protocol
// To check possible confiugrations of NSAppTransportSecurity, launch this command:
nscurl --verbose --ats-diagnostics https://example.com
otherwise
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
@fcaldarelli
fcaldarelli / Plesk 12.5 on Centos 7
Last active December 11, 2015 01:27
Plesk 12.5 on Centos 7
# Launch installer
wget -O - http://autoinstall.plesk.com/one-click-installer | sh
# Add firewall port permission
firewall-cmd --zone=public --add-port=8443/tcp --permanent
firewall-cmd --zone=public --add-port=8447/tcp --permanent
firewall-cmd --reload
@fcaldarelli
fcaldarelli / iOS-Recognize-Device.m
Last active December 7, 2015 11:48
iOS Recognize Device
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)