Skip to content

Instantly share code, notes, and snippets.

View tiagobbraga's full-sized avatar

Tiago Braga tiagobbraga

View GitHub Profile
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
@ekoneil
ekoneil / gist:6813974
Last active December 24, 2015 14:39
[Facebook iOS SDK example] Publish an Open Graph (OG) story that: 1/ uses image staging 2/ creates a custom, user-owned OG object 3/ creates a custom OG action
UIImage* image = [UIImage imageNamed:@"inspiration-2.jpg"]; // image stored in app's resources
// stage an image
[FBRequestConnection startForUploadStagingResourceWithImage:image
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(error) {
NSLog(@"Error staging resource.\n%@", error);
int code = [[[[[error userInfo] objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:@"body"] objectForKey:@"error"] objectForKey:@"code"];
if(code == 2500) {
@lucasmezencio
lucasmezencio / gist:7013188
Created October 16, 2013 19:16
Mongo Export
mongoexport --collection collection --db db --csv --out collection.csv --fields field1,field2,field3
@Godoy
Godoy / Steps.md
Last active June 20, 2017 21:38
deploy ruby on rails 4 with capistrano nginx unicorn - ubuntu 14.04

Steps

These steps were made with Ubuntu 14.04 e ruby 2.3.1. To enjoy the ease of step-by-step, I suggest not change folders and application name - just change the server ip and git

Create user to deploy

# Server console
sudo adduser deployer
sudo gpasswd -a deployer sudo
@ShadoFlameX
ShadoFlameX / custom_callouts.md
Last active May 20, 2018 14:14
Custom Map Annotation Callouts on iOS
  1. Create a UIView subclass for the pin callout view.
  2. Create a subclass of MKAnnotationView for your map pins.
  3. Add an instance of the callout view subclass to your MKAnnotationView subclass.
  4. Add a property to toggle the callout view to your MKAnnotationView subclass. This example fades in/out:
    - (void)setShowCustomCallout:(BOOL)showCustomCallout
    {
        [self setShowCustomCallout:showCustomCallout animated:NO];
    }
    
@Toxicable
Toxicable / file-upload.component.ts
Created October 23, 2016 07:18
How to upload files in angular 2
/**
* Created by Fabian on 19/10/2016.
*/
import { Component, ElementRef, Input } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'file-upload',
template: '<input type="file" [attr.multiple]="multiple ? true : null" (change)="upload()" >'
})
export class FileUploadComponent {
@khorbushko
khorbushko / PHPhotoLibrary+SaveImage
Created December 29, 2016 09:27
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
func save() {
@bleft
bleft / UIButton+Extension.swift
Last active March 12, 2021 19:04
UIButton with centered Image and Text
// with the help of: https://gist.github.com/phpmaple/9458264
extension UIButton {
func centerImageAndButton(_ gap: CGFloat, imageOnTop: Bool) {
guard let imageView = self.imageView,
let titleLabel = self.titleLabel else { return }
let sign: CGFloat = imageOnTop ? 1 : -1;
let imageSize = imageView.frame.size;
@TakashiSasaki
TakashiSasaki / gist:4282903
Created December 14, 2012 05:32
HTML5 StorageEvent does not fire "storage" event in the window that changes the state of the local storage. This sample shows how to fire self-"storage" event.
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
"use strict";
@qmchenry
qmchenry / QButton.swift
Last active November 23, 2021 18:18
Swift UIButton subclass that implements toggle and backgroundColor for states
import UIKit
class QButton: UIButton {
var isToggle: Bool = false {
didSet {
if isToggle {
self.addTarget(self, action: Selector("touchUpInside:"), forControlEvents: .TouchUpInside)
} else {
self.removeTarget(self, action: Selector("touchUpInside:"), forControlEvents: .TouchUpInside)
}