Skip to content

Instantly share code, notes, and snippets.

@boboboa32
boboboa32 / FileWebService.swift
Last active March 11, 2023 10:38
Moya file download
import Moya
import SwiftyJSON
enum FileWebService {
case download(url: String, fileName: String?)
var localLocation: URL {
switch self {
case .download(let url, let fileName):
let fileKey: String = url.MD5 // use url's md5 as local file name
@Luzifer
Luzifer / README.md
Last active March 31, 2025 18:54
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@Hokila
Hokila / NotificationViewController.swift
Created July 27, 2017 15:07
Put AVPlayerLayer on UserNotification, also add play pause button
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
Contains ImageContentExtension's NotificationViewController.
*/
import UIKit
import UserNotifications
import UserNotificationsUI
@pandaApe
pandaApe / .swift
Created July 27, 2017 08:52
Moya Download File
import Foundation
import Moya
let endpointClosure = {
(target: FileService) -> Endpoint<FileService> in
let url = URL(string: target.path)?.absoluteString
return Endpoint(URL: url!,enter code here sampleResponseClosure: { .networkResponse(200, target.sampleData) }, method: target.method, parameters: target.parameters)
}
@candostdagdeviren
candostdagdeviren / .swiftlint.yml
Last active September 15, 2024 19:51
Sample SwiftLint file to apply best practices
disabled_rules: # rule identifiers to exclude from running
- variable_name
- nesting
- function_parameter_count
opt_in_rules: # some rules are only opt-in
- control_statement
- empty_count
- trailing_newline
- colon
- comma
@jochenschoellig
jochenschoellig / ChatCollectionViewFlowLayout.swift
Created January 19, 2017 15:49
A subclass of UICollectionViewFlowLayout to get chat behavior without turning collection view upside-down. This layout is written in Swift 3 and absolutely usable with RxSwift and RxDataSources because UI is completely separated from any logic or binding.
import UIKit
class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout {
private var topMostVisibleItem = Int.max
private var bottomMostVisibleItem = -Int.max
private var offset: CGFloat = 0.0
private var visibleAttributes: [UICollectionViewLayoutAttributes]?
@miohtama
miohtama / gist:0f64104fc8aefde8360f0c70cf46b950
Last active January 22, 2017 14:00
SMS based login for React and Websauna app
"""
allows users to sign up and login with their phone number, if that number is assoicated with an
existing customer record.
"""
import logging
import colander
from cornice.service import Service
from pyramid.exceptions import HTTPBadRequest
from pyramid_sms.utils import normalize_us_phone_number
@mikoim
mikoim / README.md
Last active March 30, 2025 06:04
[Updated! Aug 14 2020] YouTube recommended encoding settings on ffmpeg (+ libx264)

Parameters

Container: MP4

Parameter YouTube recommends setting
-movflags faststart moov atom at the front of the file (Fast Start)

Video codec: H.264

@jessejanderson
jessejanderson / intro-to-otp-in-elixir-resources.md
Last active September 27, 2024 08:14
Intro to OTP in Elixir - Resources
@ahmadshah
ahmadshah / randomizer.ex
Created September 1, 2016 10:28
Random string in elixir
defmodule Randomizer do
@moduledoc """
Random string generator module.
"""
@doc """
Generate random string based on the given legth. It is also possible to generate certain type of randomise string using the options below:
* :all - generate alphanumeric random string
* :alpha - generate nom-numeric random string