Skip to content

Instantly share code, notes, and snippets.

@Fabianopb
Fabianopb / server.js
Last active June 25, 2023 16:03
Node server using multer to upload files to AWS S3.
const express = require('express');
const app = express();
const AWS = require('aws-sdk');
const fs = require('fs');
const fileType = require('file-type');
const multiparty = require('multiparty');
// configure the keys for accessing AWS
AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
@Fabianopb
Fabianopb / FileUpload.jsx
Last active December 1, 2020 03:15
React component for single file upload.
import React, { useState } from 'react';
import axios from 'axios';
const FileUpload = () => {
// If you are using TypeScript the state will be
// const [file, setFile] = useState<FileList | null>(null);
const [file, setFile] = useState(null);
const submitFile = async () => {
try {
@puf
puf / ChatMessage.java
Last active July 12, 2021 21:56
Zero to App: Develop with Firebase (for Android - Google I/O 2016)
package com.google.firebase.zerotoapp;
public class ChatMessage {
public String name;
public String message;
public ChatMessage() {
}
public ChatMessage(String name, String message) {
@kevinvanmierlo
kevinvanmierlo / BaseActivity.java
Last active September 1, 2020 15:22
Same Navigation Drawer on different Activities
public class BaseActivity extends AppCompatActivity
{
public DrawerLayout drawerLayout;
public ListView drawerList;
private ActionBarDrawerToggle drawerToggle;
protected void onCreate(Bundle savedInstanceState)
{
// R.id.drawer_layout should be in every activity with exactly the same id.
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@libinbensin
libinbensin / MainActivity.java
Last active December 9, 2023 14:44
Facebook Popup using PopupWindow
public class MainActivity extends
private PopupWindow popWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@vikrum
vikrum / AndroidManifest.xml
Last active April 6, 2024 12:00
Firebase+Android sample app with background Service + local notifications.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bgfirebaseapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />
@emil2k
emil2k / Locator.java
Last active April 29, 2022 04:25
Android utility class for getting device location using various methods. Depends on `Connectivity` class found here: https://gist.github.com/emil2k/5130324
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: