Skip to content

Instantly share code, notes, and snippets.

View Ashwinning's full-sized avatar

Ashwin Sinha Ashwinning

View GitHub Profile
@Ashwinning
Ashwinning / adbWiFiScreenrec.md
Last active November 16, 2016 06:15
This shows you how to connect to your non-rooted android phone over Wifi and record a screencap. #gistblog #android

Connecting adb over WiFi.

  1. Connect your phone over USB.

  2. Set the TCP port $ adb tcpip 5555.

  3. Run

$ adb kill-server
$ adb connect 192.168.2.5 
@Ashwinning
Ashwinning / GetRandomVector3Between.cs
Last active April 19, 2023 18:45
Find a random point between two Vector3 points. #gistblog #unity3d #c#
/// <summary>
/// Returns a random vector3 between min and max. (Inclusive)
/// </summary>
/// <returns>The <see cref="UnityEngine.Vector3"/>.</returns>
/// <param name="min">Minimum.</param>
/// <param name="max">Max.</param>
/// https://gist.github.com/Ashwinning/269f79bef5b1d6ee1f83
public Vector3 GetRandomVector3Between (Vector3 min, Vector3 max)
{
return min + Random.Range (0, 1) * (max - min);
/// <summary>
/// Rotates the point around a pivot.
/// </summary>
/// <returns>The rotated point.</returns>
/// <param name="point">Point.</param>
/// <param name="pivot">Pivot.</param>
/// <param name="rotation">Rotation.</param>
public Vector3 RotatePointAroundPivot (Vector3 point, Vector3 pivot, Quaternion rotation)
{
Vector3 direction = point - pivot; //Get point's direction relative to the pivot
@Ashwinning
Ashwinning / GetAllFilesInFolder.md
Last active November 3, 2016 05:11
Getting all files in a specified folder using Boost. #gistblog #c++ #boost

Getting all files in a specified folder using Boost.

Also check out how to get files of a specific type, and sorted results here!

#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>

//returns a list of all the files in a given folder.
std::vector<boost::filesystem::directory_entry> GetAllFilesInFolder(boost::filesystem::path folderPath)
@Ashwinning
Ashwinning / librealsenseColorIntrinsicPrinter.cpp
Last active February 6, 2018 06:56
Prints out the color intrinsics of a realsense camera with the librealsense library.
std::cout << " COLOR INTRINSICS \n ";
std::cout << "width : " + color_intrin.width << std::endl;
std::cout << "height : " + color_intrin.height << std::endl;
std::cout << "fx : " + std::to_string(color_intrin.fx) << std::endl;
std::cout << "fy : " + std::to_string(color_intrin.fy) << std::endl;
std::cout << "ppx : " + std::to_string(color_intrin.ppx) << std::endl;
std::cout << "ppy : " + std::to_string(color_intrin.ppy) << std::endl;
std::cout << "distortion coefficients : " << std::endl;
int loop = 1;
for (int coefficient : color_intrin.coeffs)
@Ashwinning
Ashwinning / PointCloudSavingExample.cs
Created April 19, 2016 22:33
The following example saves a Vector 3 List to a '.cloud' file.
using UnityEngine;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
/// <summary>
/// The following example saves a Vector 3 List to a '.cloud' file.
/// </summary>

Structure

Element Value Value Value
[0] TOTAL_NUMBER_OF_POINTS CONTAINS_COLOR_DATA COMPRESSED
[1] Vector3[1].x Vector3[1].y Vector3[1].z
[2] Vector3[2].x Vector3[2].y Vector3[2].z
[3] Vector3[3].x Vector3[3].y Vector3[3].z
[4] Color[1].r Color[1].g Color[1].b
[5] Color[2].r Color[2].g Color[2].b
@Ashwinning
Ashwinning / GetFilesOfTypeInDirectoryAndSort.md
Last active November 6, 2020 14:33
Getting all files of a specific type, in a specified folder using Boost. (returned in alphabetical order) #gistblog #boost #c++

Getting all files of a specific type, in a specified folder using Boost. (returned in alphabetical order)

//Accepts a path to a directory
//a file extension
//and a list
//Puts all files matching that extension in the directory into the given list.
//Sorts and returns the results
void GetFilesOfTypeInDirectory(const boost::filesystem::path &directoryPath, const string &fileExtension, std::vector<boost::filesystem::path> &list)
{
@Ashwinning
Ashwinning / OpenCVTextureinOpenGL.md
Last active May 21, 2023 11:54
Using webcam video as texture in OpenGL

OpenCV Texture in OpenGL.

The following code was found at http://www.alecjacobson.com/weblog/?p=1875

The page suffered from bad formatting so the contents have been pasted here for easier readibility.

// Modified from "Video Texture" code
// Copyright (C) 2009  Arsalan Malik (arsalank2@hotmail.com)
//                                                                            
@Ashwinning
Ashwinning / EnableDisableHyperV.md
Created June 9, 2016 00:22
Powershell scripts to enable disable Hyper-V.

Open Powershell as admin

To Enable

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All

To Disable

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All