This gist and its comments contains some topics for technology section of data weekly
An error occurred while installing nokogiri | |
(1.8.0), and Bundler cannot continue. | |
Make sure that `gem install nokogiri -v '1.8.0' | |
--source 'https://rubygems.org/'` succeeds before | |
bundling. |
import numpy as np | |
import plotly.offline as pyo | |
import plotly.graph_objs as go | |
# Generate a random signal | |
np.random.seed(42) | |
random_signal = np.random.normal(size=100) | |
# Offset the line length by the marker size to avoid overlapping | |
marker_offset = 0.04 |
I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.
But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.
Svelte is a language.
Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?
A few projects that have answered this question:
// [START apps_script_bigquery_update_sheet] | |
/** | |
* Runs a BigQuery query and replace the existing sheet | |
*/ | |
/** | |
* Add a custom menu to the spreadsheet when it is opened. | |
*/ | |
function onOpen() { | |
var spreadsheet = SpreadsheetApp.getActive(); |
Given a Parent
class with value
property, Child
can inherit and overload the property while accessing Parent
property getter and setter.
Although we could just reimplement the Child.value
property logic completely without using Parent.value
whatsover, this would violate the DRY principle and, more important, it wouldn't allow for proper multiple inheritance (as show in the example property_inheritance.py
bellow).
Two options:
Child
redefinesvalue
property completely, both getter and setter.
require 'base64' | |
require 'digest' | |
require 'openssl' | |
require 'fileutils' | |
module Jekyll | |
class ProtectedPage < Page | |
def aes256_encrypt(password, cleardata) | |
digest = Digest::SHA256.new | |
digest.update(password) |
from sshtunnel import SSHTunnelForwarder | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
from functools import wraps | |
# secrets.py contains credentials, etc. | |
import secrets | |
def get_engine_for_port(port): | |
return create_engine('postgresql://{user}:{password}@{host}:{port}/{db}'.format( |
window_size = 2 | |
idx_pairs = [] | |
# for each sentence | |
for sentence in tokenized_corpus: | |
indices = [word2idx[word] for word in sentence] | |
# for each word, threated as center word | |
for center_word_pos in range(len(indices)): | |
# for each window position | |
for w in range(-window_size, window_size + 1): | |
context_word_pos = center_word_pos + w |
# An example to get the remaining rate limit using the Github GraphQL API. | |
import requests | |
headers = {"Authorization": "Bearer YOUR API KEY"} | |
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section. | |
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers) | |
if request.status_code == 200: |