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
path_keyword_researcher = 'agents/keyword_researcher'
def read_string(path):
with open(path, 'r') as file:
content = file.read()
return content
backstory = read_string(f'{path_keyword_researcher}/backstory.txt')
task_description = read_string(f'{path_keyword_researcher}/task_description.txt')
task_output = read_string(f'{path_keyword_researcher}/task_output.txt')
keyword_researcher = Agent(
role='Keyword Researcher',
goal='Identify relevant keywords for {topic}',
verbose=True,
backstory=(
"Specializing in content analysis and keyword research, you utilize"
" advanced tools and techniques to discover essential keywords that"
" boost search engine rankings and topic relevancy."
),
tools=[search_tool],
@arwankhoiruddin
arwankhoiruddin / classification_synth_generator.py
Last active October 25, 2022 02:37
Generate synthetic data for classification using sklearn
from sklearn.datasets import make_classification
import pandas as pd
num_column = 100
num_rows = 10
X, Y = make_classification(n_features=num_column, n_redundant=0, n_informative=5, n_classes=3, n_clusters_per_class=1, n_samples=num_rows)
cols = []
for i in range(0, num_column):
cols.append(f'{i}')
@arwankhoiruddin
arwankhoiruddin / compress_text.py
Created August 6, 2022 09:37
This code is from https://stackoverflow.com/questions/29243119/how-to-compress-or-compact-a-string-in-python, modified based on the comment to encode and decode string, not byte
import sys
import zlib
text="""This function is the primary interface to this module along with
decompress() function. This function returns byte object by compressing the data
given to it as parameter. The function has another parameter called level which
controls the extent of compression. It an integer between 0 to 9. Lowest value 0
stands for no compression and 9 stands for best compression. Higher the level of
compression, greater the length of compressed byte object."""
@arwankhoiruddin
arwankhoiruddin / GameCore.java
Created March 13, 2020 01:50
An example of my flappy balloon JavaFX Project
package core;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import libs.Configs;
import libs.CoreFunc;
import libs.GameText;
import java.util.ArrayList;
@arwankhoiruddin
arwankhoiruddin / CaptureSikuli.java
Created July 30, 2019 16:44
Screen capture image using Sikuli and Robot
import java.awt.image.BufferedImage;
import java.io.File;
import org.sikuli.script.Screen;
import org.sikuli.script.ScreenImage;
import javax.imageio.ImageIO;
public class CaptureSikuli {
public static void main(String[] args) throws Exception {
@arwankhoiruddin
arwankhoiruddin / GenRandom.java
Created July 20, 2019 00:33
Generate some unique random integers
public class GenRandom {
public Integer[] generateDifferentRandomNums(int numRandom, int integerLimit) {
int[] num = new int[numRandom];
Set<Integer> nums = new HashSet<>();
while (nums.size() < numRandom) {
nums.add(new Random().nextInt(integerLimit));
}
return Arrays.asList(nums.toArray()).toArray(new Integer[0]);
@arwankhoiruddin
arwankhoiruddin / ScreenShotDifference
Created December 26, 2018 04:04
Find the difference between two display using java.awt.Robot and Sikuli library
import java.awt.*;
import java.awt.image.BufferedImage;
import org.sikuli.script.*;
import javax.imageio.ImageIO;
import static controller.ImageController.isExist;
import static crfs.CP.contentEquals;
public class ScreenShotDifference {
public static void main(String[] args) throws Exception {
@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'];