Skip to content

Instantly share code, notes, and snippets.

View erloncabral's full-sized avatar

Erlon Cabral erloncabral

View GitHub Profile
@erloncabral
erloncabral / swift-5.0.1-ubuntu-18.04.txt
Created June 16, 2019 19:46
swift-5.0.1-ubuntu-18.04
# additional packages //https://github.com/kylef/swiftenv/issues/137
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev systemtap-sdt-dev tzdata rsync
@erloncabral
erloncabral / swift-4.2-ubuntu-19.04.txt
Created June 16, 2019 15:47
swift-4.2-ubuntu-19.04
# apple guide (linux support)
https://swift.org/download/#using-downloads
# additional link reference
https://tecadmin.net/install-swift-ubuntu-1804-bionic/
# dependency
sudo apt-get install clang libicu-dev
sudo apt-get install libcurl4 libpython2.7 libpython2.7-dev
sudo apt install gcc-aarch64-linux-gnu
@erloncabral
erloncabral / UIImage+WebP.swift
Created November 18, 2018 22:41
UIImage with WebP image data (swift 4.2)
import UIKit
extension UIImage {
convenience init?(webPData: Data) {
var width: Int32 = 0, height: Int32 = 0
if WebPGetInfo([UInt8](webPData), webPData.count, &width, &height) == 0 {
return nil
}
@erloncabral
erloncabral / keys_directions.lua
Created August 1, 2018 12:08
love 2d keyboard directions
local x_input = 0
local y_input = 0
local line_width = 32
function love.update(dt)
x_input = (love.keyboard.isDown("right") and 1 or 0) - (love.keyboard.isDown("left") and 1 or 0)
y_input = (love.keyboard.isDown("down") and 1 or 0) - (love.keyboard.isDown("up") and 1 or 0)
end
function love.draw()
@erloncabral
erloncabral / p-eiget.rb
Last active August 2, 2018 01:20
Download PICO-8 Cartridge to carts folder
#!/usr/bin/env ruby
require 'etc'
require 'open-uri'
require 'optparse'
options = {}
opts = OptionParser.new do |opts|
opts.banner = "usage: p-eiget.rb"
opts.on('-c', '-c # cartridge') do |cart|
/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i location_of/your.mobileprovision)
/usr/libexec/PlistBuddy -c 'Print :Name' /dev/stdin <<< $(security cms -D -i location_of/your.mobileprovision)
NSArray *sample = @[@1, @2, @3, @4, @5];
NSArray *sort = @[@1, @4, @5, @3, @2];
NSMutableOrderedSet *order = [[NSMutableOrderedSet alloc] initWithArray:sample];
NSUInteger insertIndex = 0;
for (NSNumber *ref in sort) {
NSUInteger presentIndex = [order indexOfObject:ref];
if (presentIndex != NSNotFound) {
[order moveObjectsAtIndexes:[NSIndexSet indexSetWithIndex:presentIndex] toIndex:insertIndex];
insertIndex++;