Skip to content

Instantly share code, notes, and snippets.

View YoomamaFTW's full-sized avatar
🎯
Working abroad

YoomamaFTW

🎯
Working abroad
View GitHub Profile
@YoomamaFTW
YoomamaFTW / WKWebView+Other_Views_in_TableHeaderView.swift
Last active May 26, 2023 21:19
WKWebView in a UIView for tableHeaderView that auto-resizes - Swift 5.1
import UIKit
import WebKit
// This gist assumes you already have a UITableView setup
// This gist is designed to look like Reddit's DetailViewController, HOWEVER
// The point of a WKWebView is that images can be loaded
// This gist is NOT perfect; look in comments for what needs to be fixed.
class ViewController: UIViewController, WKNavigationDelegate {
@YoomamaFTW
YoomamaFTW / Custom_tableHeaderView_with_WKWebView.swift
Created December 15, 2019 15:24
Custom Table Header View with WKWebView not showing - Need Help
// THIS CODE DOES NOT SHOW THE HTML. The Gist is for an SO question and for future references.
import UIKit
import WebKit
class TableVC: UIViewController, WKNavigationDelegate {
let headerView = UITableViewHeaderFooterView()
let titleView = UILabel()
let webView = WKWebView()
override func viewDidLoad() {
@YoomamaFTW
YoomamaFTW / InfiniteTable.swift
Last active November 13, 2019 01:30
Problem with table loading cells after they come into view.
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var tableView: UITableView!
private var fetchingMore = false
var delay: Double!
var items = [[Any]]()
override func viewDidLoad() {
super.viewDidLoad()
@YoomamaFTW
YoomamaFTW / RichEditorViewController.swift
Last active October 27, 2019 19:50
RIchEditorView with Max Character Count Functionality (HTML) and Cursor Floating Under Keyboard on focus Temporary Fix (Swift 4 and 5)
import UIKit
import RichEditorView. // TODO: Download https://github.com/cbess/RichEditorView for Swift 5 support
class EditorViewController: UIViewController, RichEditorDelegate {
let editorView = RichEditorView()
var isEditingText: Bool!
var initString: String!
var prevText: String!
@YoomamaFTW
YoomamaFTW / PySimpleGUI_Scrollable_Window_macOS.py
Last active August 16, 2019 02:28
Mac users with PySimpleGUI, use the following padding for correct scrollable window
'''
As of August 15, 2019, using Python 3.7.4, PySimpleGUI == 4.1.0, macOS 10.14.6, macOS users will have trouble using scrolling or scrollable windows if you are using the Column layout method. The issue is a large portion of the bottom is unable to be in view, unless the user manually resizes the window by at least a few pixels.
EDIT: The formula works for any layering of elements in a scrollable window! So you can have a row with Text, a row with multiline, a row with buttons. It does not matter. The formula always works!
TL;DR Just add a final element in your layer with top padding like so:
layer += [sg.Text("Whatever you want. Maybe copyright", pad=(0, (22.5 * NUMBER_OF_ROWS - 13.0357, 0)))]
@YoomamaFTW
YoomamaFTW / twisted_for_windows.py
Last active August 3, 2019 17:53
How to install Twisted python package for Windows PCs
"""
First go here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
Download your preferred package based off your Python version by clicking on the name wanted. I HIGHLY recommend the 32-bit. (When installing with the 64-bit AMD version, I received an error saying the package was not supported).
Find where the package was downloaded. Usually, it's in C:\Users\(username)\Downloads
If this is your path:
"""
path = 'C:\Users\(username)\Downloads'
"""
@YoomamaFTW
YoomamaFTW / 0001_initial.py
Last active May 20, 2019 19:15
Django oversized migration file
"""Django oversized migration file. Missing two fields (ArrayFields) for the sake
of renaming a bunch of stuff in a different project. Overall 5970 lines"""
"""I have this system for a VERY/EXTREMELY specific application, so please don't recommend
reworking the models. This is using Django-Tagulous. Two fields have a tagulous field."""
# For https://stackoverflow.com/questions/56213264/migrations-file-too-large-preventing-migrate
# Generated by Django 2.2.1 on 2019-05-20 19:11
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion