Skip to content

Instantly share code, notes, and snippets.

View qqpann's full-sized avatar
🍊

Qiushi Pan qqpann

🍊
View GitHub Profile
[
{
"word": "Asshole",
"kana": "アスホール",
"meaning": "いやな奴(Ass=お尻、Hole=穴)",
"notice": "「うざい野郎」「ろくでなし」"
},
{
"word": "あばずれ",
"kana": "あばずれ",
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
bool gameHasEnded = false;
public float restartDelay = 2f;
public void EndGame()
{
@qqpann
qqpann / Trigger to end game.cs
Created June 17, 2021 16:22
Useful for death zone etc.
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
FindObjectOfType<GameManager>().EndGame();
}
}
@qqpann
qqpann / Click position detection.cs
Created June 17, 2021 16:22
Cast ray to mouse pointer and detect the clicked position
void Clicked()
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
destination = hit.point;
}
}
@qqpann
qqpann / Flip.cs
Created June 17, 2021 14:24
It's better to use transform than flipX for later convenience.
if (move.x > 0.01f)
//spriteRenderer.flipX = false;
transform.localScale = new Vector2(1, 1);
else if (move.x < -0.01f)
//spriteRenderer.flipX = true;
transform.localScale = new Vector2(-1, 1);
@qqpann
qqpann / bq_hash.py
Last active February 6, 2021 10:22
BigQuery read and save with hashed name
from pathlib import Path
from hashlib import sha256
datadir = Path('data')
def get_df_from_bq(sql: str, **opt):
hashed = sha256(sql.encode("utf-8")).hexdigest()
cache = datadir / "cache"
cache.mkdir(exist_ok=True)
fname = cache / f"{hashed}.csv"
@qqpann
qqpann / index.js
Created July 9, 2020 02:33 — forked from uiur/index.js
slack emoji -> github issue
const axios = require('axios')
const decode = require('decode-html')
const CHANNEL = '#dev'
const ISSUE_REPO = 'foo/bar'
exports.otochan = (req, res) => {
console.log('Received request:', req.body)
// slack challenge
if (req.body.challenge) {
@qqpann
qqpann / readme.md
Created January 5, 2020 16:50
[GitHub aware unicode check and ballot] #github #markdown #unicode
@qqpann
qqpann / currentfilepath.py
Created October 30, 2019 19:30
[Current file absolute path] python #python
import os
os.path.dirname(os.path.abspath(__file__))
@qqpann
qqpann / command.sh
Created July 18, 2019 15:05
Get full path to a file
realpath file.txt
#=> /data/real/path/to/file.txt