Skip to content

Instantly share code, notes, and snippets.

@ljayz
ljayz / README.MD
Created March 12, 2019 03:16 — forked from dan1wang/README.MD
Executing App Script functions in Firebase Cloud Functions

If you are using Firebase on a Spark (free) plan, you can only make outbound networking requests to Google services. Unfortunately, that does not include Web app deployed from App Script (script.google.com/macros/s/.../exec). (Stackoverflow #43330192)

This is a crude example showing how to execute Apps Script using the scripts.run method of Apps Script API.

In this example, the Firebase app does not store the user's OAuth id token, does not validate the access token (e.g. the access token is issued for your project, not someone else's), and does not store the refresh token (access token will expire 60min after issue if not refreshed). For production, these issues must be resolved.

@ljayz
ljayz / readme.md
Last active November 16, 2018 17:25
git
@ljayz
ljayz / reduce.js
Created October 10, 2018 06:17
Javascript Array to Object
//from [{key1:val1},{key2:val2},{key3:val3}] to {key1:val1,key2:val2,key3:val3}
const array = [{key1:'val1'},{key2:'val2'},{key3:'val3'}];
const arrayToObject = (accumulator, currentValue) => Object.assign(accumulator, currentValue);
array.reduce(arrayToObject, {});
@ljayz
ljayz / httpd-vhosts.conf
Created September 13, 2018 01:16
XAMPP: Fix laravel undefined index in database.php
<VirtualHost laravel.localhost.com:80>
ServerAdmin user@localhost.com
DocumentRoot "/path/to/laravel/application/public/folder"
ServerName laravel.localhost.com
ErrorLog "logs/laravel.localhost.com.log"
CustomLog "logs/laravel.localhost.comm-access.log" common
SetEnv DATABASE_URL http://user:pass@localhost/
</VirtualHost>
@ljayz
ljayz / .profile
Last active September 7, 2018 04:21
Show git branch in bash terminal
# Install https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh to ~.git-prompt.sh
# Add to code below to ~.profile
# store colors
MAGENTA="\[\033[0;35m\]"
YELLOW="\[\033[01;33m\]"
BLUE="\[\033[00;34m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"
GREEN="\[\033[32m\]"
@ljayz
ljayz / shell
Created August 29, 2018 12:57
Jenkins execute shell - ignore error
docker rm -f container || echo "Container not found"
@ljayz
ljayz / .htaccess
Created August 16, 2018 00:59
Show coming-soon.html page on specific IP address
#placed in .htaccess together with coming-soon.html
<IfModule mod_rewrite.c>
RewriteEngine On
# Allow all static image
RewriteRule ^static/img/(.*)$ static/img/$1 [L]
# Show coming soon page
RewriteCond %{REMOTE_ADDR} !=127.0.0.0 #internal public ip address
RewriteRule ^ coming-soon.html [L]
@ljayz
ljayz / main.js
Created July 12, 2018 04:13
loading meteor npm package with plugins (moment and moment-timer)
//client/main.js
import moment from 'moment';
import 'moment-timer';
Template.body.onRendered(function(){
new moment.duration(1000).timer({ start: true, loop: true }, () => {
console.log('moment timer run');
});
});
@ljayz
ljayz / readme.txt
Last active March 24, 2024 18:33
Fix aws codecommit unable to access repository (The requested URL returned error: 403) in windows
this was tested using windows10 pro
when cloning a git this error was produced
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/RepositoryName': The requested URL returned error: 403
to fix add the following git configuration
git config --global credential.helper "!aws codecommit credential-helper $@"
git config --global credential.UseHttpPath true
check if git has system credential.helper by typing
@ljayz
ljayz / modal.css
Last active March 19, 2018 01:02
Bootstrap 3 modal body auto height
.modal .modal-body {
max-height: calc(100vh - 200px);
overflow-y: auto;
}