Skip to content

Instantly share code, notes, and snippets.

Leonardo CavalcanteLeo

Block or report user

Report or block CavalcanteLeo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View compress all videos in a directory.sh
bold=$(tput bold)
normal=$(tput sgr0)
files='*.mp4'
original_dir_size=$(du -sh | awk '{print $1}');
original_dir_size_int=${original_dir_size:0:${#original_dir_size}-1}
for file in $files
@CavalcanteLeo
CavalcanteLeo / RemoteImageManager.h
Created Dec 21, 2017 — forked from exherb/RemoteImageManager.h
DownloadProgressPinRemoteImageManager
View RemoteImageManager.h
#import "PINRemoteImageManager.h"
@interface RemoteImageManager : PINRemoteImageManager
+ (instancetype)sharedImageManager;
typedef void (^PINRemoteImageManagerImagePercentageProgressBlock)(float percent);
- (NSUUID *)downloadImageWithURL:(NSURL *)url
options:(PINRemoteImageManagerDownloadOptions)options
@CavalcanteLeo
CavalcanteLeo / gist:a79e642123664ae928729357caf84ba4
Created Oct 10, 2017 — forked from ichord/gist:9808444
demo of using pdf.js to extract pages to images
View gist:a79e642123664ae928729357caf84ba4
<script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script><html>
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/pdfjs-helloworld-v2/8598/edit
-->
<body>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
<input id='pdf' type='file'/>
<!-- Use latest PDF.js build from Github -->
@CavalcanteLeo
CavalcanteLeo / BDHost.m
Created Sep 6, 2017 — forked from amcgregor/BDHost.m
Useful Objective-C methods, classes, objects, and categories. Basically a snippit collection.
View BDHost.m
// From: http://www.bdunagan.com/2009/11/28/iphone-tip-no-nshost/
// MIT license
// Remember to add CFNetwork.framework to your project using Add=>Existing Frameworks.
#import "BDHost.h"
#import <CFNetwork/CFNetwork.h>
#import <netinet/in.h>
#import <netdb.h>
#import <ifaddrs.h>
View BaseTabBarController.h
//
// BaseTabBarController.h
// WeCareWealthManagement
//
// Created by Leo Cavalcante on 24/07/17.
// Copyright © 2017 Kiddo. All rights reserved.
//
#import <UIKit/UIKit.h>
@CavalcanteLeo
CavalcanteLeo / states-by-countries.js
Created Jul 23, 2017 — forked from a-voronov/states-by-countries.js
Countries and their subdivisions based on ISO 3166-1:2013
View states-by-countries.js
// countries, states and subdivisions were generated relying on next documents:
// http://www.iso.org/iso/country_names_and_code_elements
// http://www.unece.org/cefact/locode/welcome.html
var countriesAndStates = [
{"Country":"AD","State":"Canillo"},
{"Country":"AD","State":"Encamp"},
{"Country":"AD","State":"La Massana"},
{"Country":"AD","State":"Ordino"},
{"Country":"AD","State":"Sant Julià de Lòria"},
@CavalcanteLeo
CavalcanteLeo / latency.markdown
Created Jul 23, 2017 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
View PopcornTorrent PT.BR.xliff
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
<file original="PopcornTorrent/en.lproj/Localizable.strings" source-language="en" target-language="PT-BR" datatype="plaintext">
<header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="8.3" build-num="8E162"/>
</header>
<body>
<trans-unit id="File doesn't exist at path: %@">
<source>File doesn't exist at path: %1$@</source>
<target>Arquivo não existe no diretório: %1$@</target>
@CavalcanteLeo
CavalcanteLeo / FontAwesome.h
Created May 7, 2017 — forked from erkanyildiz/FontAwesome.h
An helper for using Font Awesome iconic font semantically, with image rendering and caching support
View FontAwesome.h
// erkanyildiz
// 20161026-1808+0900
//
// FontAwesome.h
#ifndef FontAwesome_h
#define FontAwesome_h
extern const struct FontAwesome
{
View gist:0382e50e21fae255532ca94a521821cc
if (firstAsset !=nil && secondAsset!=nil) {
[activityView startAnimating];
// 1 - Create AVMutableComposition object. This object will hold your AVMutableCompositionTrack instances.
AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];
// 2 - Video track
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration)
ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration)
You can’t perform that action at this time.