Skip to content

Instantly share code, notes, and snippets.

@adamcyber1
adamcyber1 / remove_pdf_password.py
Created February 22, 2021 20:24
Remove Password from PDF
import pikepdf
'''
Opens a password protected PDF, then saves it as non-password protected
Simply set the pdf you want to open, the password, and the pdf you want to save to
'''
def main():
OPEN_PDF = ''
@adamcyber1
adamcyber1 / confirm.dart
Created September 22, 2020 05:34
Doogle Grive
Center(
child: Column(
children: [
SizedBox(
height: 50,
),
Padding(
padding: const EdgeInsets.all(20.0),
child: TextField(
onChanged: (text) {
@adamcyber1
adamcyber1 / configure.dart
Created September 22, 2020 05:30
Doogle Grive configure
void configureAmplify() async {
if (!mounted) return;
try {
AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
AmplifyStorageS3 storage = AmplifyStorageS3();
// Authentication -> AWS Cognito
// Analytics -> AWS Pinpoint
@adamcyber1
adamcyber1 / listfile.dart
Created September 22, 2020 00:21
Doogle Grive List File
Future<List<StorageItem>> listFiles() async {
try {
ListResult res = await Amplify.Storage.list();
AuthUser user = await Amplify.Auth.getCurrentUser();
List<StorageItem> items = res.items
.where((e) => e.key.split('/').first.contains(user.username))
.toList();
return items;
@adamcyber1
adamcyber1 / deletefile.dart
Last active September 22, 2020 03:09
Doogle Grive delete file
void deleteFile(StorageItem item) async {
try {
await Amplify.Storage.remove(
key: item.key,
);
} catch (e) {
Alert(
context: context,
@adamcyber1
adamcyber1 / download.dart
Last active September 22, 2020 03:40
Doogle Grive download file
void downloadFile(StorageItem item) async {
try {
var dir = await DownloadsPathProvider.downloadsDirectory;
var url = await Amplify.Storage.getUrl(
key: item.key, options: GetUrlOptions(expires: 3600));
await checkPermission();
await FlutterDownloader.enqueue(
url: url.url,
@adamcyber1
adamcyber1 / upload.dart
Last active September 22, 2020 03:41
Doogle Grive upload
void uploadFile() async {
File file = await FilePicker.getFile();
AuthUser user = await Amplify.Auth.getCurrentUser();
try {
if (file.existsSync()) {
setState(() {
uploading = true;
});
@adamcyber1
adamcyber1 / logout.dart
Created September 22, 2020 00:09
Doogle Grive Logout Function
logout() async {
try {
Amplify.Auth.signOut();
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => Login()));
} on AuthError catch (e) {
Alert(
context: context,
type: AlertType.error,
@adamcyber1
adamcyber1 / confirm.dart
Created September 22, 2020 00:03
Doogle Grive confirm
confirmUser() async {
SignUpResult res = await Amplify.Auth.confirmSignUp(
username: this.widget.username,
confirmationCode: code.trim()
);
}
@adamcyber1
adamcyber1 / signup.dart
Created September 22, 2020 00:01
Doogle Grive Sign Up
Future<String> _registerUser(LoginData data) async {
try {
Map<String, dynamic> userAttributes = {
"email": data.name,
};
SignUpResult res = await Amplify.Auth.signUp(
username: data.name,
password: data.password,
options: CognitoSignUpOptions(userAttributes: userAttributes));