Skip to content

Instantly share code, notes, and snippets.

@t3dotgg
t3dotgg / try-catch.ts
Last active April 19, 2025 03:29
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@sebjvidal
sebjvidal / SceneDelegate.swift
Created June 27, 2023 18:14
Custom UINavigationBar Height
// MARK: - SceneDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil)
(navigationController.navigationBar as! NavigationBar).preferredHeight = 88
navigationController.setViewControllers([ViewController()], animated: false)
@kyledrake
kyledrake / ferengi-plan.txt
Last active January 10, 2025 14:02
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
@Plastix
Plastix / name_checker.php
Created December 30, 2013 17:00
PHP script used for checking the availability of Minecraft usernames. Requires a text file called names.txt in the same directory as the script with one name per line. Available names are saved to available_names.txt.
<?php
// Checks the availability of Minecraft usernames given a text file of names
$names = Array();
$input = "./names.txt"; //Names to be checked (one per line)
$output= "./available_names.txt"; //Available names
$names = file($input, FILE_IGNORE_NEW_LINES);
if(file_exists($output)) file_put_contents($output, "");
foreach( $names as $name ) {
anonymous
anonymous / night-before-opsmas.txt
Created December 24, 2013 07:19
Twas the night before Opsmas..
'Twas the night before Christmas, when all through the racks
Not a server was alerting, not even Compaqs.
The backups were written to tapes with care
In hopes that later the data would be there.
The machines were nestled all snug in their sleds
Whilst visions of vengeance danced in their heads;
And oncall in his three-wolf and I in my rack.
Had just settled down for some syn and some ack.
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@aadnk
aadnk / Attributes.java
Last active September 15, 2020 10:13
Edit attributes in 1.6.2 (Not dependent on ProtocolLib). See https://github.com/aadnk/AttributeStorage/tree/nms for 1.7.2.
package com.comphenix.example;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Dinnerbone
Dinnerbone / gist:5631634
Last active May 14, 2020 12:41
New chat system for Minecraft. The server won't translate any text for the client, and there'll be a proper stack based colouring/formatting system, so no more leaking colours, english-only messages, or out of date translations.
{
"color": "yellow",
"translate": "multiplayer.player.joined",
"using": [
"Dinnerbone"
]
}
{
"color": "gray",
@tonybruess
tonybruess / Bukkit Entity Spawning.md
Last active November 27, 2017 18:59
Bukkit Entity Spawning

Entities that work:

  • Arrow
  • Bat
  • Blaze
  • Boat bow charge has no effect, always spawns on player head
  • CaveSpider
  • Chicken
  • Cow
  • Creeper
  • Egg
@csexton
csexton / deploy.rb
Created January 10, 2013 16:53
Capistrano Recipe to skip asset compilation if nothing has changed
namespace :deploy do
namespace :assets do
def should_update_assets
from = source.next_revision(current_revision)
capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
rescue
true
end
task :precompile, :roles => :web, :except => { :no_release => true } do