Skip to content

Instantly share code, notes, and snippets.

View avgx's full-sized avatar
💭
アルバイト

Alexey avgx

💭
アルバイト
View GitHub Profile
@tigi44
tigi44 / SheetPresentation.swift
Last active February 20, 2024 14:40
Using a UISheetPresentationController on SwiftUI
import SwiftUI
// MARK: - SheetPresentation
public extension View {
func sheetPresentation<SheetView: View>(isPresented: Binding<Bool>, @ViewBuilder sheetView: @escaping () -> SheetView, onDismiss: SheetPresentationController<SheetView>.DefaultClosureType? = nil) -> some View {
self.background(
@RundesBalli
RundesBalli / 01-README.md
Last active November 6, 2024 11:44
Server online-status check with reporting to telegram

Server online-status check with reporting to telegram

This simple script uses netcat to check if - for instance - a webserver is running on a server. If the service is not running, it utilizes the telegram bot API for sending a message to inform the operator of the server.

How to

1. Register the bot

Go to the BotFather bot-account and create a bot by writing /newbot. Then, copy the token.

2. Find your chat-id

Send a message to you newly created bot (you can find the link to your bot in the success message sent by BotFather).

@ghecho
ghecho / qr.swift
Last active May 29, 2019 12:32
Generate a QR image from a string using Swift 4
import CoreImage
static func createQR(fromString: String) -> CIImage?
{
let stringData = fromString.data(using: .utf8)
let filter = CIFilter(name: "CIQRCodeGenerator")
filter?.setValue(stringData, forKey: "inputMessage")
filter?.setValue("H", forKey: "inputCorrectionLevel")
let qrCodeImage = filter?.outputImage
let imageByTransform = qrCodeImage?.transformed(by: CGAffineTransform(scaleX: 15.0, y: 15.0))
@yudetamago
yudetamago / sampleScrollview.swift
Created May 4, 2017 14:46
UIScrollView with SnapKit
import UIKit
import SnapKit
func setScrollView(content: UIView) {
// called in ViewController
self.edgesForExtendedLayout = []
let scrollView = UIScrollView()
let wrapper = UIView()
@swankjesse
swankjesse / HostSelectionInterceptor.java
Last active September 27, 2025 02:40
This OkHttp application interceptor will replace the destination hostname in the request URL.
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;
@neworld
neworld / howto.md
Last active July 10, 2024 11:24
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
package bbbb;
import org.immutables.value.Value;
@Value.Immutable
public interface Complex {
@Value.Parameter double re();
@Value.Parameter double im();
}
@oc2pcoj
oc2pcoj / Good IOS RTSP Player.md
Last active July 31, 2025 07:19
iOS RTSP player for IP video cameras
@orta
orta / ServiceProvider.swift
Created September 12, 2015 19:32
Example Code for a TVServices - TopShelfExtension
//
// ServiceProvider.swift
// TopShelfExtension
//
// Created by Orta Therox on 12/09/2015.
// Copyright © 2015 Artsy. All rights reserved.
//
import Foundation
import TVServices