A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| import torch | |
| import torch.nn as nn | |
| from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
| seqs = ['gigantic_string','tiny_str','medium_str'] | |
| # make <pad> idx 0 | |
| vocab = ['<pad>'] + sorted(set(''.join(seqs))) | |
| # make model |
| def _sequence_mask(sequence_length, max_len=None): | |
| if max_len is None: | |
| max_len = sequence_length.data.max() | |
| batch_size = sequence_length.size(0) | |
| seq_range = torch.range(0, max_len - 1).long() | |
| seq_range_expand = seq_range.unsqueeze(0).expand(batch_size, max_len) | |
| seq_range_expand = Variable(seq_range_expand) | |
| if sequence_length.is_cuda: | |
| seq_range_expand = seq_range_expand.cuda() | |
| seq_length_expand = (sequence_length.unsqueeze(1) |
| #!/usr/bin/env python | |
| # -*- coding: UTF-8 -*- | |
| import warnings | |
| import numpy as np | |
| import pandas as pd | |
| import sys | |
| __author__ = "Mohsen Mesgarpour" | |
| __copyright__ = "Copyright 2016, https://github.com/mesgarpour" | |
| __credits__ = ["Mohsen Mesgarpour"] |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| ;; Prevent the cursor from blinking | |
| (blink-cursor-mode 0) | |
| ;; Don't use messages that you don't read | |
| (setq initial-scratch-message "") | |
| (setq inhibit-startup-message t) | |
| ;; Don't let Emacs hurt your ears | |
| (setq visible-bell t) | |
| ;; You need to set `inhibit-startup-echo-area-message' from the | |
| ;; customization interface: |
| #!/bin/bash -e | |
| IFADDR="192.168.3.1/24" | |
| if [[ ! ip link show docker0 ]]; then | |
| ip link add docker0 type bridge | |
| ip addr add "$IFADDR" dev docker0 | |
| ip link set docker0 up | |
| iptables -t nat -A POSTROUTING -s "$IFADDR" ! -d "$IFADDR" -j MASQUERADE | |
| fi |
| // program | |
| package main | |
| import "os/signal" | |
| import "os" | |
| import "fmt" | |
| import "syscall" | |
| import "time" | |
| -- | |
| -- open currently active Chrome tab with Safari | |
| -- forked from https://gist.github.com/3151932 and https://gist.github.com/3153606 | |
| -- | |
| property theURL : "" | |
| tell application "Google Chrome" | |
| set theURL to URL of active tab of window 0 | |
| end tell | |
| if appIsRunning("Safari") then |
| #!/bin/bash | |
| echo "Finding and Purging Big Files From Git History" | |
| echo "==============================================" | |
| echo "" | |
| echo "http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history/" | |
| echo "" | |
| pushd "$(git rev-parse --show-toplevel)" > /dev/null |