Skip to content

Instantly share code, notes, and snippets.

@stepenik
stepenik / MainActivity.java
Created September 6, 2019 23:16 — forked from enginebai/MainActivity.java
Get the current location and display a marker on Google Map.
package com.enginebai.sample;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
public class NotificationHelper {
private Context mContext;
private NotificationManager mNotificationManager;
private NotificationCompat.Builder mBuilder;
public static final String NOTIFICATION_CHANNEL_ID = "10001";
public NotificationHelper(Context context) {
mContext = context;
@stepenik
stepenik / MovieCountries1.java
Created March 27, 2019 21:43 — forked from I82Much/MovieCountries1.java
itextpdf 5.1.0 header
/*
* This class is part of the book "iText in Action - 2nd Edition"
* written by Bruno Lowagie (ISBN: 9781935182610)
* For more info, go to: http://itextpdf.com/examples/
* This example only works with the AGPL version of iText.
*
* Modified by Nick Dunn (http://developmentality.wordpress.com) to
* focus on just the PDF header aspect.
*/
@stepenik
stepenik / DialogFragmentCallback.md
Created March 13, 2019 19:40 — forked from Joev-/DialogFragmentCallback.md
Getting results from DialogFragment to calling Fragment using Callbacks

##Getting results from DialogFragments to another Fragment.

When setting up the DialogFragment make a call to Fragment.setTargetFragment()
Then from DialogFragment you can access the main fragment with Fragment.getTargetFragment()
Use interfaces to provide the required actions to the calling Fragment.

##Example code.

###AddFriendDialogFragment - Calls back to calling fragment.

@stepenik
stepenik / SharedPreferences Manager
Created March 8, 2019 23:47 — forked from jefriyh/SharedPreferences Manager
This is teh example using SharedPreference manager to manage data on pref
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by Jefri Yushendri on 7/4/2017.
*/
public class SharedPrefManager {
private static final String SHARED_PREF_NAME = "GETCREW";
private static final String TAG_TOKEN = "tagtoken";
Expression Utility Objects
Besides these basic objects, Thymeleaf will offer us a set of utility objects that will help us perform common tasks in our expressions.
#dates: utility methods for java.util.Date objects: formatting, component extraction, etc.
#calendars: analogous to #dates, but for java.util.Calendar objects.
#numbers: utility methods for formatting numeric objects.
#strings: utility methods for String objects: contains, startsWith, prepending/appending, etc.
#objects: utility methods for objects in general.
#bools: utility methods for boolean evaluation.
#arrays: utility methods for arrays.
@stepenik
stepenik / chat_serv.py
Created January 23, 2019 12:08 — forked from schedutron/chat_serv.py
Chat Server Script
#!/usr/bin/env python3
"""Server for multithreaded (asynchronous) chat application."""
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
def accept_incoming_connections():
"""Sets up handling for incoming clients."""
while True:
client, client_address = SERVER.accept()
@stepenik
stepenik / chat_clnt.py
Created January 23, 2019 12:08 — forked from schedutron/chat_clnt.py
GUI client script for my chat app
#!/usr/bin/env python3
"""Script for Tkinter GUI chat client."""
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
import tkinter
def receive():
"""Handles receiving of messages."""
while True:
@stepenik
stepenik / EndlessRecyclerViewScrollListener.java
Created January 15, 2019 09:26 — forked from rogerhu/EndlessRecyclerViewScrollListener.java
Endless RecyclerView scrolling for different layout managers
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;
@stepenik
stepenik / Calculator.java
Created October 30, 2018 22:07 — forked from agrawal-priyank/Calculator.java
Evaluate an Arithmetic expression using Stacks in Java.
import java.util.Stack;
public class Calculator {
public enum Operator{ADD, SUBTRACT, MULTIPLY, DIVIDE, BLANK}
public static void main(String[] args){
String expression = "2-6-7*8/2+5";
Calculator calc = new Calculator();
System.out.println(calc.compute(expression));