Skip to content

Instantly share code, notes, and snippets.

View xta's full-sized avatar

Rex Feng xta

View GitHub Profile
@xta
xta / swirls.pde
Created January 5, 2022 02:26 — forked from beesandbombs/swirls.pde
swirls
// by dave
float[][] result;
float t, c;
float ease(float p) {
p = c01(p);
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
//------------------------------------------------------------------------
// Author: The SwiftUI Lab
// Post: Advanced SwiftUI Animations - Part 4
// Link: https://swiftui-lab.com/swiftui-animations-part4 (TimelineView)
//
import SwiftUI
struct CyclicTimelineSchedule: TimelineSchedule {
let timeOffsets: [TimeInterval]
@xta
xta / jq-cheetsheet.md
Created June 22, 2021 19:12 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@xta
xta / web-servers.md
Created May 13, 2021 07:09 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten

Async calls

<template>
<!-- 
When isLoading is true, the <div> is in the DOM, the <p> is not.
When isLoading is false, Vue will remove the <div> and add the <p> to the DOM,
at which point <MyComponent> will be created and passed the fetched data.
-->
import Foundation
import SwiftUI
struct GradientCircle: View {
var body: some View {
let color1 = Color.init(red: 81/255, green: 204/255, blue: 159/255)
let color2 = Color.init(red: 154/255, green: 255/255, blue: 248/255)
let spectrum = Gradient(colors: [ color1, color2])
let conic =
LinearGradient(gradient: spectrum, startPoint: UnitPoint(x: 0, y: 0.5), endPoint: UnitPoint(x: 0.5, y: 1))
//--------------------------------------------------
// The SwiftUI Lab: Advanced SwiftUI Animations
// https://swiftui-lab.com/swiftui-animations-part1
//--------------------------------------------------
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red
@xta
xta / IAPHandler.swift
Created August 25, 2018 08:22 — forked from DejanEnspyra/IAPHandler.swift
[SWIFT] How to add In-App Purchases in your iOS app.
//
// IAPHandler.swift
//
// Created by Dejan Atanasov on 13/07/2017.
// Copyright © 2017 Dejan Atanasov. All rights reserved.
//
import UIKit
import StoreKit