Skip to content

Instantly share code, notes, and snippets.

View daltonbr's full-sized avatar
🎮
Brighton - UK

Dalton Lima daltonbr

🎮
Brighton - UK
View GitHub Profile
@daltonbr
daltonbr / adb.sh
Last active July 15, 2020 20:29
adb commands
# adb docs
# https://developer.android.com/studio/command-line/adb
# check environment variables
# https://developer.android.com/studio/command-line/variables
$ adb devices
$ adb devices -l
# Connecting via WiFi
@daltonbr
daltonbr / WindowsSwitchPlatform.py
Last active February 19, 2020 18:52
Python script to fast switch platforms in Unity for Windows 10, relies in symlinks
#!/usr/bin/env python3-64
# Windows 10
# You can associate this file in Windows in order to avoid calling the Python interpreter
# right click -> Open With -> Choose Another App, and then choose Python.
import sys
import os
import shutil
from pathlib import Path
@daltonbr
daltonbr / RenameAndConvert.sh
Created January 7, 2020 23:56
Convert image formats and remove prefix
# remove prefix in files- batch
for file in bla_*; do mv "$file" "${file#bla_}";done;
# convert image (batch)
sudo apt-get install imagemagick
# convert all tif files into png
mogrify -format png *.tif
@daltonbr
daltonbr / MyLogClass.cpp
Created January 5, 2020 19:32
Unreal Log - my cheat sheet
#include "Engine/Engine.h"
#define PRINT(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Green,text)
void UMyLogClass::BeginPlay()
{
Super::BeginPlay();
auto Name = Owner->GetName();
UE_LOG(LogTemp, Warning, TEXT("[WorldPosition] (*Log) %s"), *Name);
@daltonbr
daltonbr / 81-C# Script-NewBehaviourScript.cs.txt
Last active November 29, 2019 10:32
My version of the Template for Unity C# MonoBehaviour, on Mac replace it in /Applications/Unity/Hub/Editor/<UnityVersion>/Unity.app/Contents/Resources/ScriptTemplates/81-C# Script-NewBehaviourScript.cs.txt
using UnityEngine;
#if UNITY_EDITOR
using UnityEngine.Assertions;
#endif
public class #SCRIPTNAME# : MonoBehaviour
{
#region Public Fields
#endregion
@daltonbr
daltonbr / ffmpeg.sh
Last active September 11, 2020 08:07
A few snippets for ffmpeg - Rescaling, trimming, converting & making gif's and popcorn 🍿
# Simple Image/video rescaling
ffmpeg -i input.avi -vf scale=320:240 output.avi
ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png
# Keeping the Aspect Ratio
# If we'd like to keep the aspect ratio, we need to specify only one component, either width or height,
# and set the other component to -1.
ffmpeg -i input.jpg -vf scale=320:-1 output_320.png
@daltonbr
daltonbr / wav_to_mp3.sh
Created November 4, 2019 11:38
ffmpeg converting media
ffmpeg -i input.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3
# Explanation of the used arguments in this example:
# -i - input file
# -vn - Disable video, to make sure no video (including album cover image) is included if the source would be a video file
# -ar - Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.
# -ac - Set the number of audio channels. For output streams it is set by default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. So used here to make sure it is stereo (2 channels)
# -b:a - Converts the audio bitrate to be exact 192kbit per second
@daltonbr
daltonbr / myFavoriteShell.sh
Last active September 5, 2019 09:46
Go Development - script for OSX
# Go development
export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"
# Then finally install go, with Homebrew.
# brew install go
@daltonbr
daltonbr / PageInspector.cs
Created March 12, 2019 10:55
A quick snippet of a Unity Custom Editor
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(Page))]
public class PageInspector : Editor {
public Material wordMat = null;
@daltonbr
daltonbr / shell.sh
Last active November 6, 2020 04:27
CLI 'youtube-dl' examples, how to easily download youtube videos
# brew install youtube-dl (on mac)
# https://github.com/rg3/youtube-dl
# alias
alias cd..="cd .."
alias sync="adb push --sync ~/Movies/*.mp4 mnt/sdcard/Movies/"
alias yt="youtube-dl -o '~/Movies/[%(release_date)s]-[%(id)s].%(title)s.%(ext)s' --restrict-filenames"
alias ytplaylist="youtube-dl -o '~/Movies/%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'"
alias mp3="youtube-dl --extract-audio --format bestaudio --audio-format mp3 --prefer-ffmpeg --audio-quality 160K --output '%(title)s.%(ext)s'"