Skip to content

Instantly share code, notes, and snippets.

View kjantzer's full-sized avatar
👨‍💻
Likely writing JavaScript

Kevin Jantzer kjantzer

👨‍💻
Likely writing JavaScript
View GitHub Profile
@DaveWoodCom
DaveWoodCom / String+Email.swift
Last active February 28, 2021 16:45
Swift method to check for a valid email address (uses Apples data detector instead of a regex)
extension String {
func isValidEmail() -> Bool {
guard !self.lowercaseString.hasPrefix("mailto:") else { return false }
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingType.Link.rawValue) else { return false }
let matches = emailDetector.matchesInString(self, options: NSMatchingOptions.Anchored, range: NSRange(location: 0, length: self.characters.count))
guard matches.count == 1 else { return false }
return matches[0].URL?.scheme == "mailto"
}
}
@blixt
blixt / Event.swift
Last active January 19, 2023 19:42
A simple Event class for handling events in Swift without strong retain cycles.
import Foundation
private class Invoker<EventData> {
weak var listener: AnyObject?
let closure: (EventData) -> Bool
init<Listener : AnyObject>(listener: Listener, method: (Listener) -> (EventData) -> Void) {
self.listener = listener
self.closure = {
[weak listener] (data: EventData) in
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@Erutan409
Erutan409 / MimeType.php
Last active February 15, 2022 18:10
Mime Type Function for PHP
<?php
function mime_type($file) {
// there's a bug that doesn't properly detect
// the mime type of css files
// https://bugs.php.net/bug.php?id=53035
// so the following is used, instead
// src: http://www.freeformatter.com/mime-types-list.html#mime-types-list
<?php
/**
* FTP with Implicit SSL/TLS Class
*
* Simple wrapper for cURL functions to transfer an ASCII file over FTP with implicit SSL/TLS
*
* @category Class
* @author Max Rice / Damith Jayasinghe
* @since 1.0
*/
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@natelandau
natelandau / .bash_profile
Last active April 30, 2024 18:07
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@pinceladasdaweb
pinceladasdaweb / imgur.js
Created March 27, 2014 13:14
Upload images to imgur via JavaScript
/*
--------------------------------
imgur Upload
--------------------------------
+ https://github.com/pinceladasdaweb/imgur-upload
+ version 1.1
+ Copyright 2014 Pedro Rogerio
+ Licensed under the MIT license
+ Documentation: https://github.com/pinceladasdaweb/imgur-upload
@blimmer
blimmer / fixMavericksUnicastIssue
Created October 31, 2013 00:30
Bash script to resolve unicast issue on Mac 10.9 (Mavericks). This fix is temporary and does not persist a reboot (unlike other scripts floating around).
#!/bin/bash
# Mavericks has a nasty issue regarding ARPs in corporate networks.
# It appears that they have tried to reduce bandwidth utilization by caching
# the results of ARPs. Unfortunately, this causes big problems with corporate
# networks with Virtual IPs or other corporate network redundancy measures.
# There exist other patches for this issue
# (see https://github.com/MacMiniVault/Mac-Scripts/blob/master/unicastarp/unicastarp-README.md)
# but they write a value that will be pulled everytime the machine reboots. Because
@khanlou
khanlou / UIImageView+Network.h
Last active June 9, 2020 07:34
Quick and dirty UIImageView with networking
//
// UIImage+Network.h
// Fireside
//
// Created by Soroush Khanlou on 8/25/12.
//
//
#import <UIKit/UIKit.h>