Skip to content

Instantly share code, notes, and snippets.

View Shosta's full-sized avatar
🧗
Furiously hacking

Rémi Lavedrine Shosta

🧗
Furiously hacking
View GitHub Profile
@Shosta
Shosta / DownloadAsyncUsingBlock.objc
Created November 23, 2017 23:39
Download Asynchronously using block objects - Objective-C
@implementation ViewController
- (void)loadDataAsync{
// Download the Objects from a JSON file on the server
Downloader *dl = [[Downloader alloc] init];
[dl downloadObjects:self.aID andCompletionHandler:^(NSArray *objectsArray){
// Set the data to your model for instance
// self.mArray = objectsArray;
// Perform refresh on main thread.
@Shosta
Shosta / nsurlsession.objc
Created November 2, 2017 14:58
NSURLSession use in Objective-C with Delegate or with Blocks
- (void)downloadSomethingWithoutDelegate{
NSURL *url = [NSURL URLWithString:@"https://vignette.wikia.nocookie.net/vsbattles/images/4/4a/Askeladd.jpg"];
NSURLSessionDownloadTask *downloadTask = [[NSURLSession sharedSession] downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
// 4
downloadedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:location]];
}];
//3
//[downloadTask resume];

Keybase proof

I hereby claim:

  • I am shosta on github.
  • I am shostarsson (https://keybase.io/shostarsson) on keybase.
  • I have a public key ASDZ8qtcleJudG0HPLi_VwpDoo970mX_V3ZtsNT8H0Sabgo

To claim this, I am signing this object:

@Shosta
Shosta / idb_install.sh
Last active March 10, 2023 16:21
Kali Linux: idb Install script: idb_install.sh
apt-get install cmake libqt4-dev git-core libimobiledevice-utils libplist-utils usbmuxd -y
curl -sSL https://get.rvm.io | bash -s stable --ruby
source /usr/local/rvm/scripts/rvm
rvm use 2.1
mkdir ~/iOS && cd ~/iOS
git clone --recursive https://github.com/dmayer/idb.git
cd idb
bundle install
echo "Type 'ruby gidb.rb' to use idb's graphical user interface"
@Shosta
Shosta / ControlExtensions.cs
Created July 29, 2014 08:59
Dismiss Keyboard from a Control in Windows Phone 8.1 - ClassExtensions
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml.Controls;
namespace OTV.UI.Controls
{
/// <summary>
/// A Class Extensions that allows to dismiss the Keyboard from a Control.
/// Include the "OTV.UI.Controls" namespace in your class and then call the "LoseFocus" method :
@Shosta
Shosta / NSString+EmailValidating.h
Created October 4, 2013 07:53
NSString category to test if a string is a valid e-mail address.
//
// NSString+EmailValidating.h
//
//
// Created by Rems on 11/12/12.
// Copyright (c) 2012 . All rights reserved.
//
#import <Foundation/Foundation.h>
@Shosta
Shosta / gist:6608899
Created September 18, 2013 13:07
Code to add on viewDidLoad to handle the new Window and View management from iOS6 to iOS7 for your TableView.
#pragma mark - View
#define STATUS_BAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height
#define NAVIGATION_BAR_HEIGHT self.navigationController.navigationBar.bounds.size.height
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.edgesForExtendedLayout = UIRectEdgeTop;
@Shosta
Shosta / UIView+Rotation.h
Last active December 20, 2015 18:18
Allow the developer to rotate View during a predefined time or start an infinite rotation and stop it.
//--------------------------------------------------------
//
//--------------------------------------------------------
// Project :
// File : UIView+Rotation.h
// Created : $ 23/05/12 $
// Maintainer : $ Rémi LAVEDRINE $
//
// Copyright Rémi LAVEDRINE 2004-2012, All Rights Reserved
//
@Shosta
Shosta / UIDevice-Hardware.h
Last active December 20, 2015 18:18
Allow the developer to know on which harware the program runs (iPhone4, iPhone4S, iPhone5, etc...).
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 5.0 Edition
BSD License, Use at your own risk
*/
#import <UIKit/UIKit.h>
#define IFPGA_NAMESTRING @"iFPGA"
@Shosta
Shosta / UILabel+Size.h
Last active December 20, 2015 18:19
Calculate a Label Size from its content and its position. It is useful when you want to adapt a UILabel size according to its x;y origin, its width and its content. It can then adapt a cell's height from a dynamic content.
//--------------------------------------------------------
//
//--------------------------------------------------------
// Project :
// File : UILabel+Size.h
// Created : $ 04/05/12 $
// Maintainer : $ Rémi LAVEDRINE $
//
// Copyright Rémi LAVEDRINE 2004-2012, All Rights Reserved
//