Skip to content

Instantly share code, notes, and snippets.

View fcaldarelli's full-sized avatar

Fabrizio Caldarelli fcaldarelli

View GitHub Profile
@fcaldarelli
fcaldarelli / android_studio_rename_package.md
Created December 30, 2015 08:55
Android Studio rename Package

For example, if you want to change com.example.app to my.awesome.game, then:

  1. In your Project pane, click on the little gear icon ( gears )

project pane

  1. Uncheck / De-select the Compact Empty Middle Packages option

  2. Your package directory will now be broken up in individual directories

@fcaldarelli
fcaldarelli / bootable_usb_stick_using_mac.md
Last active December 30, 2015 14:08
Bootable USB stick using Mac

Instructions (five steps) to create a bootable usb stick (with iso file):

  1. Convert .iso in .img (if you have .iso file);

hdiutil convert -format UDRW -o /path/to/target.img /path/to/ubuntu.iso

  1. Run diskutil list to discover usb stick device number;

diskutil list

@fcaldarelli
fcaldarelli / Close keyboard when clicking on return key of textbox.cs
Last active January 11, 2016 17:45
Close keyboard when clicking on return key of textbox
// In Page class
public sealed partial class CustomPage : Page
{
public CustomPage()
{
this.InitializeComponent();
//...
// This will give input focus capability to page
@fcaldarelli
fcaldarelli / Order database results with specific field values.sql
Last active January 22, 2016 09:58
Order database results with specific field values
-- Specific order clause
-- In PostgreSQL can be used CASE ... WHEN in order clause:
ORDER BY
CASE field_to_order
WHEN 'value1' THEN 1
WHEN 'value2' THEN 2
WHEN 'value3' THEN 3
ELSE 4
END,
import java.util.List;
import java.util.UUID;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
// If it returns false, validation stops here (and afterValidate event will not be called)
$('form').on('beforeValidate', function(event, messages, deferreds) {
var extraConditionsSuccess = false;
/*
* Verify extraConditionsSuccess
*/
// if false, afterValidate event will not be called
@fcaldarelli
fcaldarelli / Logger.h
Created April 9, 2016 11:31
Logger Macro for iOS
//
// Logger.h
// SlotCore
//
// Created by Fabrizio on 08/04/16.
// Copyright © 2016 Fabrizio Caldarelli. All rights reserved.
//
#ifndef Logger_h
#define Logger_h
@fcaldarelli
fcaldarelli / Generate unique code.php
Created July 20, 2016 20:24
Generate unique code string in PHP
<?php
// In this case, 4bytes, 8 charactes.
$bytes = 4;
$cstrong = true;
$uid = bin2hex(openssl_random_pseudo_bytes($bytes, $cstrong));
?>
@fcaldarelli
fcaldarelli / UIColor from hex.m
Last active August 18, 2016 22:53
UIColor from hex string (RGB or RGBA)
+ (UIColor *)colorWithHexString:(NSString *)hexWithAlphaString {
UIColor *c = nil;
unsigned long long rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:hexWithAlphaString];
[scanner setScanLocation:0]; // bypass '#' character
[scanner scanHexLongLong:&rgbValue];
if(hexWithAlphaString.length == 6)
{
c = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
@fcaldarelli
fcaldarelli / Disable verbose log in Xcode 8
Created October 17, 2016 13:57
Disable verbose log in Xcode 8
1- From Xcode menu open: Product > Scheme > Edit Scheme
2- On your Environment Variables set OS_ACTIVITY_MODE = disable