Skip to content

Instantly share code, notes, and snippets.

View tyaslab's full-sized avatar
🌴
On vacation

Yusuf Ali tyaslab

🌴
On vacation
View GitHub Profile
@tyaslab
tyaslab / palindrome.py
Created December 18, 2021 01:33
Palindrome
def is_palindrome(number):
temp = number
reverse = 0
while temp > 0:
rem = temp % 10
reverse = (reverse * 10) + rem
temp = temp // 10
return number == reverse
import random
def main():
# tentukan angka misteri
misteri = random.randint(1, 100)
tebakan = 0
counter = 0
while misteri != tebakan:
counter += 1
def terbilang_ratusan(uang):
uang_terbilang = {
1: 'satu',
2: 'dua',
3: 'tiga',
4: 'empat',
5: 'lima',
6: 'enam',
7: 'tujuh',
8: 'delapan',
@tyaslab
tyaslab / daemonize.py
Created September 3, 2019 08:12
Daemonize
import time
import logging
from daemonize import Daemonize
pid = "/tmp/test.pid"
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.propagate = False
fh = logging.FileHandler("/tmp/test.log", "w")
fh.setLevel(logging.DEBUG)
@tyaslab
tyaslab / ActiveRecord.php
Created January 10, 2019 23:53
Yii Components
<?php
namespace app\components;
class ActiveRecord extends \yii\db\ActiveRecord {
public function saveRelatedModel($modelClass, $data, $relatedPk, $removable=TRUE) {
$pk = static::primaryKey()[0];
$modelPk = call_user_func([$modelClass, 'primaryKey'])[0];
@tyaslab
tyaslab / face_recognition.py
Created January 10, 2019 23:46
Face Recognition
import os
import cv2
import numpy as np
class FaceRecognition(object):
pca = None
u = None
weight = None
training_image_filenames = []
@tyaslab
tyaslab / Old Flex Mini Reference
Last active September 23, 2016 09:20
Tested Old and New Flex
display: box; or inline-box;
-moz-box-align
-moz-box-direction
-moz-box-ordinal-group
-moz-box-orient
-moz-box-pack
-moz-box-sizing
@tyaslab
tyaslab / index.html
Created September 22, 2016 09:04
Center Vertically No Fixed Width
<div class="v-center">
<div class="inner">
Centered Horizontally and Vertically
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=120%C3%9770&w=120&h=70">
</div>
</div>
@tyaslab
tyaslab / index.html
Created September 22, 2016 09:00
Center for Fixed Height
<div class="wrapper">
<div class="v-center">
<div class="inner">
Centered Horizontally and Vertically Sayang opo kowe krungu jerite atiku mengharap kau kembali sayang nganti memutih rambutku ra bakal luntur tresnaku<br>
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=120%C3%9770&w=120&h=70">
</div>
</div>
</div>
@tyaslab
tyaslab / oldflex.css
Created September 21, 2016 07:58
Old Flex implemented in Android JellyBean
.flex_display {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
// When Twitter Bootstrap's hidden is applied to the same element, make sure
// display is set to none.
&.hidden {
display: none;