Skip to content

Instantly share code, notes, and snippets.

View scriptpapi's full-sized avatar
🎯
Focusing

Nawaf Abdullah scriptpapi

🎯
Focusing
  • Dubai, United Arab Emirates
View GitHub Profile
@scriptpapi
scriptpapi / factoryPattern.cpp
Created May 25, 2018 23:20
A Template for implementing factory method in C++
// A Template for implementing factory method
#include <iostream>
using namespace std;
// Declare the available types that can be passed to the factory
enum robotType {R_Bipedal, R_Drone, R_Rover};
// Superclass
class Robot{
@scriptpapi
scriptpapi / alarm.py
Created August 24, 2018 11:15
python timer alarm script using multiprocessing
from multiprocessing import Process
import time
class TimeoutException(Exception):
pass
timer = 5
def start_timer():
time.sleep(timer)
raise TimeoutException
@scriptpapi
scriptpapi / write2txt.cs
Created December 27, 2018 09:52
C# write to text file
using System;
using System.IO;
namespace Write2Text
{
class Program
{
static void Main(string[] args)
{
using (StreamWriter writetext = new StreamWriter("C:/Users/abdul_na/Desktop/hello.txt"))
@scriptpapi
scriptpapi / ListAllStorage.js
Created May 9, 2020 15:21
Firebase - Listing All Files in Storage Folder
Firebase.storage().ref(this.state.User.uid).listAll()
.then((result) => {
result.items.forEach((imgRef) => {
console.log("ListAll > " + imgRef.fullPath)
})
})
@scriptpapi
scriptpapi / MaterialUISearch.js
Last active June 4, 2020 19:44
Material UI Search Box with Start Adornment - ReactJS
import TextField from '@material-ui/core/TextField';
import SearchIcon from '@material-ui/icons/Search';
import InputAdornment from '@material-ui/core/InputAdornment';
import InputLabel from '@material-ui/core/InputLabel';
import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
const Search = () => {
const SearchStyles = {
@scriptpapi
scriptpapi / Material-UI-Select.js
Created June 18, 2020 19:48
React Material UI Select Component
const Select = () => {
return (
<FormControl style={NewUserStyles.Input}>
<InputLabel error={this.state.Error_Industry}>Industry</InputLabel>
<Select value={this.state.Industry}
error={this.state.Error_Industry}
onChange={(e) => {this.setState({Industry: e.target.value})}}
>
{
Industries.map((item) => {
@scriptpapi
scriptpapi / ContactPicker.swift
Last active May 7, 2021 11:12
Contact Picker for SwiftUI
import SwiftUI
import Contacts
import Combine
import Foundation
import ContactsUI
struct ContactPicker: UIViewControllerRepresentable {
typealias UIViewControllerType = EmbeddedContactPickerViewController
@scriptpapi
scriptpapi / DocumentPicker.swift
Created April 26, 2021 21:25
Document Picker for SwiftUI
import Foundation
import SwiftUI
import UIKit
struct DocumentPicker: UIViewControllerRepresentable {
@Binding var filePath: URL?
func makeCoordinator() -> DocumentPicker.Coordinator {
return DocumentPicker.Coordinator(parent1: self)
@scriptpapi
scriptpapi / ImagePicker.swift
Created April 26, 2021 21:26
ImagePicker for SwiftUI
import Foundation
import SwiftUI
struct ImagePicker: UIViewControllerRepresentable {
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
@Environment(\.presentationMode) var presentationMode
@Binding var image: UIImage?
@scriptpapi
scriptpapi / write-to-csv.html
Created July 26, 2022 08:07
write to csv using pure html and js
<html>
<head>
<script>
var csvFile = null
var merchantList = []
var merchants = []
var updateResult = []
var success = 0
var failed = 0