Skip to content

Instantly share code, notes, and snippets.

View arwankhoiruddin's full-sized avatar

Arwan Ahmad Khoiruddin arwankhoiruddin

  • Mandatech
  • Yogyakarta, Indonesia
View GitHub Profile
@arwankhoiruddin
arwankhoiruddin / NodeBasedTests.java
Last active December 22, 2018 10:08
Basic structure of graph for testing
import sun.awt.image.ImageWatched;
import java.util.Iterator;
import java.util.LinkedList;
public class NodeBasedTests {
public static void main(String[] args) {
PartA partA = new PartA();
PartB partB = new PartB();
PartC partC = new PartC();
<?php
// this is unsafe way to get JSON from your MySQL... but it is fun... hahaha
$servername = "myhost";
$username = "myusername";
$password = "mypassword";
$dbname = "mydb";
$sql = $_GET['sql'];
#!/usr/bin/python
"""
Create heterogeneous Hadoop cluster
Contains of 4 nodes in two different racks
"""
from mininet.net import Containernet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import info, setLogLevel
@arwankhoiruddin
arwankhoiruddin / GetInfo.java
Last active July 20, 2018 07:09
Get available processor and free memory using Java
import java.util.*;
public class GetInfo {
public static void main(String[] args) {
Properties p = System.getProperties();
// p.list(System.out);
System.out.println("Total CPU: " + Runtime.getRuntime().availableProcessors());
System.out.println("Free memory: " + Runtime.getRuntime().freeMemory());
}
}
@arwankhoiruddin
arwankhoiruddin / sendmail.py
Created June 18, 2018 15:29
Send several mails to certain account - this is useful especially for testing purpose
#!/usr/bin/python
"""
This is a program to send emails to Scram email testing accounts
"""
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
import time
@arwankhoiruddin
arwankhoiruddin / loremIpsumGen.py
Created June 6, 2018 08:10
Before running this, you need to do pip install loremipsum
from loremipsum import get_sentences
import random
sentences_list = get_sentences(500)
flen = 5000000
progress = -1
with open('myfile.txt', 'w') as myfile:
for i in range(flen):
n = round(i/(flen/100))
@arwankhoiruddin
arwankhoiruddin / hadoop_readTasks.py
Last active May 17, 2018 06:04
Python code to read Hadoop jobs and tasks using the provided REST API
import requests
import json
def getJSON(url):
r = requests.get(url)
return json.loads(r.text)
server = 'http://d1:19888'
url = server + '/ws/v1/history/mapreduce/jobs'
# This script use InstagramAPI provided here: https://github.com/LevPasha/Instagram-API-python/tree/master/InstagramAPI
import sys
import os
sys.path.append(os.path.abspath("yourpath/Instagram-API-python/InstagramAPI"))
from InstagramAPI import InstagramAPI
import time
import random
user = 'yourname'
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import java.util.*;
import java.lang.*;
import java.io.*;
class MyClass
{
public static void main (String[] args) throws java.lang.Exception
{
int[] a = {1,2,3};
int[] b = {1,3,5};