Skip to content

Instantly share code, notes, and snippets.

View rcknr's full-sized avatar

Sergii Kauk rcknr

View GitHub Profile
@rcknr
rcknr / gist:1043690
Created June 23, 2011 21:34
Quick add event to Calendar using GData
// Set the feed URL
var EVENT_FEED_URL = 'http://www.google.com/calendar/feeds/default/private/full';
// Create a calendar object
var calendarService = new google.gdata.calendar.CalendarEventEntry();
// Create a new event handler
var quickEvent = new google.gdata.calendar.CalendarEventEntry();
// Create a new property handler and set it to true
@rcknr
rcknr / csv2array.php
Created October 2, 2015 22:55
Convert a CSV file to an associative array
<?php
$source = file('http://example.com/example.csv');
$csv_array = array_map('str_getcsv', $source, array_fill(0, count($source), ';'));
$header = array_shift($csv_array);
$result = array_map('array_combine', array_fill(0, count($csv_array), $header), $csv_array);
?>
@rcknr
rcknr / Code.gs
Created August 30, 2012 08:35
Apps Script Release Notes RSS Feed
function getFeed() {
var cache = CacheService.getPublicCache();
var cachedFeed = cache.get("gas-relnotes-feed");
if(cachedFeed == null) {
var URL = "https://developers.google.com/apps-script/release_notes";
var feedSize = 25;
var data = UrlFetchApp.fetch(URL).getContentText();
@rcknr
rcknr / Tweetsheets
Created November 22, 2012 16:57 — forked from johannesnagl/Tweetsheets
Use Twitter directly in your Google Doc, so no one will ever blame you for being social
function authorize_(method) {
var oauthConfig = UrlFetchApp.addOAuthService("twitter");
oauthConfig.setAccessTokenUrl("https://api.twitter.com/oauth/access_token");
oauthConfig.setRequestTokenUrl("https://api.twitter.com/oauth/request_token");
oauthConfig.setAuthorizationUrl("https://api.twitter.com/oauth/authorize");
oauthConfig.setConsumerKey(UserProperties.getProperty("CONSUMER_KEY"));
oauthConfig.setConsumerSecret(UserProperties.getProperty("CONSUMER_SECRET"));
return {
oAuthServiceName: "twitter",
@rcknr
rcknr / Code injection
Last active October 19, 2015 19:04
UI translation (i18n) for Squarespace
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.min.js"></script>
<script>
Y.use('node', 'node-load', function(Y) {
Y.on('domready', function() {
/* Locale to use with moments.js */
var locale = 'de_AT';
/* Format blog entries published dates */
Y.all('time.published').each(
function() {
@rcknr
rcknr / Viewer.gs
Created December 16, 2012 23:03
ScriptDb Viewer for Apps Script allows to inspect the contents of ScriptDb, run queries and sort stored objects. Works with scripts attached to a spreadsheet but can be also converted into a web app.
function showDbViewer() {
var DbViewer = UiApp.createApplication().setTitle('ScriptDb Viewer');
// Query field and button
DbViewer.add(
DbViewer.createHorizontalPanel().setVerticalAlignment(UiApp.VerticalAlignment.MIDDLE).add(
DbViewer.createTextBox().setText("{}").setId("query").setName("query"))
.add(
DbViewer.createButton("Query", DbViewer.createServerHandler("queryDb")
.addCallbackElement(DbViewer.getElementById("query")))
@rcknr
rcknr / UploadWithMedia.gs
Created July 27, 2013 18:04
Update Twitter status with an image with a single request in Apps Script
function oAuthConfig() {
var oAuthConfig = UrlFetchApp.addOAuthService("twitter");
oAuthConfig.setAccessTokenUrl("http://api.twitter.com/oauth/access_token");
oAuthConfig.setRequestTokenUrl("http://api.twitter.com/oauth/request_token");
oAuthConfig.setAuthorizationUrl("http://api.twitter.com/oauth/authorize");
// Register an app at https://dev.twitter.com/apps/new to get the following key and secret
oAuthConfig.setConsumerKey("key");
oAuthConfig.setConsumerSecret("secret");
}
@rcknr
rcknr / README.md
Last active May 4, 2016 20:21 — forked from kaezarrex/README.md
GTFS Viewer

Upload a GTFS file that contains shapes.txt. Example GTFS files can be found at the GTFS Data Exchange.

@rcknr
rcknr / Translate.gs
Created December 29, 2012 18:47
Google Apps Script wrapper for Translate API Limitations: - Doesn't return detectedSourceLanguage when called without source parameter; - Doesn't support prettyprint parameter; - Reduced error messages that return HTTP 200 status; - Doesn't support key parameter and billing ;)
function doGet(r) {
var translations = [];
var e = {error:{code:400}};
try {
if(r.parameters.q) {
for(var n in r.parameters.q) {
translations.push({translatedText:
LanguageApp.translate(
r.parameters.q[n],
(r.parameters.source)?r.parameters.source:null,
@rcknr
rcknr / gist:3306363
Created August 9, 2012 17:43
Update Twitter avatar with Apps Script
function oAuthConfig() {
var oAuthConfig = UrlFetchApp.addOAuthService("twitter");
oAuthConfig.setAccessTokenUrl("http://api.twitter.com/oauth/access_token");
oAuthConfig.setRequestTokenUrl("http://api.twitter.com/oauth/request_token");
oAuthConfig.setAuthorizationUrl("http://api.twitter.com/oauth/authorize");
// Register an app at https://dev.twitter.com/apps/new to get the following key and secret
oAuthConfig.setConsumerKey("PUT CONSUMER KEY HERE");
oAuthConfig.setConsumerSecret("PUT CONSUMER SECRET HERE");
}