Skip to content

Instantly share code, notes, and snippets.

View caramelchocolate's full-sized avatar

caramelchocolate

View GitHub Profile
@caramelchocolate
caramelchocolate / test.sh
Created March 31, 2020 06:42
phpunit wrapper
#!/bin/sh
echo "--------------------------------------------------"
date +"%Y/%m/%d %H:%M:%S"
echo "--------------------------------------------------"
vendor/bin/phpunit -c phpunit.xml.dist
#!/bin/sh
#watchmedo shell-command -w --recursive --patterns "*.php" --ignore-directories --ignore-pattern '*/.*' --command 'echo "${watch_event_type} | ${watch_object} | ${watch_src_path}"' ./
watchmedo shell-command -w --recursive --patterns "*.php" --ignore-directories --command 'sh test.sh' ./
@caramelchocolate
caramelchocolate / composer.json
Created March 9, 2020 11:41
sample composer.json for phpunit
{
"require-dev": {
"phpunit/phpunit": "^9.0"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
}
}
@caramelchocolate
caramelchocolate / aTest.php
Created March 9, 2020 11:38
simple TestClass php file
<?php
use PHPUnit\Framework\TestCase;
class aTest extends TestCase
{
private $tempDir;
protected function setUp(): void
{
// ...
@caramelchocolate
caramelchocolate / BeforeAfterPattern.php
Created January 14, 2020 05:26
Design Pattern: Before/After Pattern
<?php
# ref: http://hyuki.com/dp/dpinfo.html#BeforeAfter
abstract class Executor {
abstract protected function before();
abstract protected function execute();
abstract protected function after();
public function perform () {
$this->before();
try {
$this->execute();
@caramelchocolate
caramelchocolate / DebugGizmos.cs
Last active January 12, 2020 12:31
Compute CapsuleCollider2D position(x) center
using UnityEngine;
public class DebugGizmos : MonoBehaviour {
void OnDrawGizmos() {
float halfWidth = GetComponent<SpriteRenderer>().bounds.extents.x;
float halfHeight = GetComponent<SpriteRenderer>().bounds.extents.y;
CapsuleCollider2D capsuleCollider2D = GetComponent<CapsuleCollider2D>();
@caramelchocolate
caramelchocolate / Floating.cs
Created January 9, 2020 09:12
Floating in midair with a Rigidbody2D(Not gravityScale = 0)
using UnityEngine;
public class Floating : MonoBehaviour
{
protected Rigidbody2D rbody;
void Start()
{
this.rbody = GetComponent<Rigidbody2D>();
this.rbody.mass = 20;
@caramelchocolate
caramelchocolate / Canvas.cs
Created January 1, 2020 07:01
Initialize Canvas
void Start() {
if (Camera.main != null) {
Camera.main.orthographicSize = ORTHOGRAPHIC_SIZE;
}
if (FindObjectOfType<EventSystem>() == null) {
var eventSystem = new GameObject("EventSystem", typeof(EventSystem));
eventSystem.AddComponent<StandaloneInputModule>();
}
@caramelchocolate
caramelchocolate / main.php
Created September 5, 2019 06:33
Random numbers
<?php
var_dump(preg_replace('/[^0-9]/', '', hash('sha256','test')));
?>
@caramelchocolate
caramelchocolate / check.sh
Last active August 5, 2019 09:52
chmod 777 in jail
#!/bin/sh
jls | awk 'NR>1 {print $4}' | awk -F'/' '{print $NF}' | xargs -L1 -I@ sh -c 'j=@; echo "${j}"; sh -c "ls -lt /jail/${j}/" | grep "tmp"; echo;'