Skip to content

Instantly share code, notes, and snippets.

View kennylugo's full-sized avatar
🎯
Focusing

Kenny Lugo kennylugo

🎯
Focusing
View GitHub Profile
<!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>
@kennylugo
kennylugo / gist:f6fc6f7faabc3d7b9e6fa88b605d0797
Created January 20, 2018 19:05
Request for a review inside the app. Swift
import StoreKit
if #available( iOS 10.3,*){
SKStoreReviewController.requestReview()
}
//Shadows
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.7
view.layer.shadowOffset = CGSize.zero
view.layer.shadowRadius = 5
#!flask/bin/python
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask Bob!'
men = [
@kennylugo
kennylugo / gist:35bcff85c5da39ec9e60c89296005dc9
Created December 14, 2016 18:31
Javascript crawler, aka scraper
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();
@kennylugo
kennylugo / ViewController.swift
Created March 1, 2016 16:04
Tap Gesture : give random color to view on tap
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)
@kennylugo
kennylugo / tableViewController.swift
Last active March 2, 2016 23:13
Photo Library & Camera
//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()
@kennylugo
kennylugo / gist:4388fa16b37d845ced16
Created February 21, 2016 21:10
Swipe Cells for More Actions( buttons )
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)
}
@kennylugo
kennylugo / TableViewController.swift
Created February 21, 2016 17:39
Closures with UIAlertController: Handlers
//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
@kennylugo
kennylugo / tableViewController.swift
Created February 20, 2016 18:02
TableCellSelection & UIAlertController
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