Skip to content

Instantly share code, notes, and snippets.

View izzuddin91's full-sized avatar
🎯
Focusing

izzuddin cheras izzuddin91

🎯
Focusing
View GitHub Profile
@izzuddin91
izzuddin91 / increment_relay_count.py
Last active August 11, 2019 13:26
hydroponic project august 2019 - iteration 1 complete package
#import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
#from time import sleep # Import the sleep function from the time module
import os
import csv
r = csv.reader(open('/home/pi/Desktop/hydroponic_project/relay_running_count.csv')) # Here your csv file
lines = list(r)
original = lines[0][0]
print(lines[0])
@izzuddin91
izzuddin91 / switch.py
Created July 23, 2019 14:57
setting up switch to display information on matrix led
import RPi.GPIO as GPIO
import time
import os
import csv
GPIO.setmode(GPIO.BCM)
#pin bawah skali, seblah ground
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
@izzuddin91
izzuddin91 / water_relay.py
Created July 23, 2019 14:41
setting up relay for hydroponic projects
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and s$
while True: # Run forever
GPIO.output(8, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second -> use this to set the interval for water pump
GPIO.output(8, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second
@izzuddin91
izzuddin91 / max7219.py
Last active July 23, 2019 14:25
7 segemend LED matrix
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
import re
import time
import argparse
from luma.led_matrix.device import max7219
@izzuddin91
izzuddin91 / basic_oop.rb
Last active May 6, 2019 12:32
crops function2
class Crops
attr_accessor :sam #declare a variable named sam here
attr_accessor :luke #declare a variable named luke here
def initialize()
@sam = ["apple", "carrot"] #declare that sam has what
@luke = ["carrot"] #declare that luke has what
end
@izzuddin91
izzuddin91 / basic_process.rb
Created May 5, 2019 01:07
Crops function
puts "Please select crop number and separated by comma if more than one : \n 1) apple \n 2) pear"
a = gets.chomp
#receive string with comma separated
b = a.split(",")
# puts "#{b}"
b.each do |x|
#received string. convert to integer first
@izzuddin91
izzuddin91 / add_footer.swift
Created December 20, 2018 09:03
Swift iOS PDF
mImageView = (ImageView) findViewById(R.id.imageView1);
mImageView.setImageResource(R.drawable.camera);
func getLatestCounterNumber() {
var int = 0
ref = Database.database().reference()
ref.observeSingleEvent(of: .value, with: { snapshot in
if !snapshot.exists() { return }
@izzuddin91
izzuddin91 / convertPDFToImage.swift
Created July 29, 2018 03:59
general code snippets
//swift 4.0
func convertpdfToImage(url: URL) -> UIImage? {
guard let document = CGPDFDocument(url as CFURL) else { return nil }
guard let page = document.page(at: 1) else { return nil }
let pageRect = page.getBoxRect(.mediaBox)
let renderer = UIGraphicsImageRenderer(size: pageRect.size)
let img = renderer.image { ctx in
UIColor.white.set()
ctx.fill(pageRect)