Skip to content

Instantly share code, notes, and snippets.

View 0xdw's full-sized avatar
:octocat:
Learning

Dinindu 0xdw

:octocat:
Learning
View GitHub Profile
@0xdw
0xdw / ABOUT.md
Created April 23, 2022 02:35 — forked from laobubu/ABOUT.md
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@0xdw
0xdw / BinaryDataStream.cs
Created April 16, 2021 05:39
Unity - Reading and writing binary file (Save file)
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
namespace Utility {
public static class BinaryDataStream {
private static readonly string Path = Application.persistentDataPath + "/saves/";
private const string Ext = ".dat";
@0xdw
0xdw / GrabPassBlur.shader
Created March 4, 2021 08:07
Unity - Grab Pass Blue Shader
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/GrabPassBlur"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_BumpAmt ("Distortion", Range (0,128)) = 10
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
@0xdw
0xdw / RGB_TO_HEX.cpp
Created February 20, 2021 13:02
C++ RGB to HEX Converter
// RGB_TO_HEX.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <string>
#define CHECK_FOR_RANGE(channel) \
if (channel > 255) { \
std::cerr << "Invalid " << #channel << " channel" << std::endl; \
exit(0); \
@0xdw
0xdw / DeviceType.cs
Created February 17, 2021 16:29
Unity - Detecting between a tablet/iPad and mobile
public enum DeviceType {
Tablet,
Phone
}
@0xdw
0xdw / CheckPixelColor.cs
Created February 10, 2021 04:04
Unity - Pick color in the screen point (x, y)
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
public class CheckPixelColor : MonoBehaviour {
private void Update() {
if (Input.GetMouseButtonDown(0)) {
if (EventSystem.current.IsPointerOverGameObject(-1) || EventSystem.current.IsPointerOverGameObject(0) ||
EventSystem.current.IsPointerOverGameObject(1)) {
return;
@0xdw
0xdw / DailyRewards.cs
Created February 1, 2021 02:26
Unity - Simple Daily Rewards
using System;
using UnityEngine;
public static class DailyRewards {
private const int RewardValue = 100;
public static int Coins;
private static DateTime LastRewardTime {
get {
long time = long.Parse(PlayerPrefs.GetString(nameof(LastRewardTime), "0"));
@0xdw
0xdw / GameManager.cs
Created January 24, 2021 13:46
Unity - Add a description to a custom script
using UnityEngine;
public class GameManager : MonoBehaviour { }
@0xdw
0xdw / Enemy.cs
Last active January 24, 2021 14:06
Unity - Draw Icon on GameObject in Hierarchy & Assign icon to a custom script
using UnityEngine;
/**
* As my understanding is for each MonoBehaviour in your assembly,
* Unity looks for an associated icon with the name "<className> Icon"
* under the "Gizmos" folder, but the hierarchy must match the namespace.
* So you can add your icon in Assets/Gizmos/Enemy Icon.png
*/
public class Enemy : MonoBehaviour { }
@font-face {
font-family: "Crimson";
src: url("font/crimson-roman.woff") format("woff");
}
@font-face {
font-family: "Crimson";
src: url("font/crimson-italic.woff") format("woff");
font-style: italic;
}