Skip to content

Instantly share code, notes, and snippets.

@ryanapil
ryanapil / Player.cs
Created Mar 31, 2020
Unity Input System FPS Toggle Perspective (First Person/Third Person)
View Player.cs
using UnityEngine;
using UnityEngine.InputSystem;
public class Player : MonoBehaviour {
InputActions controls;
public enum Perspective
{
firstPerson, thirdPerson
@ryanapil
ryanapil / Player.cs
Last active Mar 31, 2020
Unity Input System FPS Movement
View Player.cs
using UnityEngine;
using UnityEngine.InputSystem;
public class Player : MonoBehaviour {
InputActions controls;
public float speed = 1f;
public float sensitivity = 1f;
@ryanapil
ryanapil / Index.php
Last active Apr 10, 2019
PHP Image Compression Function
View Index.php
function compress($source, $destination, $quality) {
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg') {
$image = imagecreatefromjpeg($source);
} elseif ($info['mime'] == 'image/gif') {
$image = imagecreatefromgif($source);
} elseif ($info['mime'] == 'image/png') {
$image = imagecreatefrompng($source);
}
imagejpeg($image, $destination, $quality);
@ryanapil
ryanapil / connect.php
Created Jan 23, 2019
MySQLi Connection File
View connect.php
<?php
$mysqli = new mysqli($var["database"]["hostname"], $var["database"]["username"], $var["database"]["password"], $var["database"]["database"]);
if ($mysqli->connect_error) {
die("Connect Error (" . $mysqli->connect_errno . ") " . $mysqli->connect_error);
}
?>
@ryanapil
ryanapil / ajax.js
Last active Nov 13, 2018
jQuery AJAX Call Template
View ajax.js
$.ajax({
url: "",
method: "GET",
data: {
},
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
@ryanapil
ryanapil / main.js
Created Apr 8, 2018
jQuery smooth scroll to # links
View main.js
$(document).ready(function() {
$("a[href^='#']").on("click", function(event) {
event.preventDefault();
var target = this.hash,
$target = $(target);
$("html, body").stop().animate({
"scrollTop": $target.offset().top
}, 900, "swing", function() {
window.location.hash = target;
});
@ryanapil
ryanapil / main.js
Last active Apr 3, 2018
jQuery search input through table rows
View main.js
var searchTimeout = 0;
$("input[name='search']").on("keyup paste", function() {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(function() {
var searchValue = $("input[name='search']").val().toLowerCase().trim();
$("table tbody tr").addClass("d-none");
$("table tbody").find("tr").each(function(i) {
if (~$(this).html().toLowerCase().trim().indexOf(searchValue)) {
$(this).removeClass("d-none");
}