Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import random
batas_bawah = 0
batas_atas = 12
jumlah_titik = 20
#include <stdio.h>
struct Peserta {
char noreg[6];
char nama[50];
char kursus;
int nilai;
};
@heisid
heisid / conservation_mode.sh
Created September 27, 2021 03:04
Battery conservation mode for Ideapad
#!/bin/sh
# A shell script to enable/disable battery conservation mode
# in my ideapad gaming 3 laptop
# conservation mode is basically a battery charging limiter
# to keep the battery within 55-60%.
# Good when I plug the charger all the time (which mostly I do)
# Not good for traveling
# Reference: https://wiki.archlinux.org/title/Laptop/Lenovo#Battery_Conservation_Mode_on_IdeaPad_laptops
#
# Sid
#!/usr/bin/env python
from shutil import disk_usage
from http.server import BaseHTTPRequestHandler, HTTPServer
class WebServer(BaseHTTPRequestHandler):
def get_info(self):
path = '/'
total, used, free = disk_usage(path)
return 'Total: {:6.2f}GB<br>'.format(total / 10**9) \
@heisid
heisid / KaliAja.cpp
Created July 23, 2021 18:05
Mengalikan angka tanpa mengalikan
/*
* Perkalian tanpa perkalian :D
*
* sid
*/
#include <iostream>
bool ganjilkah(int n) {
import re
def tokenize(sentence):
delimiter = "(plus|minus|divided by|times|\(|\))"
tokens = re.split(delimiter, sentence)
# Buang spasi di awal dan akhir
tokens = [token.strip() for token in tokens]
# Buang yg kosong
tokens = list(filter(None, tokens))
return tokens
@heisid
heisid / goblok.py
Created July 3, 2020 08:12
A python script that read itself
#!/usr/bin/env python3
# A python script that read itself
from sys import argv
with open(argv[0], 'r') as myself:
print(myself.read())
#!/bin/sh
# http://www.alfredklomp.com/programming/shrinkpdf
# Licensed under the 3-clause BSD license:
#
# Copyright (c) 2014-2019, Alfred Klomp
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
<?php
echo file_get_contents('index.php');
@heisid
heisid / test
Created February 8, 2019 10:15
<?php
echo get_file_contents('index.php');