Skip to content

Instantly share code, notes, and snippets.

@Manyaka
Manyaka / style.css
Created November 1, 2019 13:06
How to break an image out of its parent container with CSS
.full-width {
left: 50%;
margin-left: -50vw;
margin-right: -50vw;
max-width: 100vw;
position: relative;
right: 50%;
width: 100vw;
}
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI

Authoring Richly Formatted Audiobooks

Why Bother

If you're anything like me (and I recognize that most people aren't) then you listen to a lot of audiobooks in a year. As technology advances though, there can be a temptation to either rebuy audiobooks which you bought on other media like CD in the past or to skip content that is only available in older formats due to inconveniences like lack of bookmarking, inability to skip to a desired chapter, and the player not remembering your position between sessions.

Now I've not been one to let these things stop me, I figure there always has to be a way to author advanced audiobooks if you try hard enough. I know it's possible to convert books in a very basic way simply by merging all of the CD tracks into one file and converting it to M4A (AAC) and renaming the file extension and I've done so in the past. Unfortunately the only thing that helps with is the basic player position memory and iTunes doesn't include a way to merge the CD tracks into a single file

@tanaikech
tanaikech / submit.md
Last active March 20, 2024 04:21
Upload Files to Google Drive using Javascript

Upload Files to Google Drive using Javascript

News

At October 11, 2019, I published a Javascript library to to run the resumable upload for Google Drive. When this is used, the large file can be uploaded. You can also use this js library.

Description

This is a sample script for uploading files to Google Drive using Javascript. The files are uploaded by Drive API v3. gapi.client.drive.files.create() can create an empty file on Google Drive. But it cannot directly upload files including contents. I think that this might not be able to upload files and metadata with the multipart/related, although this might be resolved by the future update. So now, as one of workarounds, I use using XMLHttpRequest.

  • This sample uses gapi.
  • Before you use this, please enable Drive API at API console and carr
@GeorgeLyon
GeorgeLyon / Rust vs. Swift.md
Last active July 2, 2024 15:45
A list of advantages Swift has over Rust

Note This is a little out of date. Rust has made some progress on some points, however many points still apply.

Philosophy

Progressive disclosure

Swift shares Rust's enthusiasm for zero-cost abstractions, but also emphasizes progressive disclosure. Progressive disclosure requires that language features should be added in a way that doesn't complicate the rest of the language. This means that Swift aims to be simple for simple tasks, and only as complex as needed for complex tasks.

The compiler works for you

@wozuo
wozuo / SidebarViewController.swift
Created July 19, 2018 14:31
Programmatically create NSTableView in Swift 4.1
import Cocoa
class SidebarViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
var initialized = false
let scrollView = NSScrollView()
let tableView = NSTableView()
override func loadView() {
self.view = NSView()
@JohnSundell
JohnSundell / CrossPlatformImages.swift
Last active November 22, 2022 06:29
An easy way to make code that uses UIImage cross-platform between iOS/tvOS & macOS
// Either put this in a separate file that you only include in your macOS target
// or wrap the code in #if os(macOS) / #endif
import Cocoa
// Step 1: Typealias UIImage to NSImage
typealias UIImage = NSImage
// Step 2: You might want to add these APIs that UIImage has but NSImage doesn't.
extension NSImage {

Get/set ID3 meta tags using ffmpeg

A quick guide on how to read/write/modify ID3 metadata tags for audio / media files using ffmpeg.

FFmpeg has a free-form command line option that allows the user to specify key-value-pairs for encoding metadata. Let's take a look.

1. Read ID3 metadata

To list all global metadata tags for a media file, just set an input but no output file.

@abdullah
abdullah / selend.js
Last active April 30, 2024 11:00
Selection End Event
let selectionEndTimeout = null,
event = new Event('selectionEnd');
document.addEventListener('selectionEnd', function (evt/*event*/) {
console.log("End selection!")
}, false);
[
"mouseup",
@JayPanoz
JayPanoz / user_stylesheet_base.css.tmpl
Created November 25, 2015 17:44
iBooks's default CSS
@namespace epub "http://www.idpf.org/2007/ops";
@namespace svg "http://www.w3.org/2000/svg";
/* Hide soundtrack <audio> tags from ever showing up */
audio[epub|type~="ibooks:soundtrack"] {
display: none !important;
/* display: none; doesn't seem to actually work for some reason, so hide it another way */
height: 0 !important;
}