Skip to content

Instantly share code, notes, and snippets.

lizettepreiss

Block or report user

Report or block lizettepreiss

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
@lizettepreiss
lizettepreiss / DateToLocalDate.java
Created Dec 6, 2018
Java 8 – Convert java.util.Date to java.time.LocalDate
View DateToLocalDate.java
java.util.Date d = new java.util.Date();
java.time.LocalDate localDate = d.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
@lizettepreiss
lizettepreiss / MultilineStringSplitUsingRegex.java
Last active Dec 5, 2018
Using a Pattern to compile a regex for use instead of String.split()
View MultilineStringSplitUsingRegex.java
import java.util.regex.Pattern;
public class MultilineStringSplitUsingRegex {
private static final Pattern pattern = Pattern.compile("\\r?\\n");
public static void main(String[] args) {
MultilineStringSplitUsingRegex m = new MultilineStringSplitUsingRegex();
String[] s1 = m.splitWithPattern();
String[] s2 = m.splitWithStringSplit();
}
@lizettepreiss
lizettepreiss / JSONParser.java
Last active Oct 30, 2018
Java JSON Parser: Recursively parse any JSON and print the output.
View JSONParser.java
package preiss;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class JSONParser {
public static void main(String[] args) {
View HTTPServer.java
package preiss;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@lizettepreiss
lizettepreiss / 1. Inheritance Demo
Last active Oct 30, 2018
Java Inheritance Demo. Which parent's methods in a hierarchy of inheritance get called.
View 1. Inheritance Demo
See Child.java, Parent.java, GrandParent.java, GreatGrandParent.java, InheritanceDemo.java
@lizettepreiss
lizettepreiss / CollectionsTest.java
Created Oct 30, 2018
Demo of java Collections.binarySearch(..)
View CollectionsTest.java
package preiss.collectionsBinarySort;
// Java program to demonstrate working of Collections.
// binarySearch()
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class CollectionsTest {
public static void main(String[] args)
@lizettepreiss
lizettepreiss / 1_FacebookMessengerWebhookExample
Last active Oct 30, 2018
FacebookMessengerWebhookExample. Note that it is a requirement to have an SSL certificate for the webhook. For dev, I did not have a certificate, nor a public IP. I got around that by registering an account at NGROK and letting NGROK handle the SSL aspect for me. Note that you need to recreate your access tokens each time you restart NGROK as th…
We couldn’t find that file to show.
View LRUCache.java
package preiss.lru;
import java.util.LinkedHashMap;
import java.util.Collection;
import java.util.Map;
import java.util.ArrayList;
/**
* An LRU cache, based on <code>LinkedHashMap</code>.
*
@lizettepreiss
lizettepreiss / phparray2.php
Created Jul 3, 2016
PHP Associative Arrays
View phparray2.php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
//or
$age['Peter'] = "35";
$age['Ben'] = "37";
$age['Joe'] = "43";
echo "Peter is " . $age['Peter'] . " years old.";
@lizettepreiss
lizettepreiss / phparray1.php
Last active Jul 3, 2016
PHP Array Basics 1
View phparray1.php
<?php
//Assign automatically
$cars = array("Volvo", "BMW", "Toyota");
//or assign manually
$cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
You can’t perform that action at this time.