Skip to content

Instantly share code, notes, and snippets.

View alejandro-isaza's full-sized avatar

Alejandro Isaza alejandro-isaza

View GitHub Profile
@alejandro-isaza
alejandro-isaza / set_slack_status.rb
Last active July 6, 2018 23:17
Change your slack status from the command line with custom presets.
#!/usr/bin/env ruby
#
# Instructions:
# 1. Get personal Slack legacy tokens from https://api.slack.com/custom-integrations/legacy-tokens
# 2. Save this in ~/bin/ss and add $HOME/bin to your PATH so that you can invoke it easily.
# 3. Add custom status presets below.
# 4. Run `ss lunch` to test
require 'net/http'
require 'json'
@alejandro-isaza
alejandro-isaza / BinarySearch.swift
Last active December 29, 2015 00:18
Binary search in Swift
public extension CollectionType where Index == Int, Generator.Element: Comparable {
/// Perform a binary search for an element.
///
/// - precondition: The elements in the collection are sorted.
/// - complexity: O(log₂(n))
///
/// - returns: The index of the element or `nil` if the element was not found.
public func binarySearch(element: Generator.Element) -> Index? {
var low = startIndex
var high = endIndex
@alejandro-isaza
alejandro-isaza / PrintToFile.py
Created July 10, 2015 18:33
lldb command to print an array to a file in disk
#!/usr/bin/python
import lldb
import os
import re
import subprocess
import fblldbbase as fb
def lldbcommands():
return [ PrintToFile() ]
@alejandro-isaza
alejandro-isaza / abstract.md
Last active May 4, 2017 03:06
Introduction to Modern C++ Workshop

Abstract

C++ has a reputation of being an experts-only low-level programming language. But this is not the case anymore. C++11 and 14 introduce smart pointers, multi-threading, lambdas, move semantics, scoped enums, const expressions, user-defined literals, and a lot of other new features. The C++ standards committee is shortening the release cycle and modernizing the language.

This workshop is an introduction to new features and best practices of modern C++. We will delve into the core of C++ and all new features introduced in C++11 and C++14. There are two specific aims: to introduce you to C++ with emphasis on modern features and to help you make well-informed decisions when writing C++ code.

On completion of this workshop you should be able to:

  • Write C++ code using the latest language features while following the best practices
  • Identify modern C++ features and techniques
  • Use third-party libraries and frameworks
@alejandro-isaza
alejandro-isaza / gist:3f29c6da342f639b9232
Created February 25, 2015 18:47
Code to generate a table of character widths for a particular font. Note that this does not account for things like kerning. Use the generated table to get a good estimate of a string size without having to invoke UIKit.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
UIFont* font = [UIFont fontWithName:@"Baskerville-BoldItalic" size:26];
NSString* latinString = @"W";
CGSize latinSize = [latinString sizeWithFont:font];
NSString* kanjiString = @"儸";
CGSize kanjiSize = [kanjiString sizeWithFont:font];
@alejandro-isaza
alejandro-isaza / String+Parsing.swift
Last active February 24, 2018 18:10
Swift Character and String extensions for parsing.
import Foundation
public extension Character {
/// Determine if the character is a space, tab or newline
public func isSpace() -> Bool {
return self == " " || self == "\t" || self == "\n" || self == "\r"
}
/// Conver the character to a UTF16 code unit
public var utf16: UInt16 {

Keybase proof

I hereby claim:

  • I am alejandro-isaza on github.
  • I am alejandroisaza (https://keybase.io/alejandroisaza) on keybase.
  • I have a public key ASCM3gI4LvapxCFM9qGiEjTrwHZX56TreIXlOjxU7E3kHAo

To claim this, I am signing this object:

@alejandro-isaza
alejandro-isaza / grid.txt
Last active April 5, 2024 14:34
Various grids drawn with Unicode box-drawing characters
Simple
┌───┬───┬───┐
│ │ │ │
├───┼───┼───┤
│ │ │ │
├───┼───┼───┤
│ │ │ │
└───┴───┴───┘
Thick
@alejandro-isaza
alejandro-isaza / gist:7681796
Last active December 29, 2015 14:09
Useful unicode characters I wish my keyboard had
Greek:
Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω
α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω
Superscript:
x⁰ x¹ x² x³ x⁴ x⁵ x⁶ x⁷ x⁸ x⁹ x⁺ x⁻ x⁼ xⁱ xⁿ
Subscript:
x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₊ x₋ x₌
xₐ xₑ xₒ xₓ xₔ
@alejandro-isaza
alejandro-isaza / gist:7550829
Created November 19, 2013 19:13
Convert a HttpURLConnection to a cURL command
public static String toCurlRequest(HttpURLConnection connection, byte[] body) {
StringBuilder builder = new StringBuilder("curl -v ");
// Method
builder.append("-X ").append(connection.getRequestMethod()).append(" \\\n ");
// Headers
for (Entry<String, List<String>> entry : connection.getRequestProperties().entrySet()) {
builder.append("-H \"").append(entry.getKey()).append(":");
for (String value : entry.getValue())