Skip to content

Instantly share code, notes, and snippets.

@dasmer
dasmer / gup.py
Created December 4, 2019 06:15
Secret Santa Giftee Link Generator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 22:14:34 2019
@author: Mallika Walia & Dasmer Singh
"""
# List of secret santa participants (INPUT LIST)
gifters = [
@dasmer
dasmer / encrypted-name-ss-url.py
Created November 27, 2019 19:50
Secret Santa Encrypted Name URL Creator
import base64
from urllib.parse import quote
def secret_santa_url(input_string):
# Base64 Encoding
encodedBytes = base64.b64encode(input_string.encode("utf-8"))
encodedStr = str(encodedBytes, "utf-8")
# URL Encoding Encoding
url_b64_encoded_str = quote(encodedStr.encode('utf8'))
@dasmer
dasmer / apple_easter_egg_2019.txt
Created September 11, 2019 18:30
Apple Sept 2019 Event Easter egg
01010011 01101111 00100000 01111001 01101111 01110101 00100000 01110100 01101111 01101111 01101011 00100000 01110100 01101000 01100101 00100000 01110100 01101001 01101101 01100101 00100000 01110100 01101111 00100000 01110100 01110010 01100001 01101110 01110011 01101100 01100001 01110100 01100101 00100000 01110100 01101000 01101001 01110011 00111111 00100000
01010111 01100101 00100000 01101100 01101111 01110110 01100101 00100000 01111001 01101111 01110101 00101110
import Foundation
import UIKit
extension UITextView {
func rangeOfWordAtCurrentCursorLocation() -> NSRange? {
let selectedRange = self.selectedRange
if selectedRange.length == 0 {
return text.rangeOfWordAtLocation(location: selectedRange.location)
}
@dasmer
dasmer / invalidCast.m
Created February 10, 2016 03:49
Invalid Type Cast Objective C
// Suppose `urls` is an property of a class of type NSArray and it contains NSURLs
NSString *string = self.urls[0];
NSString *firstCharacter = [string subtringToIndex:1];
// This would break at runtime because we casted it to the wrong value type.
// We can get around this by creating NSArrays that are generic over NSURL. That way we would get a warning on the NSString cast.
// I may also mention that NSArrays can store objects of different types unlike Swift where all the object must be of the same type.
// That said, objects that contain multiple types that do not all inherit from the same object or conform to the same protocol usually should never be in the same NSArray
@dasmer
dasmer / API.md
Last active August 29, 2015 14:22 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

[SkyLab abTestWithName:@"Title" A:^{
self.titleLabel.text = NSLocalizedString(@"Hello, World!", nil);
} B:^{
self.titleLabel.text = NSLocalizedString(@"Greetings, Planet!", nil);
}];