Skip to content

Instantly share code, notes, and snippets.

View chriswitko's full-sized avatar

Chris Witko chriswitko

View GitHub Profile
@chriswitko
chriswitko / Shimmer.swift
Created April 4, 2025 02:36 — forked from xavierLowmiller/Shimmer.swift
Slide-to-Unlock animation in SwiftUI
import SwiftUI
public struct Shimmer: AnimatableModifier {
private let gradient: Gradient
@State private var position: CGFloat = 0
public var animatableData: CGFloat {
get { position }
@chriswitko
chriswitko / rating.js
Created September 11, 2024 02:15
Rating Web Component
class RatingComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.code = this.getAttribute('code') || '';
this.render();
}
get open() {
return this.hasAttribute('open');
@media (max-width: 47.9375em) {
}
@chriswitko
chriswitko / zoomImage.css
Created July 15, 2024 13:13 — forked from adilsonfsantos/zoomImage.css
Pure JS/CSS image zoom on click
picture {
cursor: zoom-in;
height: 0;
max-height: 1250px;
max-width: 1400px;
padding-top: 50%;
position: relative;
width: 100%;
&::before {
@chriswitko
chriswitko / style.css
Created November 13, 2023 08:51 — forked from mohammad-ahid/style.css
CSS hack to hide Chrome default date picker styles
// @see http://stackoverflow.com/questions/11320615/disable-browser-native-datepicker
input::-webkit-calendar-picker-indicator{
display: none;
}
input[type="date"]::-webkit-input-placeholder{
visibility: hidden !important;
}
const regions = ['pl']
const displayNames = new Intl.DisplayNames('pl', {type: 'region'})
export default function App() {
return (
<main>
<select>
{regions.map((code) => (
<option key={code} value={code}>{displayNames.of(code)}</option>
@chriswitko
chriswitko / PomodoroPicker.swift
Created November 24, 2022 03:00 — forked from dmr121/PomodoroPicker.swift
SwiftUI - Snapping horizontal scrolling pomodoro picker
//
// PomodoroPicker.swift
// pomodoro
//
// Created by David Rozmajzl on 1/1/22.
//
import SwiftUI
struct PomodoroPicker<Content, Item: Hashable>: View where Content: View {
@chriswitko
chriswitko / CustomColorScheme.swift
Created October 14, 2022 18:13 — forked from ryanlintott/CustomColorScheme.swift
Custom color scheme view modifier for SwiftUI. Sets the color scheme to light mode, dark mode, or matches the system. If set to match, the app will respond to system-wide color scheme changes properly. A simple widget color scheme implementation is also provided.
import SwiftUI
enum CustomColorScheme: Int, CaseIterable, Identifiable, Codable {
static var defaultKey = "customColorScheme"
static var defaultValue = CustomColorScheme.system
case system = 0
case light = 1
case dark = 2
import UIKit
import SwiftUI
// 🐧 Manager Singleton
class SomeThemeManager: ObservableObject {
static var shared = SomeThemeManager()
@Published var currentTheme = SomeTheme.normal
}

Full socket.io client and server example

Last updated: 2021-02-21, tested with socket.io v3.1.1

This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

If you're looking for examples using frameworks, check these links: