Skip to content

Instantly share code, notes, and snippets.

View lizettepreiss's full-sized avatar

lizettepreiss

View GitHub Profile
@lizettepreiss
lizettepreiss / 1_FacebookMessengerWebhookExample
Last active October 30, 2018 14:19
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.
@lizettepreiss
lizettepreiss / LRUCache.java
Created October 30, 2018 05:04
LRU Cache (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 July 3, 2016 09:32
PHP Associative Arrays
$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 July 3, 2016 09:30
PHP Array Basics 1
<?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] . ".";
@lizettepreiss
lizettepreiss / Client
Created June 15, 2016 09:04
SocketClient
import java.io.*;
import java.net.*;
public class Client {
public static void main(String args[]) {
package preiss;
import java.io.*;
import java.net.*;
public class SocketListener extends Thread {
public static final int PORT_NUMBER = 4241;
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date today = Calendar.getInstance().getTime();
String reportDate = df.format(today);
//------- long to Date -------
The Date constructor (click the link!) accepts the time as long in milliseconds, not seconds.
You need to multiply it by 1000 and make sure that you supply it as long.
Date d = new Date(1220227200L * 1000);
@lizettepreiss
lizettepreiss / worpress_database_queries.sql
Last active January 12, 2018 05:07
Useful Wordpress Database Queries
-- Get All Published Posts
select * from wp_posts where post_status='publish'
-- Given a category name, get all the tags associated with posts in the category
select distinct terms.slug, terms.name
from
wp_term_relationships rel, wp_term_taxonomy txnm, wp_terms terms
where
@lizettepreiss
lizettepreiss / SNMPTrapGenerator.java
Created May 5, 2016 12:44
SNMP Trap Generator. JAR Required: snmp4j.jar at http://www.snmp4j.org/html/download.html
package preiss;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.ScopedPDU;
import org.snmp4j.Snmp;
import org.snmp4j.TransportMapping;
@lizettepreiss
lizettepreiss / SNMPTrapReceiver.java
Created May 5, 2016 12:39
SNMPTrapReceiver. JAR Required: snmp4j.jar at http://www.snmp4j.org/html/download.html
package preiss;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.Vector;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.MessageDispatcherImpl;