Skip to content

Instantly share code, notes, and snippets.

class SparseMatrix:
# Create a sparse matrix of size numRows x numCols initialised to 0
def init(self, numRows, numCols):
self._numRows = numRows
self._numCols = numCols
self._elementList = list()
# Return the number of rows in the matrix
def numRows(self):
return self._numRows
# Return the number of colums in the matrix
import threading
def count_operation():
for i in range(100):
print(threading.current_thread().getName() + '-' + str(i))
# this is sequential execution - operation right after each other
count_operation()
@teguhteja
teguhteja / HierarchyConverter.java
Created April 15, 2020 16:35
General Tree convert Parent-child to Level
import java.io.*;
import java.util.*;
public class HierarchyConverter {
LinkedList<String> output = new LinkedList<>();
int maxlength = 0;
class Node{
String org;
@teguhteja
teguhteja / SimpleCopyApplicationTest.java
Last active March 23, 2020 11:23
Test of SimpleCopyApplication
package com.ttm.testswingmaven;
import org.assertj.swing.aut.getting_started.SimpleCopyApplication;
import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
import org.assertj.swing.edt.GuiActionRunner;
import org.assertj.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@teguhteja
teguhteja / SimpleCopyApplication.java
Last active March 23, 2020 11:24
Example GUI For Test Swing Application
package com.ttm.testswingmaven;
import static javax.swing.SwingUtilities.invokeAndWait;
import static org.assertj.swing.aut.util.swing.ButtonUtil.addActionToButton;
import static org.assertj.swing.aut.util.swing.ButtonUtil.newButton;
import static org.assertj.swing.aut.util.swing.LabelUtil.newLabel;
import static org.assertj.swing.aut.util.swing.TextFieldUtil.newTextField;
import java.lang.reflect.InvocationTargetException;
@teguhteja
teguhteja / NewPanel.java
Created February 6, 2020 06:53
overridden paintComponent(Graphics g) or paint(Graphics g)
/**
*
* @author teguhteja
*/
import java.awt.*;
import javax.swing.*;
// Extend JPanel to override its paintComponent() method:
class NewPanel extends JPanel {
@teguhteja
teguhteja / DemoShape.java
Created February 4, 2020 05:47
Simple draw shape 2D using Java Swing Netbeans
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gui5shape.demo;
import java.awt.Color;
import java.awt.Graphics;
@teguhteja
teguhteja / launch4j.run
Created February 3, 2020 06:05
Configurasi launch4j for dontwrapped
<?xml version="1.0" encoding="UTF-8"?>
<!--Launch4j executor script generated by Launch4jInt module. Do not modify, modifications will be overwritten anyway.-->
<project basedir="." default="all" name="Launch4jExecutor">
<property location="/home/teguhteja/Downloads/launch4j" name="launch4j.dir"/>
<property location="/home/teguhteja/NetBeansProjects/GUILaunch4j01/nbproject/launch4jconfig.xml" name="launch4j.config"/>
<echo>Configuring Launch4j and generating executable for GUILaunch4j01 project:</echo>
<target name="all">
<taskdef classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" name="launch4j"/>
<launch4j>
<config dontWrapJar="false" headerType="gui" jar="<your jar files>"
@teguhteja
teguhteja / EmailUtility.java
Created February 1, 2020 07:34
Servlet for sending enail
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package email;
/**
*
* @author teguhteja
@teguhteja
teguhteja / send_email.jsp
Created February 1, 2020 07:29
Form Send Email in jsp with AJAX JQuery
<%--
Document : send_email
Created on : Jan 31, 2020, 3:34:58 PM
Author : teguhteja
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>