A Pen by tanyagupta on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Standard set up for the express code to work with your code | |
var express = require('express'); | |
var app = express(); | |
/* | |
Routes a get request, and in this simple case - to the server's root. It sends a | |
call back to handle the request. Not much will happen here, the call back is hardcoded | |
to send a hello world string. But in theory you can do something with the req variable | |
in the "/" directory, create a dynamic html and send that back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var content = fs.readFile(process.argv[2],function(err,data){ | |
if(err){ | |
console.log('error'); | |
} | |
var lines=data.toString().split('\n'); | |
console.log(lines.length-1); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
responsive_images:{ | |
myTask:{ | |
options:{}, /* left blank to keep it simple */ | |
files:[{ | |
expand:true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet() { // this starts the Google Apps server | |
var template = HtmlService.createTemplateFromFile('extract_text_from_youtube'); | |
var title_string='Get transcript from Udacity Video'; | |
return template.evaluate() | |
.setTitle(title_string).setSandboxMode(HtmlService.SandboxMode.IFRAME); | |
} | |
function getTranscript(id){ | |
var resp = UrlFetchApp.fetch("http://video.google.com/timedtext?lang=en&v="+id) //UrlFetchapp to avoid ajax issues related to CORS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var path = require('path') | |
fs.readdir(process.argv[2], function (err, list) { | |
list.forEach(function (file) { | |
if (path.extname(file) === '.' + process.argv[3]) | |
console.log(file) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test_and(){ | |
var cars=[ | |
{make: "Jeep",model: "Cherokee",trim:"Sport 4dr Front-wheel Drive",year:"2016",wheel:{wheel_size:"17 x 7.5",wheel_metal:"Aluminum"}}, | |
{make: "Jeep",model: "Wrangler",trim:"Sahara 2dr 4x4",year: "2015"} | |
] | |
for (var i in cars){ | |
if (cars[i]["wheel"] && cars[i]["wheel"]["wheel_size"]){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function item_in_array(){ | |
var fruits = ["Bob", "Rob", "Amanda", "Cheryl","Susan"]; | |
Logger.log(fruits.indexOf("Susan")) //returns 4 which is the index of Susan | |
Logger.log(fruits.indexOf("Frank")) //returns -1 since the item is not found | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function zd_get (cmd) { | |
var url = ZD_BASE+cmd; | |
var results =[]; | |
var service = getService(); | |
if (service.hasAccess()) { | |
do { | |
try { | |
var response = UrlFetchApp.fetch(url, {headers: {'Authorization': 'Bearer ' + service.getAccessToken(),}}); | |
} |
NewerOlder