Skip to content

Instantly share code, notes, and snippets.

View MrLotU's full-sized avatar
:shipit:
┻━┻ミ㇏(ಠ益ಠ)ノ彡┻━┻

Jari (LotU) MrLotU

:shipit:
┻━┻ミ㇏(ಠ益ಠ)ノ彡┻━┻
View GitHub Profile
@MrLotU
MrLotU / hideKeyboard_swiftui.swift
Created August 7, 2020 12:42
How to hide a keyboard in SwiftUI
extension UIApplication {
func endEditing() {
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
extension View {
func endEditing() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
import UserNotifications
let center = UNUserNotificationCenter.current()
center.getDeliveredNotifications { notifications in
let identifiers = notifications.map(\.request.identifier)
center.removeDeliveredNotifications(withIdentifiers: identifiers)
}
import SwiftUI
struct ScrollCeption: View {
var body: some View {
ScrollView {
VStack {
ForEach(0..<10) { _ in
ScrollView(.horizontal) {
HStack {
ForEach(0..<5) { _ in
@MrLotU
MrLotU / subpull.sh
Created June 28, 2020 09:38
Pull all GIT subdirectories from current directory.
subpull() {
BASEPWD="${PWD}"
for d in `find . -type d -depth 1`; do
cd "${BASEPWD}"
cd "${d}"
GIT_STATUS="$(git status 2>&1)"
if [[ $GIT_STATUS == *"not a git repository"* ]]
then
echo "${d} is not under git control. Skipping"
continue
import SceneKit
// Part 1: Distance
extension SCNVector3 {
func distance(to vector: SCNVector3) -> Float {
return simd_distance(simd_float3(self), simd_float3(vector))
}
}
import SwiftUI
func > (_ lhs: CGSize, _ rhs: CGSize) -> Bool {
return lhs.width > rhs.width && lhs.height > rhs.height
}
struct MyView: View {
@State var biggestSize: CGSize = .zero
@staticmethod
def log(f=None):
def deco(f):
@functools.wraps(f)
def func(*args, **kwargs):
audit = AuditModel()
user = request.headers.get("X-Auth-User")
if user is None:
return 'UNAUTHORIZED. Please provide X-Auth-User header.', 403
audit.user = user
import functools
from datetime import datetime
from flask import request
from peewee import *
from playhouse.postgres_ext import *
class AuditModel(Model):
id = AutoField()
user = TextField()
Column Type Nullable Default
id integer not null nextval('requests_id_seq'::regclass)
user text not null
request text not null
status text not null 'to-do'::text

Indexes:
"requests_pkey" PRIMARY KEY, btree (id)

@MrLotU
MrLotU / change_pfp.py
Last active October 11, 2023 13:54
Changes the profile picture of a discord bot
import discord
#############################################################################################################################
# USAGE: #
# 0. Make sure you have python 3.5 + installed and have discord.py installed (pip3 install discord) #
# 1. Download the python file #
# 2. Change the token variable to hold your bots token and the pfp variable to hold the path to your desired pfp #
# 3. Run your file using `python3 path/to/file.py #
# 3. That's it, you can keep the file or delete it again! #
#############################################################################################################################