Skip to content

Instantly share code, notes, and snippets.

@mvark
mvark / YahooWeatherViaYQL&JSONP
Last active June 29, 2016 14:44
Get Weather information for a WOEID using YQL, jQuery
<!DOCTYPE html>
<html>
<head>
<title>Weather Forecast using YQL</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
//Developer notes - http://mvark.blogspot.in/2013/03/how-to-find-weather-information-for.html
//use YQL Console to build query - http://developer.yahoo.com/yql/console/
function getWeather(woeid, unit) {
@mvark
mvark / gist:5357137
Last active December 16, 2015 01:39
Show book titles in Amazon ads by keyword
<!DOCTYPE html>
<html>
<head>
<title>Show book titles in Amazon ads by keyword</title>
</head>
<body>
<div id="amz"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$(document).ready(function () {
@mvark
mvark / gist:5373959
Last active December 16, 2015 03:59
JS snippet shows how to get local time for a location based on its latitude and longitude using World Weather Online's Time Zone API -http://www.worldweatheronline.com/time-zone-api.aspx
function time(lat, long) {
//replace the value for the key parameter with your own
var url = "http://api.worldweatheronline.com/free/v1/tz.ashx?q=" + lat + "," + long + "&format=json&key={key}&callback=tfunc";
//reference to jQuery library is required prior to using this function
$.getScript(url, function (response) { });
}
window.tfunc = function (response) {
var time = "";
@mvark
mvark / gist:7040359
Last active December 25, 2015 21:09
Sample shows how to highlight a Province within a Country (India) with Google GeoChart. Notes: http://mvark.blogspot.in/2013/10/how-to-highlight-province-within.html
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
//Based on this original sample - http://jsfiddle.net/asgallant/wwDyU/1/
function drawChartIN () {
var data = new google.visualization.DataTable();
data.addColumn('string', 'INState');
Option Explicit
'References:
'http://stackoverflow.com/questions/19071173/ms-word-macro-how-to-adapt-so-it-get-data-from-my-excel-file
'http://www.mrexcel.com/forum/excel-questions/32187-convert-variant-array-string-array.html
Dim TargetList() As String
Public Sub GetWordsFromExcelAndHighlight()
Dim lngIndex As Long
@mvark
mvark / PSDownloadFiles
Last active August 29, 2015 13:57
PowerShell script to download a list of files that have a predictable number pattern
# PowerShell script to download a list of files that have a predictable number pattern
for ($i=1; $i -le 10; $i++)
{
$startTime = (Get-Date)
# Download files that have the naming format File1.txt, File2.txt etc..
(new-object System.Net.WebClient).DownloadFile("http://example/file$i.txt","C:\temp\file$i.txt")
$endTime = (Get-Date)
# Echo Time taken
"Time taken to download file$i : $(($endTime-$startTime).totalseconds) seconds"
}
javascript:(function()%7Bdocument.getElementById(%22txtInput%22).value%3Ddocument.getElementById(%22txtCaptcha%22).value%7D)()
@mvark
mvark / StoreMinMaxTempIntoAzureTable.ps1
Created May 14, 2014 13:56
This PowerShell script to save min, max temperature fetched from Yahoo Weather API using YQL & store it in Windows Azure Table
Add-Type -Path "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.1\ref\Microsoft.WindowsAzure.Storage.dll"
$refs = @("C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll")
$code = @"
using System;
using System.Data.Services.Common;
[DataServiceEntity]
javascript:(function() {
a = document.getElementsByTagName('a');
for (i = 0; i < a.length; i++) {
a[i].href = 'http://www.google.com/gwt/x?noimg=1&btnGo=Go&source=wax&ie=UTF-8&oe=UTF-8&u=' + encodeURIComponent(a[i].href);
a[i].style.backgroundColor = '#f0f0f0';
@mvark
mvark / TransformJSONFieldNamesForFullCalendar.js
Last active June 5, 2018 21:30
Transform JSON field names in feed to match FullCalendar jQuery plugin's Event format
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultDate: '2014-11-13',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: function (start, end, timezone, callback) {
$.ajax({
url: "http://example.azure-mobile.net/tables/event?$filter=eventdate gt '" + start.toISOString() + "' and eventdate lt '" + end.toISOString() + "'",
dataType: 'json',
beforeSend: setHeader,