Skip to content

Instantly share code, notes, and snippets.

@mhawksey
mhawksey / gist:1442370
Last active February 25, 2024 12:01
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@hubgit
hubgit / list-files-in-folder.js
Created September 20, 2012 11:20
List all files in a folder (Google Apps Script)
function listFilesInFolder() {
var folder = DocsList.getFolder("Maudesley Debates");
var contents = folder.getFiles();
var file;
var data;
var sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
@jo-snips
jo-snips / custom-events-wp_query.php
Last active January 5, 2023 17:24
The Events Calendar - Custom Query Using WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::POSTTYPE),
'posts_per_page'=>10,
//order by startdate from newest to oldest
'meta_key'=>'_EventStartDate',
'orderby'=>'_EventStartDate',
'order'=>'DESC',
@mogsdad
mogsdad / GCalUtils.md
Last active May 10, 2021 17:39
Collection of Google Calendar related utility functions for Google Apps Script.

Google Calendar Utilities

getEventsWithGuest

Gets all events that occur within a given time range, and that include the specified guest email in the guest list.

###Parameters:###

@codearachnid
codearachnid / combine_post_type.php
Last active January 6, 2016 20:49
This is a custom query fix for The Events Calendar plugin to query other post types in the same loop as events. This also works with TEC PRO for recurrence.
<?php
/**
* setup when your post type is saved to add _EventStartDate & _EventDuration
* meta fields add your own post types (line 10) to mach filters for the meta
* data. Then use tribe_get_events to query both all desired post types (be
* sure to set for future status)
*/
function extend_events_startdate( $post_id ){
//verify post is not a revision
if ( !wp_is_post_revision( $post_id ) && in_array( get_post_type( $post_id ), array( 'post' ) ) ) {
@hisnipes
hisnipes / Wordpress GravityForms Google Spreadsheet Hook
Last active December 10, 2021 14:03
Wordpress GravityForms Google Spreadsheet Hook - dynamically populate radio button choices using data from a Google Spreadsheet (should allow for easier collaboration with non-tech colleagues). Matches with today's date to pull relevant information from the table. Thanks to Pamela Fox (parsing JSON output with PHP: https://gist.github.com/pamela…
<?
// Gravity Form Hook to SQL Database for Today's Dishes //
// the ### in gform_pre_render_### locates the id of your form //
add_filter('gform_pre_render_5', 'todays_dishes');
function todays_dishes($form){
foreach($form['fields'] as &$field){
@daichan4649
daichan4649 / convertSheet2Json.gs
Last active January 4, 2024 17:09
[GAS] load SpreadSheet as JSON #spreadsheet #calendar #google
function convertSheet2Json(sheet) {
// first line(title)
var firstRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var firstRowValues = firstRange.getValues();
var titleColumns = firstRowValues[0];
// after the second line(data)
var lastRow = sheet.getLastRow();
var rowValues = [];
for(var rowIndex=2; rowIndex<=lastRow; rowIndex++) {
@varun-raj
varun-raj / pullJSON.js
Last active October 31, 2022 16:19
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
@RadGH
RadGH / wordpress-tinymce.js
Last active October 21, 2022 01:21
Get/Set content of a TinyMCE visual or text editor with JavaScript
/*
Based on: http://wordpress.stackexchange.com/questions/42652/#answer-42729
These functions provide a simple way to interact with TinyMCE (wp_editor) visual editor.
This is the same thing that WordPress does, but a tad more intuitive.
Additionally, this works for any editor - not just the "content" editor.
Usage: