Skip to content

Instantly share code, notes, and snippets.

@AlexDel
AlexDel / demo.py
Created February 1, 2018 06:44
Demo for sfu students
import nltk
from nltk.book import *
text1
text2
text1.concordance("monstrous")
text2.concordance("monstrous")
text1.similar("monstrous")
def sumSeries(first, ratio, n):
return (first*(1-(ratio)**n))/(1-ratio)
@AlexDel
AlexDel / pluralize.js
Created August 31, 2017 11:18
Pluralization service
const transResources = {
'projects':{
1: '1 стул выбран',
4: '{{number}} стула выбрано',
5: '{{numerb}} стульев выбрано'
}1
};
class CoreServices {
@AlexDel
AlexDel / vector.py
Last active July 26, 2017 06:00
Class for vector in Udacity Linear algebra course (wtih operators overloadin)
import math
class Vector(object):
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordinates = tuple(coordinates)
self.dimension = len(coordinates)
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
data = np.random.normal(7.3, 1.43, 20)
d = [x for x in np.ceil(data) if x <= 10]
plt.hist(d, bins=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], range=(1,11), color="red", align="left")
plt.title('Title')
plt.show()
@AlexDel
AlexDel / defaultSettingsService.js
Last active April 28, 2017 10:09
sample getDefaultSettings service
import { get, set } from 'lodash';
// import 'object to paths' converter from here https://gist.github.com/AlexDel/9f9f732f77ffa8bb10b4f4967a6513d8
import getPaths from 'helpers';
// service uses new settings structure from here https://gist.github.com/AlexDel/007771d7c6d2b1415d7275557a9a432b
import { EvernoteSettings } from 'Settings';
class SettingsService {
@AlexDel
AlexDel / evernoteTodoistSettings.js
Last active April 28, 2017 09:36
sample evernote settings
const evernoteSeetings = {
source: {
mode: {
default: 'simple',
availableValues: [
{ name: constantOptions.simple, description: 'simple' },
{ name: constantOptions.advanced, description: 'advanced' }
],
validation: {
presence: true,
@AlexDel
AlexDel / getDefaultSettings
Created April 28, 2017 09:21
get default settings from settings obj
tt
@AlexDel
AlexDel / objToPaths.js
Last active April 28, 2017 09:20
Converts objects keys in to array of path
const testObj = {
prop1: {
child1: 'test',
},
prop2: 'test2'
};
function getPaths(obj) {
let pathsArray = [];
let webpackConfig = {
devtool: 'inline-source-map',
output: {
filename: 'bundle.js',
publicPath: '/build/',
path: path.resolve(__dirname, './public')
},
module: {
loaders: [