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;
}
@brandonaaskov
brandonaaskov / jQuery Change Event: Proper Binding
Created January 11, 2012 21:34
jQuery's change() event doesn't work as expected with input text fields. This, however, does work.
/*
For some reason, the change() event only fires when the input field loses focus.
Binding to other options ('change keypress paste focus textInput input') will
fire the event several times, which is bad. The below code works even when
content is pasted into the text field, and only fires once as expected.
*/
$('#search-form .term').bind('input', function(){
console.log('this actually works');
});
/*
== malihu jquery custom scrollbars plugin ==
version: 2.3.2
author: malihu (http://manos.malihu.gr)
plugin home: http://manos.malihu.gr/jquery-custom-content-scroller
@SimonSimCity
SimonSimCity / pagination.html.twig
Last active September 30, 2023 17:29
A gist for pagination in Twig, based on the total number of pages, the current page and some URL-settings.
{#
Source: http://dev.dbl-a.com/symfony-2-0/symfony2-and-twig-pagination/
Updated by: Simon Schick <simonsimcity@gmail.com>
Parameters:
* currentFilters (array) : associative array that contains the current route-arguments
* currentPage (int) : the current page you are in
* paginationPath (string) : the route name to use for links
* showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled)
* lastPage (int) : represents the total number of existing pages
@khajavi
khajavi / Makefile
Created June 1, 2013 11:21
Example of getting attribute value of xml node by using libxml2 library.
CC = gcc
CLIBS = `pkg-config libxml-2.0 --cflags --libs`
retrieve_attribute_value: retrieve_attribute_value_example.c
$(CC) retrieve_attribute_value_example.c -o retrieve_attribute_value_example.bin $(CLIBS)
clean:
rm -f *.o *.bin
@pekhee
pekhee / connection.php
Created April 5, 2014 23:56
Setup database connection for Eloquent outside of Laravel.
<?php // Namespace DB;
use Illuminate\Database\Capsule\Manager as Capsule;
class Connection {
public function __construct()
{
$this->capsule = new Capsule;
// Same as database configuration file of Laravel.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@hlecuanda
hlecuanda / GAS-Trigger-TestingFunction.gs
Created August 19, 2015 08:32
A pattern to debug google apps script (GAS) triggered functions.
/**
* Test function for onEdit. Passes an event object to simulate an edit to
* a cell in a spreadsheet.
*
* Check for updates: http://stackoverflow.com/a/16089067/1677912
*
* See https://developers.google.com/apps-script/guides/triggers/events#google_sheets_events
*
* on Script editor, set to debug THIS function, but create breakpoints
* on the onEdit Function
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@ajinux
ajinux / README.md
Last active September 27, 2023 21:39
This python script scrapes the fedex website and outputs the package details on giving the package tracking id as input

FEDEX SCRAPER

Question

Question Code:FEDEX
                    Write a Python script which will scrape the FEDEX website to obtain the tracking details of the given shipment tracking details. The output by the script should be in JSON format.
Input: 744668909687
Expected Output:
{ "tracking no": 744668909687,
"ship date": "Wed 19/07/2017",
"status": "delivered",
"scheduled delivery": "Mon 24/07/2017 16:21"