Skip to content

Instantly share code, notes, and snippets.

Avatar

Ondrej Platek oplatek

View GitHub Profile
@oplatek
oplatek / clean env
Last active Nov 2, 2020
ycm compilation macos clean environment
View clean env
mboplatek:YouCompleteMe oplatek$ env
SHELL=/usr/local/bin/bash
XPC_FLAGS=0x0
TERM_PROGRAM_VERSION=433
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.XIpE0VAAVX/Listeners
TERM_SESSION_ID=C59A55E3-366C-4651-A75B-C5C0F8825111
PWD=/Users/oplatek/.vim/bundle/YouCompleteMe
LOGNAME=oplatek
LaunchInstanceID=580A1386-878E-47F0-A69F-1380E631C731
HOME=/Users/oplatek
View gist:ee74c27a8a12400c9282940cdedf3c9f
SHELL=/usr/local/bin/bash
XPC_FLAGS=0x0
TERM_PROGRAM_VERSION=433
CONDA_EXE=/Users/oplatek/anaconda3/bin/conda
_CE_M=
TMUX=/private/tmp/tmux-501/default,7388,0
LANGUAGE=en_US.UTF-8
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.XIpE0VAAVX/Listeners
TERM_SESSION_ID=2A640EC8-E79E-485A-B850-BDE24A8DEB18
EDITOR=vim
@oplatek
oplatek / ycm_stdout_stderr.log
Created Nov 2, 2020
YCM compilation issue on macos
View ycm_stdout_stderr.log
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/llvm-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/llvm-g++ - skipped
@oplatek
oplatek / curl-websocket.sh
Last active Nov 23, 2017 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
View curl-websocket.sh
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@oplatek
oplatek / curl-websocket.sh
Created Nov 23, 2017 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
View curl-websocket.sh
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@oplatek
oplatek / pcm_record.py
Created Dec 28, 2016
Record 16bit 16khz pcm from python
View pcm_record.py
# coding: utf-8
import sounddevice as sd
duration = 10
fs = 16000
rec = sd.rec(duration * fs, samplerate=fs, channels=1, dtype='int16')
sd.wait()
pcm = rec.tostring()
with open('test.raw', 'wb') as w:
w.write(pcm)
@oplatek
oplatek / tmux_local_install.sh
Created Oct 15, 2016 — forked from petrbel/tmux_local_install.sh
bash script for installing tmux without root access
View tmux_local_install.sh
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.3
@oplatek
oplatek / install-tf-gpu-linux-and-test
Last active Apr 21, 2019
Installing Tensorflow 0.8 for GPU on Linux and test if GPU is used supported Python2.7 and 3.4
View install-tf-gpu-linux-and-test
#!/bin/bash
[ -z $1 ] && python=3.4
if [ $(whoami) = root ] ; then
user=''
else
echo Not running under sudo. pip install --user
user='--user'
fi
if [ $python = '2.7' ] ; then
View lengths2mask-tensorflow
def lengths2mask2d(lengths, max_len):
batch_size = lengths.get_shape().as_list()[0]
# Filled the row of 2d array with lengths
lengths_transposed = tf.expand_dims(lengths, 1)
lengths_tiled = tf.tile(lengths_transposed, [1, max_len])
# Filled the rows of 2d array 0, 1, 2,..., max_len ranges
rng = tf.to_int64(tf.range(0, max_len, 1))
range_row = tf.expand_dims(rng, 0)
range_tiled = tf.tile(range_row, [batch_size, 1])
View example turn based architecture
self.is_first_turn = tf.placeholder(tf.bool)
logger.debug('We get input features for each turn, to represent dialog, we need to store the state between the turns')
dialog_state_before_turn = tf.get_variable('dialog_state_before_turn', initializer=encoder_cell.zero_state(c.batch_size))
dialog_state_before_turn = control_flow_ops.cond(self.is_first_turn,
lambda: encoder_cell.zero_state(c.batch_size),
lambda: dialog_state_before_turn)
logger.debug('Initialization of encoder inputs and control flow took %.2f s.', inpt_timer())
words_hidden_feat, dialog_state_after_turn = tf.nn.rnn(encoder_cell, embedded_inputs,
initial_state=dialog_state_before_turn, sequence_length=turn_len)