Skip to content

Instantly share code, notes, and snippets.

View cinaglia's full-sized avatar

Victor Cinaglia cinaglia

View GitHub Profile
@cinaglia
cinaglia / keys.json
Created August 18, 2022 22:51
hackathon-2022-08-the-toucans
{
"public_keys": [
{
"key_identifier": "dev",
"key": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEbheZKeU4vhEfMaQBVeSXpitsX2kw1b5k\nwPmCX7xB8cfhs4TcdqIB7T6XX7/bRsamc+aujJyPo7xi7vvOrMpHnmZBfyYDiidK\ndgJeC5zVI5d9gUezUSVM0rYd+JFoVgfe\n-----END PUBLIC KEY-----",
"is_current": true
}
]
}
@cinaglia
cinaglia / cloudsql-bq.sql
Last active June 11, 2021 14:47
Cloud SQL & BigQuery Sync
-- Check if table exists. If it does, compare schemas.
-- If schema is equal, then perform updates
-- If schema is different, CREATE OR REPLACE
-- Store schema for comparison
CREATE OR REPLACE TABLE `temp.users_schema` AS
SELECT * FROM EXTERNAL_QUERY(
'bigquery-exploration-278323.us.bigquery-exploration',
'DESCRIBE users;'
@cinaglia
cinaglia / TableHead.js
Created February 1, 2019 20:36
Sortable TableHead API
<TableHead
activeKey={currentKey}
direction={currentDirection}
onSort={({ key, direction }) => { console.log(key, direction); }}
>
<TableHead.Item>Id</TableHead.Item>
<TableHead.Sortable key="type">Type</TableHead.Sortable>
<TableHead.Sortable key="slug">Slug</TableHead.Sortable>
<TableHead.Item>Name</TableHead.Item>
<TableHead.Item>URL</TableHead.Item>
@cinaglia
cinaglia / index.js
Last active December 30, 2018 16:28
Check if a date is within a given range (e.g. Friday 10pm – Monday 8am).
const hourConvert = require('hour-convert')
const dayToInteger = day =>
Number.isInteger(day)
? day
: {
Monday: 0,
Tuesday: 1,
Wednesday: 2,
Thursday: 3,
@cinaglia
cinaglia / consumer.py
Last active June 11, 2021 14:48
Python consumer that watches for unprocessed tennis matches and publishes results to social media profiles.
import argparse
import collections
import logging
import logging.config
import pkg_resources
import sys
import tempfile
import time
from bs4 import BeautifulSoup
@cinaglia
cinaglia / keybase.md
Created October 27, 2018 14:26
Keybase proof

Keybase proof

I hereby claim:

  • I am cinaglia on github.
  • I am cinaglia (https://keybase.io/cinaglia) on keybase.
  • I have a public key ASAzWVQyMAllME3hYtOBLvT7JPRKHT7XuPey9SpX4Jw_bAo

To claim this, I am signing this object:

@cinaglia
cinaglia / player_images.py
Created October 17, 2018 14:33
Scrapy spider to extract images from all ATP players currently ranked.
# -*- coding: utf-8 -*-
import itertools
import random
import scrapy
import queries
from .utils import extract_player_id_and_slug, extract_and_strip
@cinaglia
cinaglia / EditableField.js
Last active October 17, 2018 14:38
Proof-of-concept of an editable field React component that tracks number of characters and notifies when it exceeds a given threshold.
import React, { Component } from 'react';
import './App.css';
const noop = () => {};
const Personalization = ({ items, onChange }) => (
<select onChange={ (e) => onChange(e.target.value) }>
<option value="" disabled>Personalize</option>
{ items.map(({ key, name }) =>
<option value={key} key={key}>{name}</option>) }
@cinaglia
cinaglia / scout.js
Created October 30, 2015 18:59
Scout File
;(function(document) {
'use strict';
var script = document.createElement('script'),
scripts = document.getElementsByTagName('script'),
scoutIndex = scripts.length - 1,
fScript = scripts[0],
style = document.createElement('link'),
head = document.getElementsByTagName('head')[0],
domain,
@cinaglia
cinaglia / respawner.py
Created November 25, 2013 01:01
Snippet that watches itself for changes and automatically re-spawns
# https://github.com/cmheisel/pywatch
import sys, os
from watcher import Watcher
args = sys.argv[:]
def respawn():
print 'Re-spawning %s' % ' '.join(args)
args.insert(0, sys.executable)
os.execv(sys.executable, args)