Skip to content

Instantly share code, notes, and snippets.

View ninjayoto's full-sized avatar

ninjayoto

  • Canada
View GitHub Profile
@ninjayoto
ninjayoto / MainActivity.java
Created June 9, 2016 09:19
Long Clickable ListView
String[] tasks = ddata.getList();
Log.d("The Array", Arrays.toString(tasks));
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_selectable_list_item, tasks));
TextView selection = (TextView) findViewById(R.id.singleTask);
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int pos, long id) {
private AlertDialog showCustomDialog(final Activity act,
CharSequence title,
CharSequence message,
CharSequence buttonYes,
CharSequence buttonNo,
final int selectedIndex) {
AlertDialog.Builder customDialog = new AlertDialog.Builder(act);
customDialog.setTitle(title);
customDialog.setMessage(message);
userAgents=[
/* 0 */"Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/10.10 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30",
/* 1 */"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/31.0.1650.63 Chrome/31.0.1650.63 Safari/537.36",
/* 2 */"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0",
/* 3 */"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36",
/* 4 */"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36",
/* 5 */"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36",
/* 6 */"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36",
/* 7 */"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36",
/* 8 */"Mozilla/5.0 (Windows NT 6.1; WOW64)
@ninjayoto
ninjayoto / introrx.md
Created May 12, 2017 20:46 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@ninjayoto
ninjayoto / install.sh
Created January 8, 2018 18:33 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@ninjayoto
ninjayoto / gist:41200d4f48c65a3418acbfb26e04c4b5
Created February 26, 2018 23:36 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@ninjayoto
ninjayoto / java-exception-handling-best-practices.md
Created March 3, 2018 23:05 — forked from raineorshine/java-exception-handling-best-practices.md
5 Great Resources for Exception Handling Best Practices in Java

General Tip

"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."

Resources

Advantages of Exceptions
Excellent example of separating error-handling code from program logic

Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.

@ninjayoto
ninjayoto / Exceptions.java
Created March 4, 2018 13:17 — forked from rshepherd/Exceptions.java
Introduction to Java exceptions
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Random;
import java.util.Scanner;
public class Exceptions {
// An exception is an event that occurs during the execution of a program
@ninjayoto
ninjayoto / Java8DateTimeExamples.java
Created March 4, 2018 13:38 — forked from mscharhag/Java8DateTimeExamples.java
Examples for using the Java 8 Date and Time API (JSR 310)
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import static java.time.temporal.TemporalAdjusters.*;
public class Java8DateTimeExamples {
@ninjayoto
ninjayoto / build.gradle
Created March 25, 2018 13:47
Fixed to work with grade-2.3
import com.petebevin.markdown.MarkdownProcessor
import org.xhtmlrenderer.pdf.ITextRenderer
import org.ccil.cowan.tagsoup.Parser
import org.apache.xalan.xsltc.trax.SAX2DOM
import org.xml.sax.InputSource
buildscript{
repositories {
mavenCentral()
maven {