Skip to content

Instantly share code, notes, and snippets.

View andreortiz82's full-sized avatar
🎯
Focusing

Andre Ortiz andreortiz82

🎯
Focusing
View GitHub Profile
@andreortiz82
andreortiz82 / UIImage+FixOrient.m
Created September 27, 2011 22:54 — forked from densa/UIImage+FixOrient.m
UIImage fix orientation
- (UIImage *)fixOrientation {
// No-op if the orientation is already correct
if (self.imageOrientation == UIImageOrientationUp) return self;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform transform = CGAffineTransformIdentity;
switch (self.imageOrientation) {
@andreortiz82
andreortiz82 / RandomizerScript.rb
Last active October 4, 2015 06:08
Generate random values from arrays
def chunky
cap_letters = ('A'..'Z')
low_letters = ('a'..'z')
nums = (0..9)
soup = Array.new
result = Array.new
cap_letters.each do |part|
soup << part
@andreortiz82
andreortiz82 / encode string value
Created May 12, 2012 20:00
encode / decode html text
-(NSString*) encodeString:(NSString *)value {
NSString *rawText = value;
NSString *encodedText = [rawText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Encoded text: %@", encodedText);
NSString *decodedText = [encodedText stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Original text: %@", decodedText);
return encodedText;
}
@andreortiz82
andreortiz82 / callback block method
Created June 14, 2012 19:17
Callback block method with success:fail params
/*
=====================================================
GetPlayer:Dribbble
=====================================================
*/
- (void)getPlayer:(NSString*)playername success:(void (^)(NSMutableDictionary *deals))success failure:(void (^)(NSError *error))failure
{
NSLog(@"Dribbble test");
NSURL *url = [NSURL URLWithString:@"http://api.dribbble.com/players/"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
@andreortiz82
andreortiz82 / AFNetworkingProgressBar
Last active October 6, 2015 04:17
AFNetworking ProgressBar
[operation setUploadProgressBlock:^(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
float prog = (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100);
[self.progBar setProgress:prog];
NSLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
}];
@andreortiz82
andreortiz82 / dispatch_async
Created October 15, 2012 07:03
dispatch_async script ios
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:
kLatestKivaLoansURL];
[self performSelectorOnMainThread:@selector(fetchedData:)
withObject:data waitUntilDone:YES];
});
;; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; An Introduction to ClojureScript for Light Table users
;; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Basics
;; ============================================================================
;; To begin, open the command pane (type Control-SPACE), Add Connection, select
;; Light Table UI. Once connected you can evaluate all the forms in this file
@andreortiz82
andreortiz82 / get_horns.rb
Created September 18, 2014 16:17
Download horn samples from NYB website
require 'open-uri'
86.times do |sample|
begin
open("nyb_#{sample}.mp3", 'wb') do |file|
file << open("http://www.newyorkbrass.com/samples/samples/nyb_#{sample}.mp3").read
puts "nyb_#{sample}.mp3 - saved"
end
rescue Exception => ex
puts "Error: #{ex}"
%a.button{:href => "#"} Basic Action Button
%a.button.success{:href => "#"} Form Submission Button
%a.button.secondary{:href => "#"} Secondary Action Button
%a.button.alert{:href => "#"} Drastic Action Button
task :deploy do
require "aws-sdk"
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
})
s3 = Aws::S3::Resource.new
bucket = s3.bucket(ENV['AWS_BUCKET'])