Skip to content

Instantly share code, notes, and snippets.

View jplazcano87's full-sized avatar
💭
Learning

Juan Pablo Lazcano jplazcano87

💭
Learning
  • Santiago, Chile
View GitHub Profile
@jplazcano87
jplazcano87 / test.playground
Created February 11, 2016 14:01
Ternanry operator in swift 2
var a:Int?
let b = 2
var output:Int?
//a is nil here
output = a ?? b
print("Value of Output is \(output!)")
//a is assigned value of b
@jplazcano87
jplazcano87 / SendMail.swift
Last active March 9, 2016 13:37
Send mail using swift
//
// SendMail.swift
// SendEmail with attachment
//
// Created by Spaceghost on 3/09/16.
// Copyright (c) 2016 Spaceghost. All rights reserved.
//
import UIKit
import MessageUI
import UIKit
import XCPlayground
class ViewController: UIViewController {
func action() { print("Bing!") }
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .whiteColor()
@jplazcano87
jplazcano87 / httpserver.py
Created August 24, 2016 18:06
SimpleHttpServer with ip and port
import sys
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
def test(HandlerClass=SimpleHTTPRequestHandler,
ServerClass=BaseHTTPServer.HTTPServer):
protocol = "HTTP/1.0"
host = ''
@jplazcano87
jplazcano87 / gist:db55f8bc41ee7f50d229663f4dc0b5a0
Created August 25, 2016 15:00 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@jplazcano87
jplazcano87 / AppHelper.java
Created September 5, 2016 14:29 — forked from anggadarkprince/AppHelper.java
Upload file with Multipart Request Volley Android
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import java.io.ByteArrayOutputStream;
/**
* Sketch Project Studio
* Created by Angga on 12/04/2016 14.27.
*/
public class AppHelper {
@jplazcano87
jplazcano87 / validator.swift
Last active January 16, 2023 23:44
Rut validator chile
import Foundation
enum RutError: ErrorType{
case InvalidRut(message : String)
}
class FormValidator: NSObject {
static func validateRut(value : String) throws ->String {
//clean rut
@jplazcano87
jplazcano87 / EmptyRecyclerView.java
Created September 13, 2016 19:29 — forked from meoyawn/EmptyRecyclerView.java
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;
@jplazcano87
jplazcano87 / AsyncTaskTests.java
Created October 23, 2016 15:44 — forked from he9lin/AsyncTaskTests.java
How to test AsyncTask in Android
package jieqoo.android.KASS.test.tasks;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import jieqoo.android.models.RESTListener;
import jieqoo.android.models.RESTResponse;
import jieqoo.android.tasks.FetchRESTResponseTask;
import jieqoo.android.util.Configuration;
import android.test.InstrumentationTestCase;
@jplazcano87
jplazcano87 / TimestampUtils.java
Created December 26, 2016 20:45 — forked from kristopherjohnson/TimestampUtils.java
Methods for generating ISO 8601 timestamps in Java/Android
package net.kristopherjohnson.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* Methods for dealing with timestamps