Skip to content

Instantly share code, notes, and snippets.

@lordlycastle
lordlycastle / BaseSingleton.cs
Last active May 7, 2024 14:41
Abstract singleton class for Unity.
using System.Linq;
using UnityEngine;
/// <summary>
/// Abstract singleton class for Unity. Updated with possible errors:
/// - Doesn't create a new singleton if it is in scene.
/// - Singleton has an initialize method which is called on creation, finding one from scene, or awake. Which makes sure initialization always happen before using it.
/// - It doesn't create a new single if you try to access it OnDestroy (e.g. game quit). Returns null instead.
/// </summary>
/// <typeparam name="TSingleton">Type of singleton. (Same as class inheriting from it.)</typeparam>
@ChathuraHettiarachchi
ChathuraHettiarachchi / MotionLayoutTry.kt
Last active May 7, 2024 14:36
This is a sample implementation of AirBnB search bar transition on Android usin Jetpack Compose MotionLayout, MotionScene with DSL. You need to replace the images on `destinations` to work this. FInd the video link https://twitter.com/i/status/1778640663086829622
package com.chootadev.composetryout
import androidx.annotation.DrawableRes
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.keyframes
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
@danielzen
danielzen / nvm-lazy.sh
Last active May 7, 2024 14:36
nvm lazy-load for zsh
# This script should be sourced from .zprofile to take advantage of the $ZSH_EXECUTION_STRING check
export NVM_DIR="$HOME/.nvm"
export NVM_SYMLINK_CURRENT=true
NODE_VERSION_DIR=$(readlink ~/.nvm/current) # Assumes ~/.nvm/current is linked
__NODE_GLOBALS=("${(@f)$(find "$NODE_VERSION_DIR"/bin -maxdepth 1 -mindepth 1 -type l -print0 | xargs --null -n1 basename | sort --unique)}")
__NODE_GLOBALS+=(node nvm)
found=false
for value in "${__NODE_GLOBALS[@]}"; do
# if zsh is trying to execute a command that matches one of the node globals in the current version
@f-o
f-o / Jigidi-Magic-Stripes.js
Created January 27, 2024 08:39
Userscript to streamline Jigidi solving
// ==UserScript==
// @name Jigidi Magic Stripes
// @namespace me.danq.com.jigidi.magicstripes
// @match https://www.jigidi.com/solve/*
// @grant GM_getValue
// @grant GM_setValue
// @version 1.1
// @author Dan Q <https://danq.me>
// @description 23/03/2023, 14:32:30
// ==/UserScript==
@miromannino
miromannino / service.md
Last active May 7, 2024 14:28 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debian/ubuntu

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name
@DanDiplo
DanDiplo / JS-LINQ.js
Last active May 7, 2024 14:27
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@TooTallNate
TooTallNate / repl-client.js
Created March 26, 2012 20:09
Running a "full-featured" REPL using a net.Server and net.Socket
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
@franzflasch
franzflasch / qemu-arm-with-busybox-linux-and-shared-folder.md
Last active May 7, 2024 14:26
Howto qemu-arm with busybox linux and shared folder

Install dependencies

apt-get install gcc-arm-linux-gnueabihf qemu

Prepare work directory

mkdir qemu-arm-sandbox && cd qemu-arm-sandbox
@TooTallNate
TooTallNate / bbs.js
Created March 16, 2012 22:42
Running a node.js REPL over `curl`
/**
* Requires node v0.7.7 or greater.
*
* To connect: $ curl -sSNT. localhost:8000
*/
var http = require('http')
, repl = require('repl')
, buf0 = new Buffer([0])
@marcorichetta
marcorichetta / postgresql-manjaro.md
Last active May 7, 2024 14:24
Install PostgreSQL on Manjaro and set it up for Django