Skip to content

Instantly share code, notes, and snippets.

View honood's full-sized avatar
👋

HoNooD honood

👋
View GitHub Profile
@honood
honood / Quirks of C.md
Created November 21, 2022 17:08 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@honood
honood / static_inline_example.md
Created September 23, 2022 03:48 — forked from htfy96/static_inline_example.md
static inline vs inline vs static in C++

In this article we compared different behavior of static, inline and static inline free functions in compiled binary. All the following test was done under g++ 7.1.1 on Linux amd64, ELF64.

Test sources

header.hpp

#pragma once

inline int only_inline() { return 42; }
static int only_static() { return 42; }
@honood
honood / Bash.swift
Created August 19, 2021 13:24 — forked from andreacipriani/Bash.swift
Execute shell/bash commands from Swift
import UIKit
protocol CommandExecuting {
func run(commandName: String, arguments: [String]) throws -> String
}
enum BashError: Error {
case commandNotFound(name: String)
}
@honood
honood / JAZMusician.h
Created February 12, 2021 18:27 — forked from jpsim/JAZMusician.h
SourceKit Playground
//
// JAZMusician.h
// JazzyApp
//
#import <Foundation/Foundation.h>
/**
JAZMusician models, you guessed it... Jazz Musicians!
From Ellington to Marsalis, this class has you covered.
@honood
honood / tap.swift
Created October 31, 2020 14:37 — forked from jonah-williams/tap.swift
Implementing a Ruby `tap` equivalent in Swift
// I wanted an equivalent to Ruby's `tap` (http://ruby-doc.org/core-2.3.0/Object.html#method-i-tap) in Swift which I could mix into any type to tap into method chains.
// Define the interface we want to provide as a protocol
private protocol Tap {
func tap(block: (Self) -> Void) -> Self
}
// Extend the `Tap` protocol with a default implementation
private extension Tap {
func tap(block: (Self) -> Void) -> Self {
@honood
honood / yardoc_cheatsheet.md
Created December 20, 2019 13:36 — forked from chetan/yardoc_cheatsheet.md
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@honood
honood / yardoc_cheatsheet.md
Created December 20, 2019 13:36 — forked from chetan/yardoc_cheatsheet.md
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@honood
honood / staticlibobjcabichecker.rb
Created September 20, 2019 12:17 — forked from dynamicdispatch/staticlibobjcabichecker.rb
Simple ruby script to check that Objective-C static libraries are built with the latest ObjC ABI
#!/usr/bin/env ruby
require 'optparse'
require 'pathname'
require 'open3'
# This tool checks an input path for all static libraries *.a files
# and makes sure they were built with the most modern ObjC ABI version.
# Parse command line options.
@honood
honood / 01-truthy-and-falsey-ruby.md
Created May 9, 2019 07:39 — forked from jfarmer/01-truthy-and-falsey-ruby.md
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update

@honood
honood / remove-python27-osx-via-pythonorg-installer-dmg.md
Created April 20, 2019 13:33 — forked from sr75/remove-python27-osx-via-pythonorg-installer-dmg.md
remove python 2.7 on mac osx if installed via python.org installer .dmg
# sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
cd /usr/local/bin && \
sudo ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | xargs rm