Skip to content

Instantly share code, notes, and snippets.

View lionello's full-sized avatar
🇭🇰

Lio李歐 lionello

🇭🇰
View GitHub Profile
@lionello
lionello / writevt.c
Last active August 1, 2022 21:49
Forked writevt from console-tools
/*
* Mostly ripped off of console-tools' writevt.c
*/
#include <stdio.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
@lionello
lionello / Versioning.sh
Created June 13, 2022 16:42 — forked from bgreenlee/Versioning.sh
Automatic project versioning for Xcode using git commits & tags #xcode #git
#!/bin/sh
# Versioning.sh
#
# https://gist.github.com/791352 by Marc Hedlund
#
# Found at http://kswizz.com/post/2686511526/git-xcode-versioning and slightly
# modified.
# To install:
@lionello
lionello / cas128.c
Last active April 7, 2022 00:26
__sync_val_compare_and_swap for __uint128_t GCC built-in
/*
__sync_val_compare_and_swap that works with __uint128_t, by Lionello Lunesu.
Placed in the public domain
*/
#undef NDEBUG
#include <assert.h>
inline __uint128_t InterlockedCompareExchange128( volatile __uint128_t * src, __uint128_t cmp, __uint128_t with )
{
__asm__ __volatile__
@lionello
lionello / ModExp.sol
Last active March 17, 2022 13:07
Solidity wrapper for Ethereum Byzantium's BigInt `modexp` built-in contract 0x5
pragma solidity ^0.4.17;
contract ModExp {
// Wrapper for built-in bigint_modexp (contract 0x5) as described here https://github.com/ethereum/EIPs/pull/198
function modexp(bytes memory _base, bytes memory _exp, bytes memory _mod) public view returns(bytes memory ret) {
uint256 bl = _base.length;
uint256 el = _exp.length;
uint256 ml = _mod.length;
@lionello
lionello / translatekeycodes.swift
Created January 18, 2022 04:19 — forked from ArthurYidi/translatekeycodes.swift
virtual key codes to unicode characters
private static func keyCodeToString(keyCode: CGKeyCode, eventModifiers: Int) -> String? {
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let rawLayoutData = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData)
let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)
let keyboardLayoutPtr = unsafeBitCast(CFDataGetBytePtr(layoutData), to: UnsafePointer<UCKeyboardLayout>.self)
var deadKeyState: UInt32 = 0
var actualStringLength = 0
var unicodeString: [UniChar] = [0, 0, 0, 0]
{
/* put this file in ~/Library/KeyBindings/ */
/* Home */
"\UF729" = "moveToBeginningOfLine:";
"^\UF729" = "moveToBeginningOfDocument:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"^$\UF729" = "moveToBeginningOfDocumentAndModifySelection:";
/* End */
@lionello
lionello / .emacs
Created March 28, 2021 15:34
My .emacs
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
(setq package-enable-at-startup nil)
(package-initialize)
(custom-set-variables
999
"DXF R12 Output" (www.mydxf.blogspot.com)
0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
@lionello
lionello / OculusQuestCloudGaming.md
Last active July 7, 2021 06:24 — forked from blixt/OculusQuestCloudGaming.md
Playing SteamVR games on the Oculus Quest

Playing SteamVR games on the Oculus Quest, without owning a PC

Setting up your Virtual Machine

We'll be creating a new Virtual Machine on Microsoft's cloud platform, Azure. The VM will have a beefy GPU just like a home computer so it can be used for playing games.

  1. Go to [the Azure portal][azure] and sign up or log in.
  2. If you are on a Free account, first go to Subscriptions and upgrade it to a Pay-as-you-go plan. Don't worry, you will get to keep any free credits you have. Azure's interface is a bit slow so this will take a minute.

⚠️ Make sure to not include any support plan because they will charge you monthly!

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.