Skip to content

Instantly share code, notes, and snippets.

View Tester2009's full-sized avatar
💭
breathing

Мухаммад Алифф Муаззам Tester2009

💭
breathing
View GitHub Profile
@Tester2009
Tester2009 / string_to_byte_array.py
Last active January 16, 2020 10:00
Convert all strings to byte, and append it to array. Now can change it's data type from list to array. Now the data is in array, compute them all in CRC16 checksum
import numpy as np
import crc16
array_z = []
data_one = "4040"
data_two = "2900"
# convert to byte
# print( list(data_one.encode()) )
# print( list(data_two.encode()) )
array_z.append( list(data_one.encode()) )
@Tester2009
Tester2009 / mqtt_broker.py
Created May 27, 2019 06:07
Simple Python MQTT communication
# source: https://mntolia.com/mqtt-python-with-paho-mqtt-client/
# source: http://www.steves-internet-guide.com/into-mqtt-python-client/
import paho.mqtt.client as mqtt
broker_host = "iot.eclipse.org"
broker_port = 1883
def on_connect(client, userdata, flags, rc):
print("Connected with result code: "+str(rc))
#include <ArduinoJson.h>
void setup() {
// Initialize Serial port
Serial.begin(9600);
while (!Serial) continue;
// Allocate the JSON document
//
// Inside the brackets, 200 is the RAM allocated to this document.
@Tester2009
Tester2009 / noob_deploy_script.sh
Created February 26, 2019 14:53
Noob way to automate my web deploy { ignore this please }
# Noob Web Deploy
# Made by @Tester2009
# February 26, 2019
# backup first from VPS backup_public
echo "Start backup remote to local"
rsync -ravz --relative --progress -e 'ssh -i /Users/tester2009/.ssh/tester2009.pem' ubuntu@some.weird.ip:/home/ubuntu/backup_public/ /Volumes/Backups/26Feb2019
echo "Done backup from /home/ubuntu/backup_public/"
@Tester2009
Tester2009 / binary_search_algo.py
Created October 23, 2018 18:37
Find data in array by using binary search algorithm. Written in Python
# explanation: https://www.youtube.com/watch?v=IcK2Qyk3cUs
# written by: github.com/Tester2009
def binary_search(arr, val):
if len(arr)==0 or (len(arr)==1 and arr[0]!=val):
return False
mid = arr[len(arr)/2]
if val==mid:
print("Found")
@Tester2009
Tester2009 / insertion_sort_algo.py
Created October 23, 2018 17:34
Insertion sorting algorithm. Written in Python
# explanation: https://www.youtube.com/watch?v=i-SKeOcBwko
# written by github.com/Tester2009
array_1 = [5, 7, 9, 3, 2, 1]
for iterate in range( 1, len(array_1) ): # iteration start with 1, because to compare with previous element in array
value = array_1[iterate] # assign array_1[value_of_iteration] to value variable
element = iterate # assign value_of_iteration to element variable
while ( element>0 ) and ( array_1[element-1]>value ): # check if element is more than 0. and check value of previous element in array to compare with current element value
array_1[element] = array_1[element-1] # assign value of previous element in array to current array element
element = element-1 # assign element to previous element
@Tester2009
Tester2009 / BubbleSort.java
Created October 15, 2018 04:59
Algo Bubble Sort
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bubblesort;
import java.util.*;
/**
*
@Tester2009
Tester2009 / l2chroot.txt
Created September 9, 2018 11:07
find and copy required library for each binary
#!/bin/bash
# Use this script to copy shared (libs) files to Apache/Lighttpd chrooted
# jail server.
# ----------------------------------------------------------------------------
# Written by nixCraft <http://www.cyberciti.biz/tips/>
# (c) 2006 nixCraft under GNU GPL v2.0+
# + Added ld-linux support
# + Added error checking support
# ------------------------------------------------------------------------------
# See url for usage:
@Tester2009
Tester2009 / switch_config
Last active August 7, 2018 07:43
Cisco Switch Configuration
Switch> en
Switch# conf t
Switch(config)# hostname <switch name>
S1(config)# no ip domain-lookup
S1(config)# vlan 99
@Tester2009
Tester2009 / car_loan_calculator.cpp
Created July 21, 2018 17:07
Calculate your car loan by using C plus plus
// Made with <3 by @Tester2009 at July 22, 2018
// https://gist.github.com/Tester2009
// All calculation was made by my friend. If there any mistake in this code, feel free to fix it.
// This code is tested on Ubuntu 18.04 LTS x86_64
// g++ car_loan_calculator.cpp -o car_loan_calculator.cpp
// ./car_loan_calculator
#include <iostream>
#include <stdio.h>
#include <math.h>