This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz limit | |
i = 1 | |
answers = [['fizzbuzz', 'buzz'], ['fizz', i]] | |
loop do | |
puts answers[(i % 5) >> (Math.log2((i % 5) + 1).ceil - 1)][(i % 3) >> (Math.log2((i % 3) + 1).ceil - 1)] | |
i += 1 | |
1/((limit + 1) - i) | |
answers[1][1] = i | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzzNoMod limit | |
i = 1.0 | |
answers = [['fizzbuzzxx', 'buzzxx'], ['fizzxx', i]] | |
loop do | |
puts answers[(i / 5.0).ceil - (i / 5.0).floor][(i / 3.0).ceil - (i / 3.0).floor].to_s.chop.chop | |
i += 1.0 | |
1/((limit + 1.0) - i).to_i | |
answers[1][1] = i | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz limit, start | |
loop do | |
puts "#{'fizz' * (~(((start % 3) >> (Math.log2((start % 3) + 1).ceil - 1)) * 2))[1]}#{'buzz' * (~(((start % 5) >> (Math.log2((start % 5) + 1).ceil - 1)) * 2))[1]}#{start.to_s * ((start % 3) >> (Math.log2((start % 3) + 1).ceil - 1)) * ((start % 5) >> (Math.log2((((start += ((limit + 1) - start)/((limit + 1) - start)) - 1) % 5) + 1).ceil - 1))}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lonelyInteger :: [Int] -> Int | |
lonelyInteger = head . head . dropWhile ((>1) . length) . group . sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CommonCrypto/CommonDigest.h> | |
#import <CommonCrypto/CommonHMAC.h> | |
+ (NSString *)signedUrlFromUrl:(NSString *)fullURL { | |
fullURL = [fullURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSString *unmodifiedKey = [@"Your Google Maps for Work API Key" stringByReplacingOccurrencesOfString:@"-" withString:@"+"]; | |
unmodifiedKey = [unmodifiedKey stringByReplacingOccurrencesOfString:@"_" withString:@"/"]; | |
NSData *keyData = [[NSData alloc] initWithBase64EncodedData:[unmodifiedKey dataUsingEncoding:NSUTF8StringEncoding] options:0]; | |
NSData *urlData = [fullURL dataUsingEncoding:NSUTF8StringEncoding]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (command shift a) | |
if (selection.length() > 0){ | |
for (var i=0; i < selection.length(); i++) { | |
addExportSizes(selection[i]); | |
} | |
[doc showMessage:"Export Options Added"]; | |
} else { | |
var app = [NSApplication sharedApplication]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func scaleAndCropImage(_ image: UIImage, toSize newSize: CGSize) -> UIImage { | |
if image.size.equalTo(newSize) { | |
return image | |
} | |
// Find the ratios of the desired dimensions to the current dimensions, | |
// and use the larger one to scale the image to fill the desired size | |
let widthFactor = newSize.width / image.size.width | |
let heightFactor = newSize.height / image.size.height | |
let scaleFactor = max(widthFactor, heightFactor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'optparse' | |
require 'json' | |
IPA_EXPORT_DIR = 'WFIPAExport' | |
ARCHIVE_DIR = 'WFArchive' | |
XCARCHIVE_NAME = 'WF-iOS.xcarchive' | |
IPA_NAME = 'WF-iOS.ipa' | |
PLIST_NAME = 'WF-iOS.plist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CGSize { | |
func scaled(byFactor factor: CGFloat) -> CGSize { | |
return CGSize(width: width * factor, | |
height: height * factor) | |
} | |
} | |
extension CGSize { | |
func scaled(toSize: CGSize, mode: UIImage.ScaleMode) -> CGSize { | |
let (widthFactor, heightFactor) = (toSize.width / width, toSize.height / height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz(start, limit) loop do puts "#{'fizz' * (((start % 3 / (start % 3 + 1.0)).ceil - 1) * (-1))}#{'buzz' * (((start % 5 / (start % 5 + 1.0)).ceil - 1) * (-1))}#{start.to_s * ((start % 3 / (start % 3 + 1.0)).ceil * ((start % 5) / ((((start += ((limit + 1) - start)/((limit + 1) - start)) - 1) % 5) + 1.0)).ceil)}" end end |
OlderNewer