Skip to content

Instantly share code, notes, and snippets.

@DrNeuroSurg
DrNeuroSurg / DeviceOrientationManager.cs
Created January 15, 2021 11:31 — forked from yasirkula/DeviceOrientationManager.cs
Easily enable/disable auto screen orientation in Unity and receive callback upon orientation change. See the comments section below for instructions.
using UnityEngine;
public class DeviceOrientationManager : MonoBehaviour
{
private const float ORIENTATION_CHECK_INTERVAL = 0.5f;
private float nextOrientationCheckTime;
private static ScreenOrientation m_currentOrientation;
public static ScreenOrientation CurrentOrientation
@DrNeuroSurg
DrNeuroSurg / AD9833_example.ino
Created January 2, 2021 10:38 — forked from m5mat/AD9833_example.ino
AD9833 Example
/*
AD9833 Waveform Module vwlowen.co.uk
*/
#include <SPI.h>
const int SINE = 0x2000; // Define AD9833's waveform register value.
const int SQUARE = 0x2028; // When we update the frequency, we need to
const int TRIANGLE = 0x2002; // define the waveform when we end writing.
@DrNeuroSurg
DrNeuroSurg / scrollView-snap.swift
Created September 27, 2020 14:03 — forked from brownsoo/scrollView-snap.swift
UITableView snap tp cells
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if scrollView == suggestionsTableView {
let cellHeight = CGFloat(60.0)
let y = targetContentOffset.pointee.y + scrollView.contentInset.top + (cellHeight / 2)
let cellIndex = floor(y / cellHeight)
targetContentOffset.pointee.y = cellIndex * cellHeight - scrollView.contentInset.top
}
}
@DrNeuroSurg
DrNeuroSurg / Levenshtein.swift
Created November 21, 2018 08:21 — forked from RuiNelson/Levenshtein.swift
Levenshtein distance between two String for Swift 4.x
import Foundation
extension String {
subscript(index: Int) -> Character {
return self[self.index(self.startIndex, offsetBy: index)]
}
}
extension String {
public func levenshtein(_ other: String) -> Int {