Skip to content

Instantly share code, notes, and snippets.

View rusik's full-sized avatar
🏄‍♂️

Ruslan Kavetsky rusik

🏄‍♂️
View GitHub Profile
@VsevolodGolovanov
VsevolodGolovanov / gist:7da8c08f8207c1c563120423cb723342
Last active June 29, 2024 12:12
Must app export profile data
Here's how to export your movie history from Must, just in case it goes under.
Go to https://mustapp.com/@<your_profile_name>/watched
Scroll down (hold End on keyboard) until the whole list is loaded.
Open Browser Developer Tools, Console.
Paste the following line and press Enter:
(() => { let exportResult = ""; $('.js_item_product').each((i, el) => exportResult += $(el).find('.poster__title').text() + '\t' + $(el).find('.poster__rate').text().trim() + '\n'); copy(exportResult); })();
Now your clipboard contains a list of Tab separated movie titles and ratings.
For Series (includes number of unwatched episodes after another Tab, if not finished):
(() => { let exportResult = ""; $('.js_item_product').each((i, el) => exportResult += $(el).find('.poster__title').text() + '\t' + $(el).find('.poster__rate_stars').text().trim() + '\t' + $(el).find('.poster__rate_progress').text().trim() + '\n'); copy(exportResult); })();
@harlanhaskins
harlanhaskins / swift-format.swift
Created October 26, 2017 19:48
Simple Swift Formatter using SwiftSyntax
import Foundation
import SwiftSyntax
func main() throws {
guard CommandLine.arguments.count > 1 else {
print("usage: swift-format [file]")
exit(-1)
}
let url = URL(fileURLWithPath: CommandLine.arguments[1])
//
// RealmSwift+Codable.swift
//
// Created by Michael Gray on 8/16/17.
//
import Foundation
import RealmSwift
// swiftlint:disable line_length identifier_name
@jinthagerman
jinthagerman / DateHelpers.swift
Created February 26, 2017 10:26
Time ago/ahead in Swift
import Foundation
struct DateComponentUnitFormatter {
private struct DateComponentUnitFormat {
let unit: Calendar.Component
let singularUnit: String
let pluralUnit: String
@robnadin
robnadin / DetailViewController.swift
Created February 16, 2015 00:47
Animated navigation bar tint color on push and interactive pop
//
// DetailViewController.swift
// TransitionCoordinator
//
// Created by Rob Nadin on 15/02/2015.
// Copyright (c) 2015 Rob Nadin. All rights reserved.
//
import UIKit
@minorbug
minorbug / timeago.swift
Created November 7, 2014 15:28
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C)
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String {
let calendar = NSCalendar.currentCalendar()
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond
let now = NSDate()
let earliest = now.earlierDate(date)
let latest = (earliest == now) ? date : now
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil)
if (components.year >= 2) {
return "\(components.year) years ago"
@brynbodayle
brynbodayle / gist:de70eb6a392e90272707
Created July 25, 2014 16:29
Multiline UIButton + Auto Layout
- (CGSize)intrinsicContentSize {
CGSize boundingSize = CGSizeMake(self.titleLabel.preferredMaxLayoutWidth - self.titleEdgeInsets.left - self.titleEdgeInsets.right, CGFLOAT_MAX);
NSAttributedString *attributedTitle = [self attributedTitleForState:self.state];
CGRect boundingRect;
if(attributedTitle) {
@subfuzion
subfuzion / redis-autostart-osx.md
Last active April 26, 2024 21:40
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@chourobin
chourobin / RKAppDelegate.m
Last active October 22, 2018 14:22
Setting up magical record with RestKit
#import <RestKit/RestKit.h>
#import "CoreData+MagicalRecord.h"
// Use a class extension to expose access to MagicalRecord's private setter methods
@interface NSManagedObjectContext ()
+ (void)MR_setRootSavingContext:(NSManagedObjectContext *)context;
+ (void)MR_setDefaultContext:(NSManagedObjectContext *)moc;
@end
@implementation AppDelegate