Skip to content

Instantly share code, notes, and snippets.

View marzapower's full-sized avatar
🐂

Daniele Di Bernardo marzapower

🐂
View GitHub Profile
@marzapower
marzapower / example.rb
Created November 30, 2021 20:46 — forked from lyoshenka/example.rb
Example of outputting YAML in Ruby using inline style (array is all on one line, not spread out with each element on its own line)
full_data = {
response: {body: StyledYAML.literal(DATA.read), status: 200},
person: StyledYAML.inline('name' => 'Steve', 'age' => 24),
array: StyledYAML.inline(%w[ apples bananas oranges ])
}
StyledYAML.dump full_data, $stdout
__END__
{
@marzapower
marzapower / count_hand.swift
Last active August 29, 2015 14:04
Swift Ninja Final Challenge
enum Suit {
case Clubs, Diamonds, Hearts, Spades
}
enum Rank {
case Jack, Queen, King, Ace
case Num(Int)
}
struct Card {
@marzapower
marzapower / MPSimpleLog.h
Last active July 17, 2019 08:41
A simple way to make your Xcode console logs more readable. SLog stands for "Short Log", DLog for "Debug Log" and ALog for "Always Log". Automagically, all the NSLog calls will be redirected to the new SLog. SLog just replaces NSLog and removes all the log noise (complete timestamp, app name, memory addresses, etc.). DLog and ALog will also prep…
#define LOG_DEBUG
#define __PREPEND_DATE(format) ([NSString stringWithFormat:@"[%@] %@", [[[NSDate new] description] componentsSeparatedByString:@" "][1], [@"%@" stringByAppendingString:format]])
#define SLog(args,...) do { [[NSFileHandle fileHandleWithStandardOutput] writeData:[[NSString stringWithFormat:__PREPEND_DATE(args), @"", ##__VA_ARGS__] dataUsingEncoding: NSUTF8StringEncoding]]; [[NSFileHandle fileHandleWithStandardOutput] writeData: [@"\n" dataUsingEncoding: NSUTF8StringEncoding]]; } while(0);
#ifdef LOG_DEBUG
#define NSLog SLog
#endif
// ALog always displays output regardless of the DEBUG setting