Skip to content

Instantly share code, notes, and snippets.

View emptymalei's full-sized avatar
📡
sending EM waves to Mars

LM emptymalei

📡
sending EM waves to Mars
View GitHub Profile
@xiaohanyu
xiaohanyu / data-weekly-technology-list.md
Last active May 11, 2019 06:38
Data-weekly technology section list

This gist and its comments contains some topics for technology section of data weekly

@emptymalei
emptymalei / error message installing nokogiri
Last active May 8, 2019 18:10
gem install nokogiri problem
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.
@caiotaniguchi
caiotaniguchi / lollipop_plotly.py
Last active January 18, 2022 16:19
Plotting Lollipop Charts with Plotly
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
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 27, 2024 06:09
The truth about Svelte

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();
@Susensio
Susensio / property_inheritance.md
Last active April 19, 2024 00:42
Inherit property setter in python 3.7

Python @property inheritance the right way

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 redefines value 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)
@danallison
danallison / with_sql_session.py
Last active April 23, 2024 07:32
Connect to Postgresql locally or through SSH tunnel
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
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# 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: