Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Kenny Batista kennybatista

🎯
Focusing
Block or report user

Report or block kennybatista

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
@kennybatista
kennybatista / gist:f6fc6f7faabc3d7b9e6fa88b605d0797
Created Jan 20, 2018
Request for a review inside the app. Swift
View gist:f6fc6f7faabc3d7b9e6fa88b605d0797
import StoreKit
if #available( iOS 10.3,*){
SKStoreReviewController.requestReview()
}
View shadows.swift
//Shadows
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.7
view.layer.shadowOffset = CGSize.zero
view.layer.shadowRadius = 5
View JS Open weather API call
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
</head>
<body>
<input class="city" type="text"></input>
<button class="submit">Submit</button>
View gist:e64a6dd7916b9e05725ceafdc1fe9d9f
#!flask/bin/python
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask Bob!'
men = [
View gist:35bcff85c5da39ec9e60c89296005dc9
var request = require('request');
var cheerio = require('cheerio');
request('http://www.factmonster.com/countries.html', function(error, response, html){
if(!error && response.statusCode == 200){
var $ = cheerio.load(html);
$('td').each(function(i, element){
// var a = $(this).prev();
var title = $("tr td a").text();
View tableViewController.swift
//DON'T FORGET TO ADD TWO CLASSES: UIIMAGEPICKERCONTROLLERDELEGATE, UINAVIGATIONCONTROLLERDELEGATE
//didSelectRowAtIndexPath: allows us to select cell from a tableView
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//indexPath.row : allows us to select cells, in our case we're selecting the first cell
if indexPath.row == 0 {
//If the photo library is available
if UIImagePickerController.isSourceTypeAvailable(.PhotoLibrary) {
//instance of the controller, allows us to use it's methods
let imagePicker = UIImagePickerController()
@kennybatista
kennybatista / ViewController.swift
Created Mar 1, 2016
Tap Gesture : give random color to view on tap
View ViewController.swift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var tapGesture = UITapGestureRecognizer(target: self, action: "tap:")
self.view.addGestureRecognizer(tapGesture)
@kennybatista
kennybatista / gist:4388fa16b37d845ced16
Created Feb 21, 2016
Swipe Cells for More Actions( buttons )
View gist:4388fa16b37d845ced16
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let shareAction = UITableViewRowAction(style: .Default, title: "SHARE") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let shareMenu = UIAlertController(title: nil, message: "Share using one of the below", preferredStyle: .ActionSheet)
shareMenu.addAction(UIAlertAction(title: "FaceBook", style: .Default, handler: nil))
shareMenu.addAction(UIAlertAction(title: "Twitter", style: .Default, handler: nil))
shareMenu.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(shareMenu, animated: true, completion: nil)
}
@kennybatista
kennybatista / TableViewController.swift
Created Feb 21, 2016
Closures with UIAlertController: Handlers
View TableViewController.swift
//When we select a cell, we want to bring up an alert
// We use the didSelectRowAtIndexPath method from UITableViewDelegate
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//CREATE MENU
let optionMenu = UIAlertController(title: "Select One", message: "Press one", preferredStyle: .Alert)
//MARK: Handler
@kennybatista
kennybatista / tableViewController.swift
Created Feb 20, 2016
TableCellSelection & UIAlertController
View tableViewController.swift
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//create option menu
let optionMenu = UIAlertController(title: "Option Menu", message: "Select one", preferredStyle: .ActionSheet)
//create action
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)
//add action to menu
You can’t perform that action at this time.