Skip to content

Instantly share code, notes, and snippets.

View igor9silva's full-sized avatar
🧑‍🍳
cooking

Igor Silva igor9silva

🧑‍🍳
cooking
View GitHub Profile
const tree = {
"type": "",
"children": [
{
"type": "1",
"children": [
{
"type": "1.1",
"children": [
{ "type": "1.1.1", "children": [] },
@igor9silva
igor9silva / generate-thum.js
Created May 31, 2023 11:11
Generate Thumbnail on S3 upload
// dependencies
const util = require('util');
const sharp = require('sharp');
const AWS = require('aws-sdk');
// get reference to S3 client
const s3 = new AWS.S3();
exports.handler = async (event, context, callback) => {
INFO in lib_getUserMedia() - get(): constraints = {"video":{"facingMode":{"ideal":"user"},"width":{"min":480,"max":1280,"ideal":800},"height":{"min":480,"max":1280,"ideal":600}},"audio":false}
INFO in lib_getUserMedia - get_raw(): videoStream got
INFO in lib_getUserMedia - get_raw(): video.onloadedmetadata dispatched
INFO in lib_getUserMedia - get_raw(): playPromise accepted
WARNING in lib_getUserMedia - get_raw(): Image Capture API not found
INFO in lib_getUserMedia - get_raw(): callbackSuccess called with constraints=
{"facingMode":{"ideal":"user"},"width":{"min":480,"max":1280,"ideal":800},"height":{"min":480,"max":1280,"ideal":600}}
INFO in WebGLCoreLogger: VIDEO GOT! Start PlayerFF
============ INIT ContextFF ============
INFO in ContextFF: webglOptions = {"antialias":true,"alpha":true,"preserveDrawingBuffer":true,"premultipliedAlpha":true,"stencil":false,"depth":true}
@igor9silva
igor9silva / remove_duplicates.swift
Last active February 28, 2018 22:13
Removing duplicates in swift, keeping order
var arr = [1, 1, 1, 2, 2, 3, 4, 5, 6, 6, 6, 6, 6, 7, 8]
var list = ["A","A","A","A","A","A","B","C","D","E","E","E","E"]
let set = Set(arr) // no duplicates but no order either
let orderedSet = NSOrderedSet(array: arr) // no duplicates and ordered, but not an array
let arrayFromOrderedSet = Array(NSOrderedSet(array: arr)) // is array, ordered, no duplicates, but loses type info
let sorted = Array(Set(arr)).sorted() // is array, ordered, no duplicates, keeps type info, but limited to ascending order
extension Array where Element: Equatable {
@igor9silva
igor9silva / ClassDescription.swift
Last active December 20, 2017 17:25
A swift helper function to log data structures. Supports structs, classes, arrays, dictionaries, functions, tuples, enums.
import Foundation
public func classDescription(_ obj: Any,
shouldIncludeType: Bool = false,
indentLevel: Int = 0) -> String {
return classDescription(obj,
shouldIncludeType: shouldIncludeType,
indentLevel: indentLevel,
optionalType: .non)
@igor9silva
igor9silva / recursive_enum.swift
Last active March 14, 2019 21:39
Swift Recursive Enum
import Foundation
public indirect enum Filter: ODataRepresentable {
public enum Operator: String {
case equalTo = "eq"
case notEqualTo = "ne"
case greaterThan = "gt"
case greaterThanOrEqualTo = "ge"