Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
#if UNITY_PS4
using UnityEngine.PS4;
#endif
using System.Collections;
using System.Collections.Generic;
using InControl;
public class InputVibration : SingletonBehaviour<InputVibrator>
{
@bogdanrybak
bogdanrybak / DataSerializer.cs
Last active May 18, 2024 13:32
FullSerializer / unity
using FullSerializer;
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class DataSerializer
{
private static readonly fsSerializer serializer = new fsSerializer();
public static string Serialize<T>(object value, bool prettify = false)
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public static class RandomUtility
{
public interface IWeighted
{
float Weight { get; }
@bogdanrybak
bogdanrybak / polygon_order
Created October 9, 2014 18:14
Polygon ordering
void OrderVerts(ref List<Vector2> vertices, Vector2 center)
{
vertices.Sort((v2, v1) => (Mathf.Atan2(v2.y - center.y, v2.x - center.x)).CompareTo(Mathf.Atan2(v1.y - center.y, v1.x - center.x)));
}
@bogdanrybak
bogdanrybak / gist:a5741b212e5edeb39ec0
Created August 21, 2014 16:26
Pixel art camera snapping (Unity3d)
public static float RoundToNearestPixel(float unityUnits, Camera viewingCamera)
{
float valueInPixels = (Screen.height / (viewingCamera.orthographicSize * 2)) * unityUnits;
valueInPixels = Mathf.Round(valueInPixels);
float adjustedUnityUnits = valueInPixels / (Screen.height / (viewingCamera.orthographicSize * 2));
return adjustedUnityUnits;
}
@bogdanrybak
bogdanrybak / Gruntfile.js
Created January 21, 2014 16:37
Simplest less compiling grunt task
module.exports = function(grunt) {
grunt.initConfig({
less: {
production: {
options: {
paths: ["assets/less"],
compress: true,
yuicompress: true
},
files: {
@bogdanrybak
bogdanrybak / mysql-to-s3.sh
Last active December 29, 2015 05:49
Backup mysql databases to Amazon S3 using AWS CLI.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MUSER="root"
MPASS="pass"
MHOST="localhost"
BACKUP_LOCATION="/backup/mysql"
AWS_BUCKET_NAME="my_bucket"
NOW=$(date +"%h-%d-%Y")
@bogdanrybak
bogdanrybak / update_wordpress.sh
Last active December 27, 2015 15:29
Shell script to apply before updating wordpress
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
echo "This will set permissions which will allow wordpress to auto-update for the specified web directory, then restore them to secure permissions when done."
echo -n "Enter the site path to work with: /var/www/"
read site