Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
shaybensasson / keras_models.md
Created March 21, 2020 09:14 — forked from candlewill/keras_models.md
A collection of Various Keras Models Examples

Keras Models Examples

一系列常用模型的Keras实现

DNN

Multilayer Perceptron (MLP) for multi-class softmax classification

from keras.models import Sequential
@shaybensasson
shaybensasson / daemon.json
Created September 24, 2019 06:03
/etc/docker/daemon.json, docker firewall dns configs
{
"dns": ["132.72.140.46", "132.72.140.45", "8.8.8.8"]
}
@shaybensasson
shaybensasson / Fix.immediate.wakeup.after.suspend.service
Created August 7, 2019 16:48
A systemmd service that Fixes immediate wakeup after suspend, by disabling all triggers but power/sleep btn (X1 extreme)
[Unit]
Description="Fixes immediate wakeup after suspend, by disabling all trigers but power/sleep btn"
# https://askubuntu.com/a/1139215/562313
[Service]
ExecStart=/bin/bash -c "echo PEG0 > /proc/acpi/wakeup && echo PEGP > /proc/acpi/wakeup && echo XHC > /proc/acpi/wakeup && echo RP09 > /proc/acpi/wakeup && echo PXSX > /proc/acpi/wakeup"
[Install]
WantedBy=multi-user.target
@shaybensasson
shaybensasson / getGmailMessageUrl.js
Created July 27, 2019 05:42
Get a direct link to Gmail message using a bookmarklet
javascript: href=document.location.href; window.open(href.substr(0,href.indexOf('?')) + '/#search/rfc822msgid:' + '<' + encodeURIComponent(document.getElementsByClassName('message_id')[0].innerHTML.slice(4, -4)) + '>', "_self");
@shaybensasson
shaybensasson / .xbindkeysrc
Last active August 9, 2019 09:07
xbindkeys config for Media keys in ubuntu
#KeyboardPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
XF86AudioPlay
#KeyboardStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
XF86AudioStop
#KeyboardPrev
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
@shaybensasson
shaybensasson / mongo_server_install_test.py
Created June 18, 2019 05:54
testing mongodb server install on ubuntu
import datetime
DB_NAME = 'testdb'
if __name__ == '__main__':
import pymongo
with pymongo.MongoClient("mongodb://localhost:27017/") as myclient:
# mydb = myclient["mydatabase"]
assert 'local' in myclient.list_database_names()
@shaybensasson
shaybensasson / xorg.conf
Created June 5, 2019 18:57
Mad Catz R.A.T.7 Mouse remap on ubuntu, create and paste it in /etc/X11/xorg.conf
Section "InputClass"
Identifier "Mouse Remap"
MatchProduct "Mad Catz R.A.T.7 Mouse"
MatchIsPointer "true"
MatchDevicePath "/dev/input/event*"
Option "Buttons" "24"
Option "ButtonMapping" "1 2 3 4 5 0 0 8 9 10 11 12 0 0 0 16 17 7 6 0 0 0 0 0"
Option "AutoReleaseButtons" "20 21 22 23 24"
Option "ZAxisMapping" "4 5 6 7"
EndSection
@shaybensasson
shaybensasson / compile_NEST_py3_shay.sh
Created May 16, 2019 08:37
Compiles NEST simulation package for python3
#!/bin/bash
set -e
# Any subsequent(*) commands which fail will cause the shell script to exit immediately
cmake -DCMAKE_INSTALL_PREFIX=/home/shay/opt/packages/nest-simulator-2.16.0 \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
-DPYTHON_INCLUDE_DIR=/usr/include/python3.5 \
-DPYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.5m \
/home/shay/Downloads/NEST/nest-simulator-2.16.0
@shaybensasson
shaybensasson / mnist_cnn_tf_sample.py
Created May 4, 2019 09:54
Testing tensorflow < 2 installation
'''Trains a simple convnet on the MNIST dataset.
Gets to 99.25% test accuracy after 12 epochs
(there is still a lot of margin for parameter tuning).
16 seconds per epoch on a GRID K520 GPU.
'''
#from __future__ import print_function
from tensorflow import keras as K
# from keras.datasets import mnist
# from keras.models import Sequential
@shaybensasson
shaybensasson / mnist_cnn_torch_sample.py
Last active April 20, 2020 06:27
Testing torch 1.1 installation
from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
class Net(nn.Module):