Skip to content

Instantly share code, notes, and snippets.

View code-simple's full-sized avatar
🏠
Working from home

code-simple code-simple

🏠
Working from home
View GitHub Profile
@code-simple
code-simple / main.dart
Created October 18, 2020 11:05
How to use For Loop in Nested Map
// How to use For Loop in Nested Map
void main() {
var people = {1: {'Name': 'John', 'Age': '27', 'Sex': 'Male'},
2: {'Name': 'Marie', 'Age': '22', 'Sex': 'Female'}};
for(int i=1;i<=people.length;i++){
print('\nPerson ID: ${i}');
people[i].forEach((k,v)=>print('$k : $v'));
}
@code-simple
code-simple / people.json
Created September 28, 2021 21:06
Just Random Data
[
{
"id": 1,
"firstname": "Emiline",
"lastname": "Carville",
"email": "[email protected]",
"gender": "Genderfluid",
"job": "Professor",
"phone": "638-170-8548",
"language": "Kazakh"
@code-simple
code-simple / JSON2CSV.dart
Last active September 29, 2021 19:59
# Very Simplest Way to Create CSV Out of JSON, List Data, or Almost anything \n In this Example We will Make CSV of a JSON that has List<Map<String, dynamic>> Data
import 'dart:convert';
import 'dart:io';
// This Will extract data from JSON file and Create CSV file.
// people.json DownloadLink : https://gist.githubusercontent.com/code-simple/dff6ec9eaa0816131d7273578f38c3e1/raw/6c8e8b9bb36003c2f3b9ca3cefc8a4bcfe2910eb/people.json
// new.csv DownloadLink : https://gist.githubusercontent.com/code-simple/7cae32a464f8a9995a6e510528edc576/raw/d31870b6dac5781ac4ee1d203e66334320bfec96/new.csv
void main() {
// Read CSV [Simple CSV that has first row header, and data in next rows]
List<Map<dynamic, dynamic>> readCSV(String fileName) {
@code-simple
code-simple / new.csv
Created September 29, 2021 10:14
Random CSV Data
_ID First Name Last Name Email Gender Contact Job Language
1 Tybi Coskerry [email protected] Male 0346-5735006 Human Resources Assistant I French
2 Jerrie Wakenshaw [email protected] Female 0349-5138690 Sales Associate Chinese
3 Matty McCadden [email protected] Khusra 0346-4564463 Engineer IV Swahili
4 Darrick Oultram [email protected] Male 0339-6193663 Teacher Tswana
5 Laverna Wilcox [email protected] Male 0327-9251003 Sales Representative Bosnian
6 Elena Pinder [email protected] Khusra 0348-1525842 Registered Nurse Kurdish
7 Tildie Hefner [email protected] Khusra 0339-5566900 Editor Bengali
8 Manon Tourot [email protected] Male 0339-8781172 General Manager Czech
9 Thorn Gadesby [email protected] Male 0349-4647773 Director of Sales Montenegrin
@code-simple
code-simple / time.dart
Last active October 9, 2021 11:26
To format your Time There is no need to Import whole Intl library, Just use this small Script, It has Months names, And add 0 if DateTime.now() returns single Digit
// Test Code
// https://dartpad.dev/?id=b0c38822400ec328d396cba8e5f966bc
void main() {
mytime() {
var now = DateTime.now();
var monthList = [
// Added 1st month Null because of Range Error
'Null',
@code-simple
code-simple / next_birthday.dart
Last active October 9, 2021 17:32
Next Birthday
void main() {
nextBirthDay({required int day, required int month, required int year}) {
var now = DateTime.now();
var dob = DateTime(year,month,day);
var thisYearDob = DateTime(now.year,dob.month,dob.day);
return ('Next Birthday : ${thisYearDob.add(Duration(days:365)).toString().split(' ').first}');
}
print(nextBirthDay(day:10,month:9,year:2021));
}
// FAB GROUP BUTTON EXAMPLE
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() => runApp(MaterialApp(
home: App(),
debugShowCheckedModeBanner: false,
));
class App extends StatefulWidget {
@code-simple
code-simple / script.sh
Created June 7, 2022 14:34
Webscrapping using BASH
#!/bin/bash
# This is example of how your can Webscrap using curl , Here i Webscraped my Gas and Electricity and Got all neccessary Information , Just change LINKS to get your corresponding bills to yours.
GASFILE='file:///tmp/gas.html'
GASLINK="https://www.sngpl.com.pk/web/viewbill?consumer=02613930003&proc=viewbill&contype=NewCon"
electricityLINK="https://bill.pitc.com.pk/pescobill/general?refno=08262140100430"
electricityFILE='/tmp/e.txt'
# TOOLS USED HERE: html2text - grep - wget
# Download and Convert ELECTRICTITY to Text electricity bill for easy extraction
@code-simple
code-simple / pesco_scrapper.py
Last active September 4, 2022 18:56
PESCO.py
# This Python Script Scrapp PESCO Bill and Give all important information about Utility Bill
# Required modules BeautifulSoup & selenium , and Python 3.10 or latest
# To install modules write following command into Command
# e.g to install BeautifulSoup write in command 'pip install BeautifulSoup'
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import re
@code-simple
code-simple / AmazonScrapper.py
Last active March 5, 2023 14:04
Amazon Product Scraping with auto Pagination Support
from bs4 import BeautifulSoup
import sys,requests,re,os
import pandas as pd
os.system('clear')
# Function to extract Product Title
def get_title(soup):