Skip to content

Instantly share code, notes, and snippets.

View hervenivon's full-sized avatar
🎨
Teaching art to computers

Hervé Nivon hervenivon

🎨
Teaching art to computers
View GitHub Profile
@pauldambra
pauldambra / posthog-cloudfront.ts
Created July 20, 2022 10:08
A gist to create a cloudfront proxy for PostHog
import * as cdk from "aws-cdk-lib";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as cloudfront_origins from "aws-cdk-lib/aws-cloudfront-origins";
import { Construct } from "constructs";
// created by PostHog user CJ Enright
// shared in our community slack https://posthogusers.slack.com/archives/CTLTM70RM/p1657732914776719
// many thanks to them 🙌💖
export class PostHogProxy extends cdk.Stack {
constructor(scope: Construct, id: string) {
@robksawyer
robksawyer / excludedActivityTypes.swift
Last active March 7, 2024 09:10
A list of UIActivity.ActivityType for modern apps.
let excludedActivityTypes = [
UIActivity.ActivityType.print,
UIActivity.ActivityType.openInIBooks,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.mail,
UIActivity.ActivityType.markupAsPDF,
UIActivity.ActivityType.postToFacebook,
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020 16:47
Custom Segmented Picker / Segmented Control in SwiftUI
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@Harry-Harrison
Harry-Harrison / ContentView.swift
Last active July 11, 2023 10:42
Haptic Feedback Vibrations in SwiftUI
// This prints a list of buttons that on tap will fire a different type of haptic vibration
import SwiftUI
struct ContentView: View {
let generator = UINotificationFeedbackGenerator()
var body: some View {
VStack(alignment: .center, spacing: 30.0) {
Button(action: {
@RuiNelson
RuiNelson / Levenshtein.swift
Last active August 2, 2023 03:50
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 {
@alexcasalboni
alexcasalboni / index.md
Last active November 30, 2022 06:22
Bridge Function between Kinesis Streams and Step Functions

Bridge Function between Kinesis Streams and Step Functions

For each record read from the Kinesis Stream, a StepFunction state machine will be executed asynchronously.

Required Environment Variables

  • region: the AWS region where your StepFunction state machine is defined.
  • stateMachineArn: the ARN of the StepFunction state machine you want to execute.

Notes

@subfuzion
subfuzion / curl.md
Last active May 5, 2024 10:49
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@zacwest
zacwest / ios-font-sizes.swift
Last active May 4, 2024 13:41
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@Chandler
Chandler / slack_history.py
Last active March 26, 2024 14:35
Download Slack Channel/PrivateChannel/DirectMessage History
print("UPDATE AUG 2023: this script is beyond old and broken")
print("You may find interesting and more up to date resources in the comments of the gist")
exit()
from slacker import Slacker
import json
import argparse
import os
# This script finds all channels, private channels and direct messages
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],