Skip to content

Instantly share code, notes, and snippets.

View mjtoolbox's full-sized avatar
🏠
Working from home

Michael Jo mjtoolbox

🏠
Working from home
View GitHub Profile
def reduce_mem_usage(df):
start_mem_usg = df.memory_usage().sum() / 1024**2
print("Memory usage of properties dataframe is :",start_mem_usg," MB")
NAlist = [] # Keeps track of columns that have missing values filled in.
for col in df.columns:
if df[col].dtype != object and df[col].dtype != 'datetime64[ns]': # Exclude strings and dates
# Print current column type
print("******************************")
print("Column: ",col)
@mjtoolbox
mjtoolbox / seven-segment
Created April 21, 2017 14:03
Arduino seven segment control
const int latchPin = 12;//Pin connected to ST_CP of 74HC595
const int clockPin = 8;//Pin connected to SH_CP of 74HC595
const int dataPin = 11; //Pin connected to DS of 74HC595
//display 0,1,2,3,4,5,6,7,8,9,A,b,C,d,E,F
int datArray[16] = {252, 96, 218, 242, 102, 182, 190, 224, 254, 246, 238, 62, 156, 122, 158, 142};
void setup ()
{
//set pins to output
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
@mjtoolbox
mjtoolbox / StudentWCClient.java
Created March 31, 2014 04:50
RestWebServiceTest Client code
package com.mjtoolbox.wsclient;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
@mjtoolbox
mjtoolbox / StudentResource.java
Created March 31, 2014 04:42
RESTful WebService using RestEasy
package com.mjtoolbox.ws;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@mjtoolbox
mjtoolbox / web.xml
Created March 31, 2014 04:30
RestWebServiceTest web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>RestWebServiceTest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
@mjtoolbox
mjtoolbox / pom.xml
Created March 31, 2014 04:11
RestWebServiceTest project pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mjtoolbox.ws.test</groupId>
<artifactId>RestWebServiceTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>RestWebServiceTest</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@mjtoolbox
mjtoolbox / Cygwin0711
Created July 12, 2013 05:51
EC2 Instance Startup Engineering Cygwin output for HW3 preparation
msjo@msjo-PC ~
$ pwd
/home/msjo
msjo@msjo-PC ~
$ ls
demo.txt genome index.html market-research.js out1.txt subset.ptt.00 subset.ptt.03
errs.txt genome.tar locs market-research-wrapper.js out2.txt subset.ptt.01 subset.ptt.04
genes grader.js market-research.csv mjtoolbox-aws-ubuntu-startup-eng.pem out3.txt subset.ptt.02 test.txt
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:shiro="http://xproject.flightCenter/tag">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/flight.css"
@mjtoolbox
mjtoolbox / gist:5538527
Created May 8, 2013 05:57
Simple Servlet using JEE7 JsonObjectBuilder
package mypackage;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonWriter;
@mjtoolbox
mjtoolbox / Tree Traversal
Created January 12, 2013 17:22
Tree Traversal : InOrder, PreOrder, PostOrder using recursion and non-recursion for XProject. Non-recursive PostOrder is not included.
package tree;
public class TreeTraversal
{
/**
* @param args
*/
public static void main(String[] args)
{