Skip to content

Instantly share code, notes, and snippets.

View satriahrh's full-sized avatar

Satria H R Harsono satriahrh

View GitHub Profile
@satriahrh
satriahrh / retrieveTree.py
Last active November 19, 2017 14:56
python code for retrieve tree
def retrieveTree(self, coordinate, level):
if not level % 2:
# genap
if coordinate[0] < self.coordinate[0]:
# kiri
if not hasattr(self, 'left'):
return self.coordinate
return self.left.retrieveTree(coordinate, level+1)
elif coordinate[0] > self.coordinate[0]:
# kanan
def retrieveTree(self, qp, level=0, arr):
"""
INPUT
qp : query point of (x, y)
level : initial level, default set to 0
arr : dataset containing vertices and its list region
OUTPUT
dictionary of {
'nearest': (int, int),
@satriahrh
satriahrh / histogram.py
Last active March 1, 2018 06:14
Histogram code on github.com/hafizhme/phocode that seems can't affordable on it
from PIL import Image
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('agg')
def do(original_image: Image):
freq = [
[0 for x in range(256)],
[0 for x in range(256)],
3 523
523 1259
1259 1987
1987 2791
2791 3623
3623 4483
4483 5351
5351 6199
6199 7079
7079 8123
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install git -y
sudo apt-get install gcc-8 g++-8 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo update-alternatives --config gcc
g++ -o bin/kpa-brute-force -std=c++17 ftie/*.h ftie/*.cpp pengujian/kpa_bf.cpp `libpng-config --ldflags`

Data to Test

  • ./bin/kpa-brute-force 3 7 2
  • ./bin/kpa-brute-force 3319 3323 6740748
  • ./bin/kpa-brute-force 7219 7243 5276214
  • ./bin/kpa-brute-force 11503 11519 108853157
  • ./bin/kpa-brute-force 15959 15971 198571272
  • ./bin/kpa-brute-force 20743 20747 3897525

PNG++ Installation on Ubuntu 16.04

Full documentation --> https://www.nongnu.org/pngpp/doc/0.2.9/

Requirements

The libpng it self, in Ubuntu 16.04 you can follow sudo apt install libpng12-dev.

The Steps

  1. Grab the lattest file here aka 0.2.9
  2. Go to download directory.
D, [2019-04-22T17:25:04.844532 #28255] DEBUG -- : (0.8ms) SET NAMES utf8mb4 COLLATE utf8mb4_bin, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
D, [2019-04-22T17:25:04.855728 #28255] DEBUG -- : DebtCollector::CashFunding::Investor Load (0.9ms) SELECT `cash_funding_investors`.* FROM `cash_funding_investors` WHERE `cash_funding_investors`.`user_id` = 1 LIMIT 1
I, [2019-04-22T17:25:04.931137 #28255] INFO -- : [paperclip] Trying to link /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-15d663q to /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-sr49e6
I, [2019-04-22T17:25:04.945184 #28255] INFO -- : [paperclip] Trying to link /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-1908wza to /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-1imoczc
D, [2019-04-22T17:25:04.946448 #28255] DEBUG -- : (0.5ms) BEGIN
I, [2019-04-22T17:25:04.947528 #28255] INFO -- : [paperclip] Trying to

Ruby Cheat Sheet

How to generate a random date and time between two dates?

Time.at((date2.to_f - date1.to_f)*rand + date1.to_f)

Git Cheat Sheet

Push Tag to Remote

Push a specific tag only, no forcing to push all tags. See more

git push origin <tag_name>