Skip to content

Instantly share code, notes, and snippets.

View udithishara's full-sized avatar
🏠
Working from home

Udith Ishara Madusanka udithishara

🏠
Working from home
View GitHub Profile
@pamelafox
pamelafox / showspreadsheet.php
Created January 8, 2011 05:47
PHP for parsing the JSON output a published Google spreadsheet and displaying columns from each row.
<?php
// Parsing this spreadsheet: https://spreadsheets.google.com/pub?key=0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc&hl=en&output=html
$url = 'http://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json';
$file= file_get_contents($url);
$json = json_decode($file);
$rows = $json->{'feed'}->{'entry'};
foreach($rows as $row) {
echo '<p>';
@douglasmiranda
douglasmiranda / get-latest-videos.js
Created September 21, 2011 15:05
Get latest videos from Youtube with Jquery (Gdata API)
function show_my_videos(data){
html = ['<ul id="youtube-videos">'];
$(data.feed.entry).each(function(entry){
url = this.link[0].href;
url_thumbnail = this.media$group.media$thumbnail[3].url;
description = this.media$group.media$description.$t;
html.push('<li><a href="'+url+'">');
html.push('<img src="'+url_thumbnail+'" alt="'+description+'">');
html.push('</a></li>');
});
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@jsvine
jsvine / draft.md
Created August 8, 2012 14:56
Why I love Tabletop.js but don't use it in production

Tabletop.js is a fantastic, open-source JavaScript library that lets developers easily integrate data from Google Spreadsheets into their online projects. I've used it, even contributed a minor feature, and love it for prototyping. Non-programmers love being able to update a project via Google Spreadsheets' hyper-intuitive interface.

That said, I'm extraordinarily wary of using Tabletop in production. Instead, at the Wall Street Journal, we use a bit of middleware to "prune" our Google Spreadsheets-based data and then cache it on our own servers. A few brief reasons:

@rewfergu
rewfergu / googleDocImport.php
Created November 30, 2012 21:48
Import contents of a Google Doc into a page
<?php
// Based on http://www.realisingdesigns.com/2009/10/29/using-google-docs-as-a-quick-and-easy-cms/
// Specify document ID
$gd_doc = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$gd_array = array();
$gd_array["url"] = "https://docs.google.com/document/pub?id=".$gd_doc;
$gd_array["start"] = '<div id="contents">';
@cdnsteve
cdnsteve / facebook_user_likes_page_check.js
Created December 6, 2012 16:57
JavaScript: Facebook check if user likes page
/* Source: http://stackoverflow.com/questions/5093398/how-to-check-if-a-user-likes-my-facebook-page-or-url-using-facebooks-api
*/
function parsePageSignedRequest() {
if (isset($_REQUEST['signed_request'])) {
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
@mallocator
mallocator / wikipedia.custom.css
Last active March 23, 2024 08:45
Custom CSS to make wikipedia look a little more readable based on css styles of medium.com. Sizes work for me on a macbook and windows with 1080p display. Used with MonoBook preset in appearance preferences.
body {
padding: 0 10%;
}
p {
text-align: left;
font-size: 18px;
letter-spacing: 0.08px;
line-height: 26px;
word-wrap: break-word;
@nathansmith
nathansmith / [1] convertToMarkup.js
Last active November 16, 2023 12:43
Handy utilities for dealing with `<div contenteditable="true">` areas.
// Helpers.
import { convertToText } from './';
/*
You would call this when receiving a plain text
value back from an API, and before inserting the
text into the `contenteditable` area on a page.
*/
const convertToMarkup = (str = '') => {
return convertToText(str).replace(/\n/g, '<br>');
@mdang
mdang / PHP_PDO.md
Last active October 31, 2023 07:36
Lesson: PHP - PDO

PHP - PDO

Learning Objectives

  • Explain what PDO is and it's role in accessing data
  • Explain how to set up environment variables using PHP dotenv
  • Explain how to establish and destroy database connections
  • Describe what prepared statements are
  • Explain how to bind parameters to safely form SQL queries
  • Explain how to get the new ID generated from an insert statement
@razbomi
razbomi / gulpfile.js
Created November 16, 2016 23:19
Gulp pipe function
'use strict';
var gulp = require('gulp');
var through = require('through2');
// https://gulp.readme.io/docs
gulp.task('default', () => {
gulp.src('src/**/*')
.pipe(pipeFunction())
.pipe(gulp.dest('dist'))