Skip to content

Instantly share code, notes, and snippets.

@kocur4d
kocur4d / main.py
Created February 23, 2019 20:58
Add column to np.array
import numpy as np
X = np.array([
[2.31, 4.58],
[1.56,4.27],
[5.48,5.61],
[0.03,1.49],
[6.13,6.07],
[2.36,4.75],
[2.14,4.3],
@kocur4d
kocur4d / random.js
Created August 28, 2018 19:54
JS Random Color
const randomColor = () => '#'+(Math.random()*0xFFFFFF<<0).toString(16)
// SAGA
export const disconnectPage = function*(pageId) {
const accessToken = yield call(ensureAccessTokenSaga)
const { success, data, error } = yield call(disconnectFacebookPage(pageId), accessToken)
if(success === true) {
yield put(dataRequest({
key: 'facebook_page_settings:pages',
fetcher: fetchFacebookPages,
}))
from sklearn.learning_curve import learning_curve
import numpy as np
import matplotlib.pyplot as plt
N, train_lc, val_lc = learning_curve(svc_clf, X_train, y_train, cv=7, train_sizes=np.linspace(0.3, 1, 25))
plt.plot(N, np.mean(train_lc, 1), color='blue', label='training score')
plt.plot(N, np.mean(val_lc, 1), color='red', label='validation score')
plt.hlines(np.mean([train_lc[-1], val_lc[-1]]), N[0], N[-1], color='gray', linestyle='dashed')
plt.set_ylim(0, 1)
@kocur4d
kocur4d / bootstrap.md
Last active September 21, 2018 11:31
Bootstrap create-react-app with redux

yarn add redux react-redux redux-thunk redux-devtools-extension redux-logger immutable redux-immutable node-sass-chokidar

rm src/App* src/logo*

Create the store

// ./src/store.js

import { createStore, applyMiddleware, compose } from 'redux'
@kocur4d
kocur4d / things.py
Last active May 28, 2018 15:20
Python stuff
# count the number of expected result
sum(record.outcome == 1 for record in data.records)
# Count the values
df.column_name.value_counts()
# or
df.groupby('column_name').count()
@kocur4d
kocur4d / index.py
Created April 28, 2018 12:47
Padding np.array with constant data
data = np.array([1,2,3,4,5])
np.pad(data, (2, 3), 'constant', constant_values=9)
# [9,9,1,2,3,4,5,9,9,9]
np.pad(data, (0, 3), 'constant', constant_values=9)
# [1,2,3,4,5,9,9,9]
np.pad(data, (2, 0), 'constant', constant_values=9)
# [9,9,1,2,3,4,5]
@kocur4d
kocur4d / gist:5217431
Created March 21, 2013 22:34
git setup
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.ust 'reset HEAD --'
@kocur4d
kocur4d / gist:5182715
Last active December 15, 2015 01:49 — forked from sandro/gist:293926
Loads gem into console. Add this to your .bashrc file.
alias irbg='irb -I ./lib -r ./lib/*.rb'