This file contains hidden or 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
M-x set-face-background | |
magit-section-highlight | |
red |
This file contains hidden or 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
# Comile the leaker | |
clang leaker.c -o leaker | |
# Run leaks detecting tool | |
leaks -atExit -- ./leaker | grep LEAK: | |
# Optional | |
cd /usr/local/lib | |
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) { | |
char *p = (char *) malloc(12); | |
p = 0; // the leak is here | |
printf("Hello, leak!\n"); | |
return 0; | |
} |
This file contains hidden or 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
# To `~/.bash_profile`: | |
emacs ~/.bash_profile | |
# Add the line: | |
UNCRUSTIFY_CONFIG="$HOME/.uncrustify" | |
# Generate a new configuration file: | |
uncrustify --update-config -o ~/.uncrustify | |
# Usage |
This file contains hidden or 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 Font { | |
public static let h1: Font = .largeTitle | |
public static let h2: Font = .title | |
public static let h3: Font = .headline | |
public static let h4: Font = .subheadline | |
public static let h5: Font = .body | |
public static let h6: Font = .callout | |
public static let h7: Font = .footnote | |
public static let h8: Font = .caption |
This file contains hidden or 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
// | |
// SceneDelegate.swift | |
// | |
// Created by Rostyslav Druzhchenko on 14.01.2020. | |
// Copyright © 2020 Rostyslav Druzhchenko. All rights reserved. | |
// | |
// Instruction: | |
// | |
// 1. Create a sharable class: | |
// 1. Inherit the class from `ObservableObject`. |
This file contains hidden or 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 Foundation | |
private let kHexHeader = "87654321 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789abcdef\n" | |
private let kLineHeader = "00000000:" | |
private let kLineLength = 16 | |
extension Data { | |
func hexArray() -> String { |
This file contains hidden or 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 String { | |
// MARK: - Substring | |
private func index(from: Int) -> Index { | |
self.index(startIndex, offsetBy: from) | |
} | |
func substring(from: Int) -> String { | |
let fromIndex = index(from: from) |
This file contains hidden or 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 Date { | |
private static let isoDateFormatter: DateFormatter = { | |
let dateFormatter = DateFormatter() | |
dateFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dateFormatter.timeZone = TimeZone(abbreviation: "GMT") | |
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" |
This file contains hidden or 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 Foundation | |
func readVariable(_ name: String) -> String { | |
if let value = ProcessInfo.processInfo.environment[name] { | |
return value | |
} | |
return "" | |
} | |
let homePath = readVariable("HOME") |