Skip to content

Instantly share code, notes, and snippets.

View jsdbroughton's full-sized avatar
🐒
coiled spring

Jonathon Broughton jsdbroughton

🐒
coiled spring
View GitHub Profile
@ramnathv
ramnathv / gh-pages.md
Created March 28, 2012 15:37
Creating a clean gh-pages branch

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
@entaq
entaq / Google_oAuth.js
Created November 15, 2012 17:18
Google oAuth 2.0 sample
/**
reference -
https://developers.google.com/accounts/docs/OAuth2WebServer
https://code.google.com/apis/console/
https://developers.google.com/+/api/latest/
**/
////handle all requests here
function doGet(e) {
anonymous
anonymous / gist:4169590
Created November 29, 2012 14:57
Get Google Spreadsheet as PDF with customizations
function spreadsheetToPDF(key) {
var oauthConfig = UrlFetchApp.addOAuthService("spreadsheets");
var scope = "https://spreadsheets.google.com/feeds"
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
@RonnyO
RonnyO / console.lol.js
Created January 16, 2013 09:17
Like console.log, just a tiny bit funnier
// console.lol by @RonnyOrbach, idea by Erez Avny
if (typeof console != 'undefined') console.lol = function(){
var args = [].slice.call(arguments, 0);
args.unshift("LOL");
args.push("LOLOLOL!")
console.log.apply(console, args);
};
@juanpabloaj
juanpabloaj / DriveUpload.js
Last active May 13, 2020 22:17 — forked from rcknr/DriveUpload.gs
xls attached to google spreadsheet
function uploadXls(file) {
authorize();
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // <-- developer key
var metadata = { title: file.getName() }
var params = {method:"post",
oAuthServiceName: "drive",
oAuthUseToken: "always",
contentType: "application/vnd.ms-excel",
contentLength: file.getBytes().length,
payload: file.getBytes()
@jsdbroughton
jsdbroughton / GoogleSheetPDF.js
Last active April 28, 2022 18:42
Function to convert a given Google Spreadsheet [Sheet] into a PDF.
/**
* Function to convert a given Google Spreadsheet [Sheet] into a PDF.
*
* @param {string} key This is the Id of the Sheet to be converted bothe the DocsList.getId() and the SpreadsheetApp.getId() versions work
* @param {string} name [Optional] Intended Filename. If omitted, uses the Sheet filename.
* @param {object} options Settings object for the crafting of the PDF. Defaults to A4, no gridline print etc. <pre>
* {
* format:Enum,
* size:Enum,
* headers: Bool,
@soundTricker
soundTricker / datastore.js
Created May 17, 2013 11:02
Google Apps ScriptからCloud Datastore APIへのクエリ
function myFunction() {
var option = googleOAuth_();
option.method = "post";
option.contentType = 'application/json';
option.payload = JSON.stringify({
"query":
{
"kinds":
[
@austinhyde
austinhyde / js-observables-binding.md
Last active August 16, 2023 18:19
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active July 3, 2024 08:29
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.