Skip to content

Instantly share code, notes, and snippets.

@framundo
framundo / csv_sanitize.sh
Created December 1, 2017 17:48
CSV Sanitizer
#!/bin/bash
iconv -f ISO-8859-1 -t utf-8 $1 > utf8.csv
perl -pi -e 's/\r\n|\n|\r/\n/g' utf8.csv # Convert to UNIX
sed -e 's/,/\./g' -e 's/"/\\"/g' -e 's/;/","/g' -e 's/$/"/' -e 's/^/"/' utf8.csv > out.csv
gawk -F',' -v OFS=',' '{NF=6}1' out.csv > padded.csv
@framundo
framundo / numbers.json
Created November 30, 2016 11:52
json example
[1,2,3,5,8,13,21]
@framundo
framundo / leak.java
Created November 25, 2016 19:44
Leak
private void timer() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// Do something
timer();
}
}, 5000);
}
@framundo
framundo / leakFix.java
Created November 25, 2016 19:39
Leaking timer
Handler mHandler = new Handler();
Runnable mTimerRunnable = new Runnable() {
@Override
public void run() {
// Do something
timer();
}
};
@framundo
framundo / DragMove.cs
Created August 2, 2016 17:04
DragMove Changes
public class DragMove : NetworkBehaviour {
...
void Update () {
if (!isLocalPlayer)
return;
}
}
@framundo
framundo / AddToStadium.cs
Last active August 2, 2016 17:05
AddToStadium
using UnityEngine;
using System.Collections;
public class AddToStadium : MonoBehaviour {
void Start () {
GameObject stadium = GameObject.FindGameObjectWithTag ("Stadium");
transform.SetParent (stadium.transform, false);
}
}
@framundo
framundo / DragMove.cs
Created August 2, 2016 17:03
DragMove.cs
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class DragMove : NetworkBehaviour {
public float horozontalSpeed = 0.01f;
public float verticalSpeed = 0.01f;
void Update () {

Usage

You can call the utils anywhere in your code as long as you have access to a fragment or activity:

  ...
  PermissionUtils.requirePermission(fragmentOrActivity, new PermissionsListener() {
      @Override
      public void onPermissionsGranted() {
          // Code to execute using permission  
      }
 
public class ExampleFragment extends Fragment {
...
private void setupWorld() {
...
Triangle triangle = new Triangle();
mBasicRenderer.addModel(triangle);
mEasyGLView.setRenderer(mBasicRenderer);
}
public class Triangle extends Model3D {
private FloatBuffer vertexBuffer;
static final int COORDS_PER_VERTEX = 3;
static float triangleCoords[] = { // in counterclockwise order:
0.0f, 1.0f, 0.0f, // top
-0.5f, -0.5f, 0.0f, // bottom left
0.5f, -0.5f, 0.0f // bottom right