Skip to content

Instantly share code, notes, and snippets.

@tomazsaraiva
tomazsaraiva / virtualhosts.js
Last active January 6, 2020 23:52
[Apache Virtual Hosts] #mamp #unix #server #apache
// local
// edit the hosts
sudo nano /etc/hosts
// edit the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
<VirtualHost *>
DocumentRoot "/Users/tomazsaraiva/Documents/example/"
ServerName example.localhost
</VirtualHost>
Change the action of google-services.json to GoogleServicesJson
Generate SHA-1 certificate
https://developers.google.com/android/guides/client-auth
public void SaveContacts(string Name, string Number)
{
var store = new CNContactStore();
var contact = new CNMutableContact();
var cellPhone = new CNLabeledValue<CNPhoneNumber>(CNLabelPhoneNumberKey.Mobile, new CNPhoneNumber(Number));
var phoneNumber = new[] { cellPhone };
contact.PhoneNumbers = phoneNumber;
contact.GivenName = Name;
var saveRequest = new CNSaveRequest();
saveRequest.AddContact(contact, store.DefaultContainerIdentifier);
public abstract class ScreenTransitionData
{
public bool Dirty;
}
public class ScreenTransitionInfo
{
public Type Target
{
get;
public static class Utils
{
public static int DpToPixel(int dp)
{
return (int)(dp * Resources.System.DisplayMetrics.Density + 0.5f);
}
}
android:overScrollMode="never"
@tomazsaraiva
tomazsaraiva / LoadCRN.cs
Last active February 20, 2018 18:00
Unity texture utilities
public static Texture2D LoadCRN(byte[] data, bool mipmaps = false)
{
ushort width = System.BitConverter.ToUInt16(new byte[2] { data[13], data[12] }, 0);
ushort height = System.BitConverter.ToUInt16(new byte[2] { data[15], data[14] }, 0);
byte format = data[18];
TextureFormat textureFormat = TextureFormat.RGB24;
if (format == 0)
{
textureFormat = TextureFormat.DXT1Crunched;
@tomazsaraiva
tomazsaraiva / crunch-mipmaps.bat
Last active March 29, 2018 15:54
Advanced DXTc texture compression and transcoding library https://github.com/Unity-Technologies/crunch/tree/unity
@ECHO OFF
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf0.crn -mipMode UseSourceOrGenerate -maxmips 2
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf1.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 2048 2048
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf2.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 1024 1024
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf3.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 512 512
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf4.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 256 256
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf5.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 128 128
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf6.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 64 64
FOR %%f IN (*.jpg) DO crunch -file "%%f" -quality 255 -out %%~nf7.crn -mipMode UseSourceOrGenerate -maxmips 2 -rescale 32 32
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(MaterialScaleModifier))]
public class MaterialScaleModifierInspector : Editor
{
private MaterialScaleModifier _target;
using UnityEngine;
public class Builder : MonoBehaviour
{
[SerializeField]
private GameObject _prefab;
[SerializeField]
private Vector2 _grid;