Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
@lgs
lgs / active.md
Created June 13, 2017 19:23 — forked from paulmillr/active.md
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Fri, 19 Jun 2015 15:17:38 GMT till Sun, 19 Jun 2016 15:17:38 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user => user.followers > 635)
@lgs
lgs / query.sql
Created June 12, 2017 19:29 — forked from abo-abo/query.sql
Use https://developers.google.com/bigquery/ to select top 100 repos by number of commits
select repository_name, count(repository_name) as pushes, repository_description, repository_url
from [githubarchive:github.timeline]
where type="PushEvent"
and repository_language="Emacs Lisp"
and parse_utc_usec(created_at) >= parse_utc_usec('2014-01-01 00:00:00')
group by repository_name, repository_description, repository_url
order by pushes desc
limit 100
@lgs
lgs / BigQuery2GSheets.js
Created June 12, 2017 19:16 — forked from greenido/BigQuery2GSheets.js
An Apps script example to fetch data form Big query to google spreadsheets. For more: http://wp.me/pB1lQ-19i
/**
* Fetching data from BigQuery and present it in our sheet
* Author: Ido Green
* Date: 14/12/2013
*
* See: http://wp.me/pB1lQ-19i
* Misc: https://developers.google.com/bigquery/
*/
//
@lgs
lgs / drive-appscript.js
Created June 12, 2017 19:08 — forked from igrigorik/drive-appscript.js
Sample BigQuery queries for the HTTP Archive dataset.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Run Query", functionName: "runQuery"} ];
ss.addMenu("HTTP Archive + BigQuery", menuEntries);
}
function runQuery() {
var projectNumber = 'httparchive';
var sheet = SpreadsheetApp.getActiveSheet();
@lgs
lgs / schema-generator.js
Created June 12, 2017 17:17 — forked from oyvindholmstad/schema-generator.js
BigQuery JSON schema generator in Javascript and Scala
/*
A script to generate a Google BigQuery-complient JSON-schema from a JSON object.
Make sure the JSON object is complete before generating, null values will be skipped.
References:
https://cloud.google.com/bigquery/docs/data
https://cloud.google.com/bigquery/docs/personsDataSchema.json
https://gist.github.com/igrigorik/83334277835625916cd6
... and a couple of visits to StackOverflow
@lgs
lgs / json-bq-schema-generator.rb
Created June 12, 2017 17:16 — forked from igrigorik/json-bq-schema-generator.rb
BigQuery JSON schema generator
require 'open-uri'
require 'zlib'
require 'yajl'
# References
# - https://developers.google.com/bigquery/preparing-data-for-bigquery#dataformats
# - https://developers.google.com/bigquery/docs/data#nested
#
def type(t)
let axios = require('axios'); // HTTP client
let cheerio = require('cheerio'); // HTML parsing package
let jsonframe = require('jsonframe-cheerio'); // a cheerio plugin I designed
let fs = require('fs'); // is included in node.js - you don't need to install it
axios.get('https://www.producthunt.com')
.then((response) => {
if(response.status === 200) {
@lgs
lgs / active-issues.sql
Created March 29, 2017 04:11 — forked from alysonla/active-issues.sql
Queries that power the open source section of the 2016 Octoverse report https://octoverse.github.com/
-- Active issues
-- Count of total active issues in the specified time frame
-- Source: githubarchive public data set via Google BigQuery http://githubarchive.org/
SELECT
COUNT(DISTINCT JSON_EXTRACT_SCALAR(events.payload, '$.issue.id')) AS events_issue_count
FROM (SELECT * FROM TABLE_DATE_RANGE([githubarchive:day.],TIMESTAMP('2015-09-01'),TIMESTAMP('2016-08-31')))
AS events
-- 10,723,492 active issues
@lgs
lgs / scraper.rb
Created March 25, 2017 14:32 — forked from heyellieday/scraper.rb
Medium Web Scraper
require "mechanize"
require "nokogiri"
require 'json'
require "awesome_print"
def get_latest
url = "http://medium.com/@heyellieday"
agent = Mechanize.new { |agent| agent.user_agent_alias = "Mac Safari" }
html = agent.get(url).body
@lgs
lgs / reddit.html
Created March 22, 2017 22:16 — forked from sente/reddit.html
An example of a retrieving data from reddit's JSON(p) api using jquery
<!DOCTYPE html>
<!--
Stuart Powers
http://sente.cc/
http://twitter.com/stuartpowers
-->
<html>
<head>