Skip to content

Instantly share code, notes, and snippets.

@terngkub
terngkub / split_list.py
Created November 16, 2020 11:58
Python: split a list into a list of chunks
def split_list(lst, chunk_nb):
list_size = len(lst)
ret = []
for i in range(chunk_nb):
beg = round(list_size * i / chunk_nb)
end = round(list_size * (i+1) / chunk_nb)
ret.append(lst[beg:end])
return ret
# Section: Maven Basics
## Maven Life Cycles
Each life cycles contains phases.
Each phases may have plugin and goal
Three pre-defined lifecycles
* clean
* pre-clean
#include <iostream>
#include <vector>
#include <chrono>
void copy_arg(std::vector<int> v)
{
(void)v;
}
void ref_arg(std::vector<int> const & v)
@terngkub
terngkub / README.md
Last active October 30, 2019 11:19
push_swap_performance

push_swap_performance

A shellscript to test the performance of push_swap project

About this project

This is the shell script that I wrote to test my push_swap project performance. I also use it to test other people's projects that I review. The script will output:

  • avg = average performance
  • best = performance from the best case
  • worst = performance from the worst case
  • exceed = number of cases that exceed the performance threshold
@terngkub
terngkub / README.md
Created March 13, 2019 19:52
fillit_compare

fillit_compare

A shellscript to compare the result of 2 fillit program

About the script

  • I used this script to test the result of my fillit project by comparing the result with other students project.
  • The script uses Tetriminos-generator to generate a random input.
  • Then, the script runs two fillit program and compare the results.
  • If there is a different, the script will stop running. You can then look at the input, outputs and the different file.

How to use the scipt

@terngkub
terngkub / gist:261495d7ff2625626108c2cc8704d047
Last active March 4, 2026 03:18
Install zlib 32bit on Ubuntu 64 bit
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install zlib1g:i386
sudo apt install libsnappy-dev:i386
sudo apt install liblz4-1:i386
Code from https://www.lvsys.com/how-to-add-page-breaks-to-html-in-articles
... content in page 1 ...
<p style="page-break-after: always;">&nbsp;</p>
<p style="page-break-before: always;">&nbsp;</p>
... content in page 2 ...
@terngkub
terngkub / index.html
Created October 2, 2018 14:05
Simple histogram with d3.js
<html>
<head>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<script type="text/javascript">
var dataset = [5, 10, 13, 19, 21, 25, 22, 18, 15, 13, 11, 12, 15, 20, 18, 17, 16, 18, 23, 25];
var w = 500;
@terngkub
terngkub / append.go
Created October 2, 2018 08:27
Golang. Append string to a file. If the file didn't exist, created it.
package main
import (
"log"
"os"
)
func appendFile(fileName, content string) {
file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
template <typename D = void, typename... T>
constexpr auto make_array(T &&... t) -> std::array<std::conditional_t<std::is_void<D>::value, std::common_type_t<T...>, D>, sizeof...(T)>
{
return {{std::forward<T>(t)...}};
}