Skip to content

Instantly share code, notes, and snippets.

@realvjy
realvjy / ChoasLinesShader.metal
Last active April 19, 2024 20:01
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@AlexKobachiJP
AlexKobachiJP / EditMode.swift
Last active February 15, 2024 05:24
Reimplementation of SwiftUI EditMode enum for macOS
// Documentation comments are copied from the official documentation for iOS.
import SwiftUI
#if os(macOS)
/// Reimplemenation of [EditMode](https://developer.apple.com/documentation/swiftui/editmode) for macOS.
public enum EditMode {
/// The user can edit the view content.
@mecid
mecid / Calendar.swift
Last active April 28, 2024 06:42
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@PaulWoodIII
PaulWoodIII / SelectedItems.swift
Created August 19, 2019 00:02
quick example of how to use selection in a SwiftUI list, an ObservableObject provides the content as well
//: [Previous](@previous)
import SwiftUI
import Combine
import PlaygroundSupport
class Context: ObservableObject {
@Published var selectedItems: Set<String>
@Published var items: Array<String>
@Oranzh
Oranzh / AES-256 encryption and decryption in PHP and C#.md
Created March 24, 2018 04:19
AES-256 encryption and decryption in PHP and C#

AES-256 encryption and decryption in PHP and C#

Update: There is a more secure version available. Details

PHP

<?php

$plaintext = 'My secret message 1234';
@jtdp
jtdp / gist:5443498
Last active January 24, 2024 08:59
Revert file permission changes in local git repository.. Very useful when you change permissions due to working on a samba share. Lifted from: http://stackoverflow.com/questions/2517339/git-how-to-recover-the-file-permissions-git-thinks-the-file-should-be
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply