Skip to content

Instantly share code, notes, and snippets.

View valentincognito's full-sized avatar
💤

Valentin valentincognito

💤
View GitHub Profile
@valentincognito
valentincognito / firstActiveObjectIndex.cs
Created September 14, 2017 07:44
Get the index of the first active child
private int GetFirstActiveindex(GameObject _parentObject)
{
for (int i = 0; i < _parentObject.transform.childCount; i++)
{
if (_parentObject.transform.GetChild(i).gameObject.activeSelf == true) return i;
}
return 0;
}
@valentincognito
valentincognito / basicLerp.cs
Created September 14, 2017 10:43
Add a smooth effect to a transform position
transform.position = Vector3.Lerp(startPos, endPos, Time.deltaTime * speed);
@valentincognito
valentincognito / deleteCommitSoft.md
Last active November 2, 2017 01:52
List of useful commands for the git command line interface

Delete the most recent commit

Keeping the work you've done

$ git reset --soft HEAD~1

Destroying the work you've done

@valentincognito
valentincognito / blender_shortcuts.md
Last active March 22, 2018 07:54
List of shortcuts and other useful tips

Shortcuts

Camera

align with current view: ctrl + alt + 0 (numpad)

3D View

recenter 3D view pivot: select object -> Numpad.

Parents and groups

clear parent: alt + p

@valentincognito
valentincognito / letterSpacing.cs
Created September 19, 2017 10:00
Letter spacing script for Unity
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
/*
http://forum.unity3d.com/threads/adjustable-character-spacing-free-script.288277/
Unity 5.4 compatible version
Produces an simple tracking/letter-spacing effect on UI Text components.
Set the spacing parameter to adjust letter spacing.
@valentincognito
valentincognito / commandLineCheatSheet.md
Last active November 28, 2017 09:40
All about this magic plugin

Command line cheat sheet

Images sequence to video

ffmpeg -i DSC_%03d.jpg out.mp4

Standard video codecs

@valentincognito
valentincognito / gridLayout.java
Created June 7, 2018 06:06
GridLayout how to stretch all children evenly
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:id="@+id/choice_grid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="4dp"
@valentincognito
valentincognito / addViewToLayout.java
Created June 7, 2018 07:56
Create and add a new imageView in a relativeLayout with parameters
RelativeLayout rl = findViewById(R.id.spenViewLayout);
ImageView duplicate = new ImageView(getApplicationContext());
duplicate.setImageDrawable(getDrawable(R.drawable.love));
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(300, 300);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
rl.addView(duplicate, params);
@valentincognito
valentincognito / layout_child_iterate.java
Created June 15, 2018 06:45
Loop through a Layout view to access all children
GridView myLayout = findViewById(R.id.myLayoutId);
for (int i = 0; i < myLayout.getChildCount(); i++) {
// Int our case the gridView contains videos
VideoView v = (VideoView) myLayout.getChildAt(i);
// Start the video
v.start();
}
@valentincognito
valentincognito / get_screen_size.java
Created June 22, 2018 02:16
Get the screen dimension at runtime
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;