Skip to content

Instantly share code, notes, and snippets.

var infoBubble = new InfoBubble({
padding: 10,
borderRadius: 4,
arrowSize: 0,
arrowPosition: 30,
arrowStyle: 2
});
for(var i=0;i<data.length;i++)
{
for(var i=0;i<data.length;i++)
{
var lat = data[i].latitude;
var lng = data[i].longitude;
var latLng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({map: map, position: glatLng});
markersArray.push(marker);
// Set an attribute on the marker, it can be named whatever...
marker.html = '<div>My content goes here for ['+lat+', '+lng+']</div>';
var markersArray = [];
// For sake of simplicity, I'm assuming you're using jQuery
// data variable that contains latitudes and longitudes of positions
for(var i=0; i<data.length; i++){
var glatLng = new google.maps.LatLng(data[i].latitude, data[i].longitude);
var marker = new google.maps.Marker({map: map, position: glatLng});
markersArray.push(marker);
var $p = $('<p />');
def get_token_and_login_url(self, redirect_uri):
"""Gets the oAuth token via the oauth2 library."""
data = urllib.urlencode({'oauth_callback': redirect_uri if redirect_uri else 'oob'})
$fh = fopen($box->download_url('862161200'), 'r'); // Open box.net file
$tmp = tempnam('/tmp', uniqid().'.docx'); // create tmp file
print_r($tmp);
echo '<br />';
$tfh = fopen($tmp, 'w');
fwrite($tfh, fread($fh, 13421772)); // write bytes from box.net file to tmp file
fseek($tfh, 0);
// Then load tmp file into ZipArchive->open() and use this function:
http://www.botskool.com/geeks/how-extract-text-docx-or-odt-files-using-php
@michaelhelmick
michaelhelmick / postimage.py
Created January 4, 2012 02:17
Post an image to API with Python OAuth
'''encode_multipart_formdata taken from @ryanmcgrath `twython`'''
def post_image(self):
files = [("photo", 'image.jpg', open('/path/to/image.jpg', 'rb').read())]
params = {
'oauth_version': "1.0",
'oauth_nonce': oauth.generate_nonce(),
'oauth_timestamp': int(time.time()),
'oauth_token': self.oauth_token,
@michaelhelmick
michaelhelmick / oauth2.py
Created January 7, 2012 17:03
Python OAuth2 - Return to_header() in alpha order without "oauth_body_hash"
def to_header(self, realm=''):
"""Serialize as a header for an HTTPAuth request."""
oauth_params = ((k, v) for k, v in self.items()
if k.startswith('oauth_'))
stringy_params = ((k, escape(str(v))) for k, v in oauth_params)
abc_params = {}
for k, v in stringy_params:
if k == 'oauth_body_hash':
@michaelhelmick
michaelhelmick / twythonupload.py
Created January 12, 2012 23:22
Upload Image with Twython
def updateProfileImage(self, filename, version = 1):
""" updateProfileImage(filename)
Updates the authenticating user's profile image (avatar).
Parameters:
image - Required. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
params = {
@michaelhelmick
michaelhelmick / googlemaps.php
Created January 17, 2012 15:58
google api v3
<?php foreach($this->searchResult as $result): ?>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(<?php echo $result['Latitude'];?>,<?php echo $result['Longitude']; ?>);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
@michaelhelmick
michaelhelmick / googlemapsv3.php
Created January 17, 2012 20:16
Google Map v3 API multiple markers
<script>
var infowindow = null;
var markerArray = [];
var bounds: new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById("map_canvas"), {zoom: 4,mapTypeId: google.maps.MapTypeId.ROADMAP});
function set_marker(lat, lng){
var position = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({map: map, position: position});