Skip to content

Instantly share code, notes, and snippets.

View MaximKotliar's full-sized avatar
🚲
Педалю ровери

Maxim Kotliar MaximKotliar

🚲
Педалю ровери
View GitHub Profile
@gre
gre / easing.js
Last active July 11, 2025 12:47
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@DavidBoyes
DavidBoyes / gist:5290376
Created April 2, 2013 06:48
Returns a rectangle which is the largest that can fit inside a rotated rectangle
- (CGRect)cropRectForRectSize:(CGSize)rectSize rotation:(float)radians {
int quadrant = ((int)floor(radians / (M_PI / 2))) & 3;
float sign_alpha = ((quadrant & 1) == 0) ? radians : M_PI - radians;
float alpha = fmod((fmod(sign_alpha, M_PI) + M_PI), M_PI);
CGSize bb = CGSizeMake(rectSize.width * cos(alpha) + rectSize.height * sin(alpha), rectSize.width * sin(alpha) + rectSize.height * cos(alpha));
float gamma = rectSize.width < rectSize.height ? atan2(bb.width, bb.height) : atan2(bb.height, bb.width);
float delta = M_PI - alpha - gamma;
float length = rectSize.width < rectSize.height ? rectSize.height : rectSize.width;
@koenrh
koenrh / gcp-gpu-vm-hashcat.md
Last active June 23, 2025 01:06
Running Hashcat on Google Cloud's new GPU-based VMs

Running Hashcat on Google Cloud's GPU-based VMs

In February 2017, Google announced the availability GPU-based VMs. I spun up a few of these instances, and ran some benchmarks. Along the way, I wrote down the steps taken to provision these VM instances, and install relevant drivers.

Update April 2019: Updated instructions to use instances with the Tesla T4 GPUs.

@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active July 8, 2025 03:48
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@omarojo
omarojo / VideoMediaInput.swift
Last active May 13, 2024 06:35
How to use MTAudioProcessingTap in Swift 4.2
//
// VideoMediaInput.swift
// GenerateMetal-iOS
//
// Created by Omar Juarez Ortiz on 2018-11-28.
// Copyright © 2018 All rights reserved.
//
import Foundation
import UIKit
@RuiAAPeres
RuiAAPeres / SwiftUIBindsWithReactiveSwift.swift
Last active August 5, 2024 07:54
Couple of methods to bridge ReactiveSwift with SwiftUI
import Combine
import ReactiveSwift
import SwiftUI
class AnySubscription: Subscription {
private let cancelable: Cancellable
init(cancelable: Cancellable) {
self.cancelable = cancelable
import Foundation
// MARK: - Interval
struct Interval {
var low: Int
var high: Int
func overlaps(_ otherInterval: Interval) -> Bool {
return contains(otherInterval.low) || contains(otherInterval.high)
}
@Snowy1803
Snowy1803 / ContentView.swift
Last active December 31, 2024 11:53
This code allows you to use matchedGeometryEffect in SwiftUI while keeping iOS 13 compatibility in your app.
//
// ContentView.swift
// Example of using matchedGeometryEffect in iOS 13 code
// matchedGeometryEffect example code taken and adapted from :
// https://sarunw.com/posts/a-first-look-at-matchedgeometryeffect/
//
// Created by Emil Pedersen on 16/10/2020.
//
struct ContentView: View {
//
// coredock.h
// Header file for undocumented Dock SPI
//
// Arranged by Wolfgang Baird
// Based on CoreDockPrivate.h from http://www.cocoadev.com/index.pl?DockPrefsPrivate
//
// Contributors:
// Alacatia Labs: Initial version posted at http://www.cocoadev.com/index.pl?DockPrefsPrivate
// Tony Arnold: CoreDockGetWorkspacesEnabled, CoreDockSetWorkspacesEnabled, CoreDockSetWorkspacesCount