Skip to content

Instantly share code, notes, and snippets.

View geekaurora's full-sized avatar

Tony Zhang geekaurora

View GitHub Profile
@timothycosta
timothycosta / UIViewController+SwiftUI.swift
Last active April 28, 2023 07:00
Using UIViewController via the SwiftUI Environment
struct ViewControllerHolder {
weak var value: UIViewController?
init(_ value: UIViewController?) {
self.value = value
}
}
struct ViewControllerKey: EnvironmentKey {
static var defaultValue: ViewControllerHolder { return ViewControllerHolder(UIApplication.shared.windows.first?.rootViewController ) }
@danielgalasko
danielgalasko / RepeatingTimer.swift
Last active March 28, 2024 10:26
A repeating GCD timer that can run on a background queue
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents
/// crashes that occur from calling resume multiple times on a timer that is
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52
class RepeatingTimer {
let timeInterval: TimeInterval
init(timeInterval: TimeInterval) {
self.timeInterval = timeInterval
}
@tanaikech
tanaikech / submit.md
Last active April 23, 2024 22:31
Multipart-POST Request Using Node.js

Multipart-POST Request Using Node.js

Here, I introduce 2 scripts for uploading files to Slack using Node.js as samples. These 2 sample scripts are for uploading files to Slack.

Sample script 1:

  • You can upload the zip file by converting byte array as follows.
    • At first, it builds form-data.
    • Adds the zip file converted to byte array and boundary using Buffer.concat().
    • This is used as body in request.
@ebraminio
ebraminio / upload.go
Last active March 22, 2023 06:01
golang upload client and server
// curl -X POST -H "Content-Type: application/octet-stream" --data-binary '@filename' http://127.0.0.1:5050/upload
package main
import (
"fmt"
"io"
"net/http"
"os"
"time"
@ehernandez-xk
ehernandez-xk / upload-file-s3.go
Last active January 31, 2021 00:56
Uploading a file to AWS S3 using aws-sdk-go
/*
https://www.youtube.com/watch?v=iOGIKG3EptI
https://github.com/awslabs/aws-go-wordfreq-sample/blob/master/cmd/uploads3/main.go
https://docs.aws.amazon.com/sdk-for-go/api/aws/
- first configure your aws credentials run: aws configure
- go get -u github.com/aws/aws-sdk-go/aws
- login to UI web aws s3 interface
- go to S3 service
@einfallstoll
einfallstoll / tutorial.markdown
Created May 3, 2016 06:13
How to detect a movie being played in a WKWebView?

How to detect a movie being played in a WKWebView?

I'd like to know wether it's possible to detect a movie being played in the WKWebView?

Additionally I'd like to know the exact URL of the opened stream?

Answer

Since the solution(s) to this question required a lot of research and different approaches, I'd like to document it here for others to follow my thoughts. If you're just interested in the final solution, look for some fancy headings.

@calebd
calebd / AsynchronousOperation.swift
Last active April 29, 2023 13:12
Concurrent NSOperation in Swift
import Foundation
/// An abstract class that makes building simple asynchronous operations easy.
/// Subclasses must implement `execute()` to perform any work and call
/// `finish()` when they are done. All `NSOperation` work will be handled
/// automatically.
open class AsynchronousOperation: Operation {
// MARK: - Properties
@homam
homam / AWS_S3_File_Upload.js
Created January 27, 2014 10:08
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
i
me
my
myself
we
our
ours
ourselves
you
your