Skip to content

Instantly share code, notes, and snippets.

suntong

Block or report user

Report or block suntong

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Google Doc to HTML.js
/*
Convert GoogleDoc To HTML (on Google Drive )
Converting a Google Document to simple HTML
http://collaborative-tools-project.blogspot.co.uk/2013/06/converting-google-document-to-simple.html
*/
function test_convertGoogleDoc(){
View Find & replace in files within a folder using Google Apps Script.js
// Iterate through the file iterator for a particular folder
function iterateFolderById() {
var files = DriveApp.getFolderById("0B5eEwPQVn6GOaUt6Vm1GVjZmSTQ").getFiles();
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
var doc = DocumentApp.openById(file.getId());
doc.replaceText("My search string or regex", "My replacement string");
}
@suntong
suntong / Move a Google Doc into another folder.js
Last active Dec 31, 2015
move a Google Doc into another folder
View Move a Google Doc into another folder.js
/*
How do I move a file to a folder in Google Apps Script?
http://stackoverflow.com/questions/14696514/how-do-i-copy-move-a-file-to-a-folder-in-google-apps-script
Yeah, it is a bit odd that Google does not provide a move method.
But, considering how drive works and that a file can belong to
multiple folders, it makes some sense that you have write your own moves.
I should note that this simple function is exactly that ... simple.
@suntong
suntong / GetFoldersByName.js
Last active Jul 21, 2018
Get folder ID by its name
View GetFoldersByName.js
// Get the *first* folder ID by its name
function getFolderByName(folderName) {
var folders = DriveApp.getFoldersByName(folderName);
var folderID = null;
if (folders.hasNext())
folderID = folders.next();
return folderID;
}
View GDocs2MD.js
/*
Usage:
Adding this script to your doc:
- Tools > Script Manager > New
- Select "Blank Project", then paste this code in and save.
Running the script:
- Tools > Script Manager
- Select "ConvertToMarkdown" function.
- Click Run button.
- Converted doc will be mailed to you. Subject will be "[MARKDOWN_MAKER]...".
@suntong
suntong / Google-Picker_Docs.js
Created Dec 20, 2013
Google Picker for Google Docs
View Google-Picker_Docs.js
// http://stackoverflow.com/questions/20599404/google-picker-for-google-drive
function doGet() {
var app = UiApp.createApplication();
var selectCkH = app.createServerHandler('selectFile');
var closeHandler = app.createServerHandler('closeDocsPicker');
var docsDialog = app.createDocsListDialog().showDocsPicker()//.setInitialView(google.picker.ViewId.FOLDERS)
// .addView(new google.picker.PhotosView()
// .setType(google.picker.PhotosView.Type.FEATURED))
.addCloseHandler(closeHandler)
View JavaByExample.java
"two\nlines"
"\"This is in quotes\""
int d = 3, e, f = 5;
byte z = 22;
double pi = 3.14159;
char x = 'x';
z = (byte) f;
@suntong
suntong / test06.sh
Created Feb 1, 2014
overlayfs: mounting overlayfs on top of overlayfs
View test06.sh
#!/bin/sh
# http://article.gmane.org/gmane.linux.file-systems/54764
#
# The script (test06.sh) makes a read-only overlayfs mount on top of
# another readonly overlayfs mount, repeating this in a loop,
#
# when all the read-only filesystems are mounted, then it mounts another
# overlayfs that uses the last read-only rootdir as lowerdir and a read-write
# filesystem in upperdir,
View main.go
// http://play.golang.org/p/FOe85j-O-n
package main
import (
"fmt"
"os"
"time"
)
View gist:9cb494214aea24c2c5ff

Challenge: select all the people that are:

  • in the 3rd class
  • under age 10
  • female

A:

train[(train['Age'] < 10) & (train['pclass'] == 3) & (train['sex'] == "female")]
You can’t perform that action at this time.