Skip to content

Instantly share code, notes, and snippets.

Folders

  • A folder is a file with the MIME type application/vnd.google-apps.folder and with no extension.
  • You can use the alias root to refer to the root folder anywhere a file ID is provided
  • To insert a file in a particular folder, specify the correct ID in the parents property of the file.
  • The parents property can be used when creating a folder as well to create a subfolder.
  • To add or remove parents for an exiting file, use the addParents and removeParents query parameters by calling PATCH https://www.googleapis.com/drive/v3/files/${fileId}

Files

  • When creating a batch of files, you can preallocate up to 1,000 UUIDs for use in create requests by calling GET https://www.googleapis.com/drive/v3/files/generateIds?count=${count}&space=drive This does not work when copying files.
  • All you need is the fileId to copy a file. It does not matter whether or not the document was created by a user of the destination Google Apps domain.
@jmealo
jmealo / spread.xml
Last active December 21, 2015 07:18
Spread SMF manifest for the pkgsrc distribution on SmartOS (based off: evercity's manifest)
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/spread' type='service' version='0'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency name='fs-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='network-service' grouping='require_all' restart_on='none' type='service'>
@jmealo
jmealo / wackamole.xml
Created August 19, 2013 14:20
Wackamole SMF manifest for the pkgsrc distribution on SmartOS (based on everycity's manifest)
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/wackamole' type='service' version='0'>
<dependency name='filesystem_minimal' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/minimal'/>
</dependency>
<dependency name='loopback' grouping='require_any' restart_on='error' type='service'>
<service_fmri value='svc:/network/loopback'/>
</dependency>
@jmealo
jmealo / extract-progress.py
Last active December 21, 2015 06:28
Extracts .tar, .tar.gz, .tar.bz2 and .zip files with an optional progress bar. Raises ExtractException when it encounters an error.
import os, re, commands, subprocess
def streamCommand(cmd):
# runs a shell command and returns stdout as a stream you can loop over
stdout = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout
return stdout
def getFileExtension(filename):
@jmealo
jmealo / prep-env.sh
Last active December 21, 2015 01:59
Script to prepare environment in SmartOS Zone or Ubuntu VM before installing software
#!/bin/bash
# To run:
# source <(curl -s https://gist.github.com/jmealo/6231713/raw)
# note: running it this way renders the network configuration tests superfluous
if [[ "$(uname)" = "SunOS" ]] ; then
OS="SMARTOS"
elif [[ -f /etc/debian_version ]]; then
OS="DEBIAN"
crime_enum = {
'Aggravated Assault Firearm': 0,
'Aggravated Assault No Firearm': 1,
'Burglary Non-Residential': 2,
'Burglary Residential': 3,
'Homicide - Criminal ': 4,
'Homicide - Criminal': 4,
'Homicide - Gross Negligence': 5,
'Homicide - Justifiable ': 6,
'Motor Vehicle Theft': 7,
sw=# EXPLAIN ANALYZE SELECT ST_Distance(ST_Transform(ST_GeomFromText('POINT(-75.211457 39.956314)', 4326), 900913), planet_osm_line.way) AS planar_degrees, name FROM planet_osm_line ORDER BY planar_degrees ASC LIMIT 2;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
Limit (cost=4719.15..4719.15 rows=2 width=600) (actual time=39.156..39.157 rows=2 loops=1)
-> Sort (cost=4719.15..4758.76 rows=15845 width=600) (actual time=39.154..39.154 rows=2 loops=1)
Sort Key: (st_distance('010100002031BF0D005777154645F05FC15B189DFEB2895241'::geometry, way))
Sort Method: top-N heapsort Memory: 25kB
-> Seq Scan on planet_osm_line (cost=0.00..4560.70 rows=15845 width=600) (actual time=0.028..33.340 rows=15845 loops=1)
Total runtime: 39.186 ms
(6 rows)
@jmealo
jmealo / philadelphia.poly
Created April 20, 2013 23:47
Poly file for the city of Philadelphia
city_limits_0
1
-7.501497E+01 4.013793E+01
-7.501456E+01 4.013768E+01
-7.501401E+01 4.013735E+01
-7.501387E+01 4.013726E+01
-7.501223E+01 4.013626E+01
-7.501146E+01 4.013578E+01
-7.501062E+01 4.013527E+01
-7.501043E+01 4.013515E+01
@jmealo
jmealo / gist:5417527
Created April 19, 2013 01:40
MongoError: Can't extract geo keys from object, malformed geometry?:
{
"type": "LineString",
"coordinates": [
[
-75.43241,
40.122597
],
[
-75.432447,
40.122651
{
"brand": "joyent",
"image_uuid,": "7abad50e-b865-11e0-8462-730bcfdde020d",
"alias": "pgbench",
"hostname": "pgbench",
"max_physical_memory": 16384,
"nics": [
{
"nic_tag": "admin",
"ip": "76.8.51.210",