Skip to content

Instantly share code, notes, and snippets.

@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@MatiMax
MatiMax / DNSResolve3.swift
Last active October 9, 2021 09:44
This Playground shows how to use Core Foundation's CFHost in *Swift 3* to try to produce an array of Strings containing the host name and all its aliases for a given IP address. Unfortunately, CFHostGetNames() does not supply the aliases of a host, so we're left alone with the gethostbyaddr() C function.
//: # How to retrieve a host name and associated aliases from an IP address using Core Fondation's `CFHost` in Swift 3
import Foundation
import PlaygroundSupport
//: In order to get the callback working we use a simple class to implement the showcase.
class DNSResolve {
//: The IP address may be a Swift `String` thanks to the toll-free bridging to C strings.
let ip: String = "17.172.224.47"
//: We use an optional `CFHost` variable because CFHost neither comes with an initializer nor is conforming to the Nullable protocol.
var host: CFHost?
//: We use this array of `String`s to store the resolved host names.
@Murmurianez
Murmurianez / index.html
Last active July 29, 2021 11:03
Simple CSS + SVG checkbox and radiobox
<style>
.checkbox{
margin: 10px 20px;
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label{
border: 2px solid #FFFFFF;
@MatiMax
MatiMax / DNSResolve.swift
Last active November 14, 2016 05:48
This Swift Playground shows how to use Core Foundation's CFHost in Swift 2 to try to produce an array of Strings containing the host name and all its aliases for a given IP address. Unfortunately, CFHostGetNames() does not supply the aliases of a host, so we're left alone with the gethostbyaddr() C function.
//: # How to retrieve a host name and associated aliases from an IP address using Core Fondation's `CFHost`
import Cocoa
import XCPlayground
//: In order to get the callback working we use a simple class to implement the showcase.
class DNSResolve {
//: The IP address may be a Swift `String` thanks to the toll-free bridging to C strings.
let ip: String = "17.172.224.47"
//: We use an optional `CFHost` variable because CFHost neither comes with an initializer nor is conforming to the Nullable protocol.
var host: CFHost?
//: We use this array of `String`s to store the resolved host names.
@omegahm
omegahm / create_labels.sh
Created April 7, 2015 19:00
Create Gtihub labels from Bash
#!/usr/bin/env bash
# Colours picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
###
# Label definitions
###
declare -A LABELS
# Platform
/*
This is a demonstration of how to implement the Optional type in Swift.
The name 'Maybe' is taken from Haskell, but the two cases 'None' & 'Some'
are the same as Swift's Optional type (Haskell uses 'Nothing' & 'Just').
The Maybe type conforms to NilLiteralConvertible, as does Swift's
Optional type. This allows a Maybe value to be constructed from 'nil'.
One aspect of Swift's Optional type which can't be reproduced is
'implicit Optional wrapping'. Here's an example:
@mlanett
mlanett / rails http status codes
Last active June 14, 2024 06:07
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing