Skip to content

Instantly share code, notes, and snippets.

View danielhavir's full-sized avatar

Daniel Havir danielhavir

View GitHub Profile
Month DWI
January 536
February 467
March 464
April 370
May 411
June 438
July 476
country year co2
China 1962 0.651705172948
India 1962 0.307620146391
Japan 1962 3.1103547047
Russia 1962 7.91397623629
United Kingdom 1962 11.1388081316
United States 1962 15.5606900155
China 1963 0.637538142643
India 1963 0.323658671475
Japan 1963 3.41488661345
import bson # pip install pymongo
import numpy as np
import pandas as pd
import os
from tqdm import tqdm_notebook
out_folder = 'images'
# Create output folder
if not os.path.exists(out_folder):

Keybase proof

I hereby claim:

  • I am danielhavir on github.
  • I am danielhavir (https://keybase.io/danielhavir) on keybase.
  • I have a public key ASDEKLlI3mzQBn3N1IThJD64Xb7T-vHA8XxTKcX4-u5rOgo

To claim this, I am signing this object:

if [ $# -ne 2 ];then
echo "Usage: `basename $0` idVendor idProduct"
exit 1
fi
for X in /sys/bus/usb/devices/*; do
if [ "$1" == "$(cat "$X/idVendor" 2>/dev/null)" -a "$2" == "$(cat "$X/idProduct" 2>/dev/null)" ]
then
echo "$X"
@danielhavir
danielhavir / die_javascript.sh
Last active July 30, 2018 15:49
JavaScript Must Die!
### Removes Node and NPM from mac OS ###
# Uninstall using NPM
npm uninstall npm -g || echo "NPM uninstall didn't work"
# Try if Node's installed with Brew
(brew uninstall node&&brew prune)||echo "Node was not installed with Brew"
# Remove all files and folders including Node or NPM
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
rm -rf /usr/local/include/node*
tput setaf 6; echo '#### Downloading and installing Anaconda ####'; tput sgr0;
wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
bash ./Anaconda3-5.3.0-Linux-x86_64.sh
tput setaf 2; echo '#### Anaconda has been successfully installed ####'; tput sgr0;
# Stop Xorg
sudo systemctl stop lightdm.service
# Remove .deb packages and Anaconda installer
rm -f Anaconda* nvidia* cuda*
def gram_matrix(feature_map):
C, H, W = feature_map.size()
reshaped_map = feature_map.view(C, H*W)
G = reshaped_map.mm(reshaped_map.t()) / (C * H * W)
return G
def content_loss(content_features, generated_features, j):
loss_content = F.mse_loss(generated_features[j], content_features[j])
return loss_content
def style_loss(style_features, generated_features, J):
loss_style = 0.
for j in J:
gram_style = gram_matrix(style_features[j])
gram_gen = gram_matrix(generated_features[j])
loss_style += F.mse_loss(gram_gen, gram_style)
return loss_style