Skip to content

Instantly share code, notes, and snippets.

View ombak's full-sized avatar
🎯
Focusing

Sukma Saputra ombak

🎯
Focusing
View GitHub Profile
# gunakan saat pytest error
pytest --capture=sys
# gunakan saat pytest success
pytest -s
@ombak
ombak / gist:787fbf04c8bdf7d98b47933c9d4033b3
Created June 7, 2020 05:55
menghapus_cache_pada_git_1.sh
git rm -r --cached .
def selection_sort(mylist):
# i indicates how many items were sorted
for i in range(len(mylist)-1):
# To find the minimum value of the unsorted segment
# we first assume that the first element is the lowest
min_index = i
# We then use j to loop through the remaining elements
dex = 0
for j in range(i+1, len(mylist)):
if mylist[j] < mylist[min_index]:
<?php
//...dengan menggunakan step akan menghasilkan kelipatan 10
//...yang dimulai dari 0 dan diakhiri di nilai 100
//...array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
foreach (range(0, 100, 10) as $number) {
echo $number;
}
<?php
//...array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
foreach (range(0, 12) as $number) {
echo $number;
}
<?php
//...kosongkan parameter password bila tidak ada password
$conn = mysql_connect("localhost", "root", "");
//...bila koneksi gagal
if(!$conn) {
die("koneksi gagal, periksa lagi parameter.");
}
//...mysql_error() untuk menampilkan pesan error
<?php
//...kosongkan parameter password bila tidak ada password
$conn = mysql_connect("localhost", "root", "");
//...bila koneksi gagal
if(!$conn) {
die("koneksi gagal, periksa lagi parameter.");
} else {
echo "koneksi berhasil.";
}
<?php
echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!';
<?php
//....basic true/false declaration
$user_id = (!empty($id) ? $id : '');
<?php
if ( $kondisi ) {
print 'statement';
} else {
print 'other statement';
}