Skip to content

Instantly share code, notes, and snippets.

int childs = transform.childCount;
for (int i = childs - 1; i > 0; i--)
{
GameObject.Destroy(transform.GetChild(i).gameObject);
}
@litvil
litvil / gist:0620a7b808f57a13d9c8
Last active August 29, 2015 14:16
Unity3d. Camera touch movement
// http://stackoverflow.com/questions/11497085/move-camera-over-terrain-using-touch-input-in-unity-3d/27836741#27836741
using UnityEngine;
using System.Collections;
public class ViewDrag : MonoBehaviour {
Vector3 hit_position = Vector3.zero;
Vector3 current_position = Vector3.zero;
Vector3 camera_position = Vector3.zero;
float z = 0.0f;
@litvil
litvil / gist:19f2caf4d1d8bd87093c
Created February 24, 2015 09:33
Unity3d. Camera touch movement - 2
private Vector2 worldStartPoint;
void Update () {
// only work with one touch
if (Input.touchCount == 1) {
Touch currentTouch = Input.GetTouch(0);
if (currentTouch.phase == TouchPhase.Began) {
this.worldStartPoint = this.getWorldPoint(currentTouch.position);
@litvil
litvil / spiral_path
Last active August 29, 2015 14:20
Create spiral path from center to borders inside rectangle
private function createSpiralSearchPath(max_x:int, max_y:int, start_point:Point = null):Vector.<Point> {
var current_cell:Point = new Point();
if (start_point){
current_cell.x = start_point.x;
current_cell.y = start_point.y;
}else{
current_cell.x = int(max_x * 0.5);
current_cell.y = int(max_y * 0.5);
}
@litvil
litvil / air_multi
Last active August 29, 2015 14:23
Code changes AIR application id, and it is posible to launch many same applications
public static function changeAirAppId():void {
var file:File = File.applicationDirectory.resolvePath(APP_CONF_PATH + APP_CONF_FILE);
Logger.log(file.url);
if (file.exists) {
var ObiectXML:XML = readXMLFromFile(file);
var ns:Namespace = ObiectXML.namespace();
var time:Date = new Date();
ObiectXML.ns::id[0] = 'Bot' + time.valueOf().toString();
var sourceFile:File = File.applicationStorageDirectory.resolvePath(APP_CONF_FILE);
@litvil
litvil / adjust
Created June 23, 2015 10:23
AdjustColor Hue Saturation Brightness Contrast of a MovieClip
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
var colorFilter:AdjustColor = new AdjustColor();
var mColorMatrix:ColorMatrixFilter;
var mMatrix:Array = [];
var MC:MovieClip = new MovieClip();
function adjustColors():void
{
@litvil
litvil / AS3 Shapes
Last active August 29, 2015 14:24 — forked from AlexHannigan/AS3 Shapes
package {
//import necessary classes
import flash.display.Sprite;
import flash.display.Graphics;
public class Circle extends Sprite {
private var canvas:Sprite = new Sprite();
private var gr:Graphics = canvas.graphics;

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh [email protected]

Add ssh fingerprint and enter password provided in email

@litvil
litvil / controller_registrator.rb
Created January 13, 2016 16:57
ControllerRegistrator
module ControllerRegistrator
def get_controller_class(name)
if self.class.controller_classes[name].is_a?(Class)
return self.class.controller_classes[name]
end
self.class.controller_classes[name].call(self)
end
def controllers
@controllers ||= {}