Skip to content

Instantly share code, notes, and snippets.

View caramelchocolate's full-sized avatar

caramelchocolate

View GitHub Profile
@caramelchocolate
caramelchocolate / main.sh
Last active July 23, 2019 04:03
list php version in jails
#!/bin/sh
jls | awk 'NR>1 {print $4}' | awk -F'/' '{print $NF}' | xargs -I@ sh -c 'j=@; v=$(jexec ${j} php -v | head -1); echo "${j}: ${v}"'
@caramelchocolate
caramelchocolate / main.sh
Last active July 23, 2019 04:04
collect /etc/hosts in jail
#!/bin/sh
jls | awk 'NR>1 {print $4}' | awk -F'/' '{print $NF}' | xargs -I@ sh -c 'j=@; c=$(jexec ${j} cat /etc/hosts); echo "${c}" > "${j}.txt"'
@caramelchocolate
caramelchocolate / main.sh
Last active July 23, 2019 04:05
collect /usr/local/etc/postfix/main.cf in jail
#!/bin/sh
jls | awk 'NR>1 {print $4}' | awk -F'/' '{print $NF}' | xargs -I@ sh -c 'j=@; c=$(jexec ${j} test -e /usr/local/etc/postfix/main.cf && jexec ${j} cat /usr/local/etc/postfix/main.cf); echo "${c}" > "${j}.txt"'
@caramelchocolate
caramelchocolate / main.sh
Created August 4, 2019 06:02
display /etc/resolv.conf in jails
#!/bin/sh
find ./jail/base*/ -name 'resolv.conf' | xargs -L1 -I@ sh -c 'f="@";echo ">>>${f}";cat ${f}; echo "<<<${f}";echo;'
@caramelchocolate
caramelchocolate / main.sh
Created August 4, 2019 12:23
display "displayName" and "address" in VMware fusion
#!/bin/sh
find ~/Documents/Virtual\ Machines.localized/ -name '*.vmx' -print0 | xargs -0 -I@ -L1 sh -c 'f="@";cat ${f}|grep displayName|address'
@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;'
@caramelchocolate
caramelchocolate / main.php
Created September 5, 2019 06:33
Random numbers
<?php
var_dump(preg_replace('/[^0-9]/', '', hash('sha256','test')));
?>
@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 / 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 / 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>();