Skip to content

Instantly share code, notes, and snippets.

View Nyx0uf's full-sized avatar
🏠
Working from home

Nyx0uf Nyx0uf

🏠
Working from home
View GitHub Profile
@Nyx0uf
Nyx0uf / zeroconf.swift
Last active January 27, 2023 10:49
ZeroConf swift socket
import Foundation
import Logging
protocol ZeroConfExplorerDelegate: AnyObject {
func didFindServer(_ server: MPDServer)
}
final class ZeroConfExplorer: NSObject {
// MARK: - Public properties
// Is searching flag
@Nyx0uf
Nyx0uf / ncmpcpp.config
Created April 1, 2020 15:54
ncmpcpp config
mpd_host "::1"
mpd_port "6600"
mpd_music_dir "/Users/nxm/Music/beets/"
# NCMPCPP
ncmpcpp_directory = ~/.ncmpcpp
lyrics_directory = ~/.ncmpcpp/lyrics
# UI
user_interface = "alternative"
@Nyx0uf
Nyx0uf / mpd.conf
Last active April 1, 2020 15:45
mpd config
music_directory "/Users/nxm/Music/beets/"
db_file "/Users/nxm/Music/mpd/mpd.db"
pid_file "/Users/nxm/Music/mpd/mpd.pid"
state_file "/Users/nxm/Music/mpd/mpd.state"
sticker_file "/Users/nxm/Music/mpd/stickers"
playlist_directory "/Users/nxm/Music/mpd/playlists/"
auto_update "yes"
auto_update_depth "5"
filesystem_charset "UTF-8"
@Nyx0uf
Nyx0uf / beets.yaml
Last active April 1, 2020 15:45
beets config
directory: /Users/nxm/Music/beets
library: ~/.config/beets/music.blb
pluginpath: ~/.config/beets/plugins/
plugins: inline info ftintitle smartplaylist mpdupdate
threaded: yes
ignore: .AppleDouble ._* *~ .DS_Store
asciify_paths: yes
art_filename: cover
per_disc_numbering: yes
sort_case_insensitive: yes
@Nyx0uf
Nyx0uf / NYXAVCEncoder.swift
Created February 3, 2016 10:35
Hardware accelerated GIF to MP4 converter in Swift using VideoToolbox
import VideoToolbox
import AVFoundation
private var __canHWAVC: Bool = false
private var __tokenHWAVC: dispatch_once_t = 0
public protocol NYXAVCEncoderDelegate : class
{
func didEncodeFrame(frame: CMSampleBuffer)
func didFailToEncodeFrame()
@Nyx0uf
Nyx0uf / gist:217d97f81f4889f4445a
Last active November 15, 2020 22:31
UIImage scale using vImage
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize
{
// Create a vImage_Buffer from the CGImage
CGImageRef sourceRef = self.CGImage;
vImage_Buffer srcBuffer;
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst,
@Nyx0uf
Nyx0uf / fastgzdeflate
Created January 16, 2012 18:32
Fast gzip deflate for small files
-(NSData*)gzDeflate
{
/// Max decompressed data size : 128Kb
/// Feel free to increase it to suit your needs
unsigned char outt[131072];
z_stream strm = (z_stream){.zalloc = Z_NULL, .zfree = Z_NULL, .opaque = Z_NULL, .avail_in = [self length], .next_in = (Bytef*)[self bytes], .avail_out = 131072, .next_out = outt};
if (inflateInit2(&strm, (15 + 16)) != Z_OK)
return nil;