.
8 | .list-group {
9 | // No need to set list-style: none; since .list-group-item is block level
10 | margin-bottom: 20px;
11 | padding-left: 0; // reset padding because ul and ol
12 | }
13 |
14 | // Linked list items
15 | a.list-group-item {
16 | color: $list-group-link-color;
17 |
18 | .list-group-item-heading {
19 | color: $list-group-link-heading-color;
20 | }
21 |
22 | // Hover state
23 | &:hover,
24 | &:focus {
25 | text-decoration: none;
26 | background-color: $list-group-hover-bg;
27 | }
28 | }
29 |
30 | // Individual list items
31 | // -------------------------
32 |
33 | .list-group-item {
34 | position: relative;
35 | display: block;
36 | padding: 10px 15px;
37 | // Place the border on the list items and negative margin up for better styling
38 | margin-bottom: -1px;
39 | background-color: $list-group-bg;
40 | border: 1px solid $list-group-border;
41 |
42 | // Round the first and last items
43 | &:first-child {
44 | @include border-top-radius($list-group-border-radius);
45 | }
46 | &:last-child {
47 | margin-bottom: 0;
48 | @include border-bottom-radius($list-group-border-radius);
49 | }
50 |
51 | // Align badges within list items
52 | > .badge {
53 | float: right;
54 | }
55 | > .badge + .badge {
56 | margin-right: 5px;
57 | }
58 |
59 | // Active class on item itself, not parent
60 | &.active,
61 | &.active:hover,
62 | &.active:focus {
63 | z-index: 2; // Place active items above their siblings for proper border styling
64 | color: $list-group-active-color;
65 | background-color: $list-group-active-bg;
66 | border-color: $list-group-active-border;
67 |
68 | // Force color to inherit for custom content
69 | .list-group-item-heading {
70 | color: inherit;
71 | }
72 | .list-group-item-text {
73 | color: lighten($list-group-active-bg, 40%);
74 | }
75 | }
76 | }
77 |
78 | // Custom content options
79 | // -------------------------
80 |
81 | .list-group-item-heading {
82 | margin-top: 0;
83 | margin-bottom: 5px;
84 | }
85 | .list-group-item-text {
86 | margin-bottom: 0;
87 | line-height: 1.3;
88 | }
89 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_media.scss:
--------------------------------------------------------------------------------
1 | // Media objects
2 | // Source: http://stubbornella.org/content/?p=497
3 | // --------------------------------------------------
4 |
5 |
6 | // Common styles
7 | // -------------------------
8 |
9 | // Clear the floats
10 | .media,
11 | .media-body {
12 | overflow: hidden;
13 | zoom: 1;
14 | }
15 |
16 | // Proper spacing between instances of .media
17 | .media,
18 | .media .media {
19 | margin-top: 15px;
20 | }
21 | .media:first-child {
22 | margin-top: 0;
23 | }
24 |
25 | // For images and videos, set to block
26 | .media-object {
27 | display: block;
28 | }
29 |
30 | // Reset margins on headings for tighter default spacing
31 | .media-heading {
32 | margin: 0 0 5px;
33 | }
34 |
35 |
36 | // Media image alignment
37 | // -------------------------
38 |
39 | .media {
40 | > .pull-left {
41 | margin-right: 10px;
42 | }
43 | > .pull-right {
44 | margin-left: 10px;
45 | }
46 | }
47 |
48 |
49 | // Media list variation
50 | // -------------------------
51 |
52 | // Undo default ul/ol styles
53 | .media-list {
54 | padding-left: 0;
55 | list-style: none;
56 | }
57 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_pager.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Pager pagination
3 | // --------------------------------------------------
4 |
5 |
6 | .pager {
7 | padding-left: 0;
8 | margin: $line-height-computed 0;
9 | list-style: none;
10 | text-align: center;
11 | @include clearfix();
12 | li {
13 | display: inline;
14 | > a,
15 | > span {
16 | display: inline-block;
17 | padding: 5px 14px;
18 | background-color: $pagination-bg;
19 | border: 1px solid $pagination-border;
20 | border-radius: $pager-border-radius;
21 | }
22 |
23 | > a:hover,
24 | > a:focus {
25 | text-decoration: none;
26 | background-color: $pagination-active-bg;
27 | }
28 | }
29 |
30 | .next {
31 | > a,
32 | > span {
33 | float: right;
34 | }
35 | }
36 |
37 | .previous {
38 | > a,
39 | > span {
40 | float: left;
41 | }
42 | }
43 |
44 | .disabled {
45 | > a,
46 | > a:hover,
47 | > a:focus,
48 | > span {
49 | color: $pager-disabled-color;
50 | background-color: $pagination-bg;
51 | cursor: not-allowed;
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_pagination.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Pagination (multiple pages)
3 | // --------------------------------------------------
4 | .pagination {
5 | display: inline-block;
6 | padding-left: 0;
7 | margin: $line-height-computed 0;
8 | border-radius: $border-radius-base;
9 |
10 | > li {
11 | display: inline; // Remove list-style and block-level defaults
12 | > a,
13 | > span {
14 | float: left; // Collapse white-space
15 | padding: $padding-base-vertical $padding-base-horizontal;
16 | line-height: $line-height-base;
17 | text-decoration: none;
18 | background-color: $pagination-bg;
19 | border: 1px solid $pagination-border;
20 | border-left-width: 0;
21 | }
22 | &:first-child {
23 | > a,
24 | > span {
25 | border-left-width: 1px;
26 | @include border-left-radius($border-radius-base);
27 | }
28 | }
29 | &:last-child {
30 | > a,
31 | > span {
32 | @include border-right-radius($border-radius-base);
33 | }
34 | }
35 | }
36 |
37 | > li > a:hover,
38 | > li > a:focus,
39 | > .active > a,
40 | > .active > span {
41 | background-color: $pagination-active-bg;
42 | }
43 | > .active > a,
44 | > .active > span {
45 | color: $pagination-active-color;
46 | cursor: default;
47 | }
48 |
49 | > .disabled {
50 | > span,
51 | > a,
52 | > a:hover,
53 | > a:focus {
54 | color: $pagination-disabled-color;
55 | background-color: $pagination-bg;
56 | cursor: not-allowed;
57 | }
58 | }
59 | }
60 |
61 | // Sizing
62 | // --------------------------------------------------
63 |
64 | // Large
65 | .pagination-lg {
66 | @include pagination-size($padding-large-vertical, $padding-large-horizontal, $font-size-large, $border-radius-large);
67 | }
68 |
69 | // Small
70 | .pagination-sm {
71 | @include pagination-size($padding-small-vertical, $padding-small-horizontal, $font-size-small, $border-radius-small);
72 | }
73 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_print.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Basic print styles
3 | // --------------------------------------------------
4 | // Source: https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css
5 |
6 | @media print {
7 |
8 | * {
9 | text-shadow: none !important;
10 | color: #000 !important; // Black prints faster: h5bp.com/s
11 | background: transparent !important;
12 | box-shadow: none !important;
13 | }
14 |
15 | a,
16 | a:visited {
17 | text-decoration: underline;
18 | }
19 |
20 | a[href]:after {
21 | content: " (" attr(href) ")";
22 | }
23 |
24 | abbr[title]:after {
25 | content: " (" attr(title) ")";
26 | }
27 |
28 | // Don't show links for images, or javascript/internal links
29 | .ir a:after,
30 | a[href^="javascript:"]:after,
31 | a[href^="#"]:after {
32 | content: "";
33 | }
34 |
35 | pre,
36 | blockquote {
37 | border: 1px solid #999;
38 | page-break-inside: avoid;
39 | }
40 |
41 | thead {
42 | display: table-header-group; // h5bp.com/t
43 | }
44 |
45 | tr,
46 | img {
47 | page-break-inside: avoid;
48 | }
49 |
50 | img {
51 | max-width: 100% !important;
52 | }
53 |
54 | @page {
55 | margin: 2cm .5cm;
56 | }
57 |
58 | p,
59 | h2,
60 | h3 {
61 | orphans: 3;
62 | widows: 3;
63 | }
64 |
65 | h2,
66 | h3 {
67 | page-break-after: avoid;
68 | }
69 |
70 | // Bootstrap components
71 | .navbar {
72 | display: none;
73 | }
74 | .table {
75 | td,
76 | th {
77 | background-color: #fff !important;
78 | }
79 | }
80 | .btn,
81 | .dropup > .btn {
82 | > .caret {
83 | border-top-color: #000 !important;
84 | }
85 | }
86 | .label {
87 | border: 1px solid #000;
88 | }
89 |
90 | .table {
91 | border-collapse: collapse !important;
92 | }
93 | .table-bordered {
94 | th,
95 | td {
96 | border: 1px solid #ddd !important;
97 | }
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_thumbnails.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Thumbnails
3 | // --------------------------------------------------
4 |
5 |
6 | // Base classes
7 | // For thumbnail block-level composite components and simple image styles
8 |
9 | // The actual thumbnailed element
10 | // Can be `a`, `div`, or `img`
11 | .thumbnail,
12 | .img-thumbnail {
13 | padding: $thumbnail-padding;
14 | line-height: $line-height-base;
15 | background-color: $thumbnail-bg;
16 | border: 1px solid $thumbnail-border;
17 | border-radius: $thumbnail-border-radius;
18 | @include transition(all .2s ease-in-out);
19 | }
20 | .thumbnail {
21 | display: block;
22 | }
23 | .thumbnail > img,
24 | .img-thumbnail {
25 | @extend .img-responsive;
26 | }
27 |
28 | // Add a hover state for linked versions only
29 | a.thumbnail:hover,
30 | a.thumbnail:focus {
31 | border-color: $link-color;
32 | }
33 |
34 | // Images and captions
35 | .thumbnail > img {
36 | margin-left: auto;
37 | margin-right: auto;
38 | }
39 | .thumbnail .caption {
40 | padding: $thumbnail-caption-padding;
41 | color: $thumbnail-caption-color;
42 | }
43 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_utilities.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Utility classes
3 | // --------------------------------------------------
4 |
5 |
6 | // Floats
7 | // -------------------------
8 |
9 | .clearfix {
10 | @include clearfix();
11 | }
12 | .pull-right {
13 | float: right !important;
14 | }
15 | .pull-left {
16 | float: left !important;
17 | }
18 |
19 |
20 | // Toggling content
21 | // -------------------------
22 |
23 | .hide {
24 | display: none !important;
25 | }
26 | .show {
27 | display: block !important;
28 | }
29 | .invisible {
30 | visibility: hidden;
31 | }
32 | .text-hide {
33 | @include hide-text();
34 | }
35 |
36 |
37 | // For Affix plugin
38 | // -------------------------
39 |
40 | .affix {
41 | position: fixed;
42 | }
43 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/_wells.scss:
--------------------------------------------------------------------------------
1 | //
2 | // Wells
3 | // --------------------------------------------------
4 |
5 |
6 | // Base class
7 | .well {
8 | min-height: 20px;
9 | padding: 19px;
10 | margin-bottom: 20px;
11 | background-color: $well-bg;
12 | border: 1px solid darken($well-bg, 7%);
13 | border-radius: $border-radius-base;
14 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
15 | blockquote {
16 | border-color: #ddd;
17 | border-color: rgba(0,0,0,.15);
18 | }
19 | }
20 |
21 | // Sizes
22 | .well-lg {
23 | padding: 24px;
24 | border-radius: $border-radius-large;
25 | }
26 | .well-sm {
27 | padding: 9px;
28 | border-radius: $border-radius-small;
29 | }
30 |
--------------------------------------------------------------------------------
/JS/AddressBook/app/styles/bootstrap/bootstrap.scss:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap v3.0.0
3 | *
4 | * Copyright 2013 Twitter, Inc
5 | * Licensed under the Apache License v2.0
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Designed and built with all the love in the world by @mdo and @fat.
9 | */
10 |
11 | // Core variables and mixins
12 | @import "variables";
13 | @import "mixins";
14 |
15 | // Reset
16 | @import "normalize";
17 | @import "print";
18 |
19 | // Core CSS
20 | @import "scaffolding";
21 | @import "type";
22 | @import "code";
23 | @import "grid";
24 |
25 | @import "tables";
26 | @import "forms";
27 | @import "buttons";
28 |
29 | // Components: common
30 | @import "component-animations";
31 | @import "input-groups";
32 | @import "dropdowns";
33 | @import "list-group";
34 | @import "panels";
35 | @import "wells";
36 | @import "close";
37 |
38 | // Components: Nav
39 | @import "navs";
40 | @import "navbar";
41 | @import "button-groups";
42 | @import "breadcrumbs";
43 | @import "pagination";
44 | @import "pager";
45 |
46 | // Components: Popovers
47 | @import "modals";
48 | @import "tooltip";
49 | @import "popovers";
50 |
51 | // Components: Misc
52 | @import "alerts";
53 | @import "thumbnails";
54 | @import "media";
55 | @import "labels";
56 | @import "badges";
57 | @import "progress-bars";
58 | @import "carousel";
59 | @import "jumbotron";
60 |
61 | // Utility classes
62 | @import "utilities"; // Has to be last to override when necessary
63 | @import "responsive-utilities";
64 |
--------------------------------------------------------------------------------
/JS/AddressBook/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "addressbook",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "modernizr": "~2.6.2",
6 | "jquery": "~1.9.1",
7 | "font-awesome": "~3.2.1",
8 | "backbone": "~1.0.0",
9 | "Backbone.localStorage": "~1.1.6",
10 | "underscore": "~1.5.1",
11 | "underscore.string": "~2.3.3",
12 | "bootstrap-select": "*",
13 | "jasmine-underscore": "*"
14 | },
15 | "devDependencies": {}
16 | }
17 |
--------------------------------------------------------------------------------
/JS/AddressBook/dist/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/dist/favicon.ico
--------------------------------------------------------------------------------
/JS/AddressBook/dist/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org/
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/JS/AddressBook/dist/styles/font/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/dist/styles/font/FontAwesome.otf
--------------------------------------------------------------------------------
/JS/AddressBook/dist/styles/font/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/dist/styles/font/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/JS/AddressBook/dist/styles/font/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/dist/styles/font/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/JS/AddressBook/dist/styles/font/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/dist/styles/font/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/JS/AddressBook/karma.conf.coffee:
--------------------------------------------------------------------------------
1 | # Karma configuration
2 | # http:#karma-runner.github.io/0.10/config/configuration-file.html
3 |
4 | module.exports = (config) ->
5 | config.set
6 | # base path, that will be used to resolve files and exclude
7 | basePath: ''
8 |
9 | # testing framework to use (jasmine/mocha/qunit/...)
10 | frameworks: ['jasmine']
11 |
12 | # list of files / patterns to load in the browser
13 | files: [
14 | 'app/bower_components/jquery/jquery.js'
15 | 'app/bower_components/underscore/underscore.js'
16 | 'app/bower_components/underscore.string/lib/underscore.string.js'
17 | 'app/bower_components/backbone/backbone.js'
18 | 'app/bower_components/Backbone.localStorage/backbone.localStorage.js'
19 | 'app/bower_components/bootstrap-select/bootstrap-select.js'
20 | 'app/bower_components/jasmine-underscore/lib/jasmine-underscore.js'
21 | 'app/scripts/vendor/bootstrap/alert.js'
22 | 'app/scripts/memory-storage.coffee'
23 | 'app/scripts/boot.coffee'
24 | 'app/scripts/models.coffee'
25 | 'test/spec/*.coffee'
26 | ]
27 |
28 | # list of files / patterns to exclude
29 | exclude: []
30 |
31 | # web server port
32 | port: 8080
33 |
34 | # level of logging
35 | # possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
36 | logLevel: config.LOG_INFO
37 |
38 | # enable / disable watching file and executing tests whenever any file changes
39 | autoWatch: true
40 |
41 | # Start these browsers, currently available:
42 | # - Chrome
43 | # - ChromeCanary
44 | # - Firefox
45 | # - Opera
46 | # - Safari (only Mac)
47 | # - PhantomJS
48 | # - IE (only Windows)
49 | browsers: ['Chrome']
50 |
51 | preprocessors: {
52 | '**/*.coffee': 'coffee'
53 | }
54 |
55 | # Continuous Integration mode
56 | # if true, it capture browsers, run tests and exit
57 | singleRun: false
58 |
--------------------------------------------------------------------------------
/JS/AddressBook/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "addressbook",
3 | "version": "0.0.0",
4 | "devDependencies": {
5 | "grunt": "~0.4.1",
6 | "grunt-contrib-copy": "~0.4.1",
7 | "grunt-contrib-concat": "~0.1.3",
8 | "grunt-contrib-coffee": "~0.6.5",
9 | "grunt-contrib-uglify": "~0.2.0",
10 | "grunt-contrib-compass": "~0.2.0",
11 | "grunt-contrib-jshint": "~0.4.1",
12 | "grunt-contrib-cssmin": "~0.6.0",
13 | "grunt-contrib-connect": "~0.2.0",
14 | "grunt-contrib-clean": "~0.4.0",
15 | "grunt-contrib-htmlmin": "~0.1.3",
16 | "grunt-contrib-imagemin": "~0.1.3",
17 | "grunt-contrib-watch": "~0.4.0",
18 | "grunt-rev": "~0.1.0",
19 | "grunt-usemin": "~0.1.10",
20 | "grunt-mocha": "~0.3.0",
21 | "grunt-open": "~0.2.0",
22 | "grunt-concurrent": "~0.1.0",
23 | "matchdep": "~0.1.1",
24 | "connect-livereload": "~0.2.0",
25 | "grunt-casperjs": "git://github.com/soswow/grunt-casperjs.git",
26 | "karma-ng-scenario": "~0.1.0",
27 | "grunt-karma": "~0.6.1",
28 | "karma-script-launcher": "~0.1.0",
29 | "karma-chrome-launcher": "~0.1.0",
30 | "karma-firefox-launcher": "~0.1.0",
31 | "karma-html2js-preprocessor": "~0.1.0",
32 | "karma-jasmine": "~0.1.2",
33 | "karma-requirejs": "~0.1.0",
34 | "karma-coffee-preprocessor": "~0.1.0",
35 | "karma-phantomjs-launcher": "~0.1.0",
36 | "karma": "~0.10.2",
37 | "karma-ng-html2js-preprocessor": "~0.1.0"
38 | },
39 | "engines": {
40 | "node": ">=0.8.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/JS/AddressBook/test/casperjs/simple-test.coffee:
--------------------------------------------------------------------------------
1 | casper.test.begin "Initial smoke test", 7, (test) ->
2 |
3 | casper.start 'http://localhost:9001', ->
4 | test.assertTitle "Super puper address book!", "Right title"
5 | test.assertExists "#search-add-field"
6 | searchAttr = @getElementAttribute '#search-add-field', 'placeholder'
7 | test.assertEquals searchAttr, "Search contact", 'Search field has right placeholder'
8 | test.assertVisible "button.add-one", "Add button is visible"
9 | test.assertSelectorHasText "button.add-one", "or Add one"
10 | test.assertExists "#contacts-list span.no-data"
11 | test.assertSelectorHasText "#contacts-list span.no-data", "There is no contacts yet."
12 |
13 | casper.run -> test.done()
14 |
15 |
16 | casper.test.begin "Adding new contact", 4, (test) ->
17 |
18 | casper.start 'http://localhost:9001', ->
19 | test.comment "Let's click add button"
20 | @click 'button.add-one'
21 | test.assertNotVisible "button.add-one", "Add button not visible now"
22 | test.assertVisible ".btn-group button.save", "Save button is visible"
23 | test.assertVisible ".btn-group button.cancel", "Cancel button is visible"
24 | searchAttr = @getElementAttribute '#search-add-field', 'placeholder'
25 | test.assertEquals searchAttr, "Full name", 'Name field has right placeholder'
26 |
27 | casper.run -> test.done()
28 |
29 |
--------------------------------------------------------------------------------
/JS/AddressBook/test/spec/ContactSpec.coffee:
--------------------------------------------------------------------------------
1 | describe "Contact model", ->
2 | model = null
3 |
4 | beforeEach ->
5 | app.models.contacts.reset()
6 | model = new app.models.Contact()
7 | app.models.contacts.add model
8 |
9 | it "shouldn't be saved without name and phone", ->
10 | invalid = model.save {}
11 | expect(invalid).toBe false
12 | expect(model.validationError.length).toBe 2
13 | expect(model.validationError[0]).toInclude 'name', 'phone'
14 | expect(model.validationError[1]).toBe 'Name, Phone are mandatory'
15 |
16 | invalid = model.save name: "Something"
17 | expect(invalid).toBe false
18 | expect(model.validationError.length).toBe 2
19 | expect(model.validationError[0]).toInclude 'phone'
20 | expect(model.validationError[1]).toBe 'Phone is mandatory'
21 |
22 | it "should be saved with name, phone and group", ->
23 | validData = name: 'Test', phone: '123', group: 10
24 | expect(model.save(validData)).toBeTruthy()
25 |
26 |
27 | describe "Contacts collection", ->
28 |
29 | beforeEach ->
30 | app.models.contacts.reset()
31 |
32 | it "should return saved items only", ->
33 | model = new app.models.Contact(name: "Test", phone: "123")
34 | app.models.contacts.add model
35 | expect(app.models.contacts.notNew()).toBeEmpty()
36 | model.save()
37 | savedItems = app.models.contacts.notNew()
38 | expect(savedItems).toBeArray()
39 | expect(savedItems.length).toBe 1
40 | expect(savedItems[0]).toBe model
--------------------------------------------------------------------------------
/JS/AddressBook/test/spec/GroupSpec.coffee:
--------------------------------------------------------------------------------
1 | describe "Group collection", ->
2 |
3 | it "should make options list", ->
4 | expect(app.models.groups.length).toBe 3
5 | expect(app.models.groups.map( (obj) -> obj.get('name') )).toInclude 'Work', 'Family', 'Other'
6 |
7 | it "should have initial items", ->
8 | options = app.models.groups.makeOptions()
9 | expect(options).toMatch /
/
--------------------------------------------------------------------------------
/JS/AddressBook/test/spec/SmokeSpec.coffee:
--------------------------------------------------------------------------------
1 | describe "Global stuff", ->
2 | it "should be in place", ->
3 | expect(app).toBeDefined()
4 | expect(app.models).toBeDefined()
5 | expect(app.models.Group).toBeDefined()
6 | expect(app.models.Contact).toBeDefined()
7 | expect(app.models.groups).toBeDefined()
8 | expect(app.models.contacts).toBeDefined()
9 |
--------------------------------------------------------------------------------
/JS/Ai-class/motion-model.js:
--------------------------------------------------------------------------------
1 | function motionPredict(input){
2 | var x = input.initX || 0,
3 | y=input.initY || 0,
4 | tetha=input.tetha || 0,
5 | v = input.v,
6 | dt = input.dt,
7 | omega = input.omega,
8 | T = input.T;
9 |
10 | for (var i=0; i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/JS/BlueToggl/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/JS/BlueToggl/scripts/7bbebd55.coffee.js:
--------------------------------------------------------------------------------
1 | (function(){$(function(){var e,t,n,r,i;return e=function(e,t){return $("#inrunner").css({background:"radial-gradient(circle, rgba(32, 115, 145, 0) "+e+"px, #207391 "+e+"px, rgba(32, 115, 145, 0) "+t+"px)"})},t=function(e,t){return $("#outrunner").css({background:"radial-gradient(circle, rgba(0, 0, 0, 0) "+e+"px, rgba(32, 115, 145, 0) "+e+"px, #207391 "+t+"px, rgba(32, 115, 145, 0) "+t+"px)"})},window.params={inFrom:300,inOutChange:140,inTo:0,outFrom:30,outInChange:200,outTo:300,length:100,delta:3.3},n={"in":!1,out:!1},i=function(e,o){return null==o&&(o=params.delta),n.out=!0,requestAnimationFrame(function(){return t(e,e+params.length),params.outTo>e?(!n["in"]&&e>params.outInChange&&(r(params.inFrom),o=params.delta),o*=.984,i(e+o,o)):n.out=!1})},r=function(t,o){return null==o&&(o=params.delta),n["in"]=!0,requestAnimationFrame(function(){return e(t,t+params.length),t>params.inTo?(!n.out&¶ms.inOutChange>t&&(i(params.outFrom),o=params.delta),o*=.984,r(t-o,o)):n["in"]=!1})},console.log("in!"),r(params.inFrom)})}).call(this);
--------------------------------------------------------------------------------
/JS/Chemistry/calcYakub.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Build YAKUB/FUKUDA
5 |
6 |
7 |
8 |
27 |
28 |
29 | Calculate YAKUB/FUKUDA
30 |
48 |
49 |
52 |
53 |
59 |
60 |
Result:
61 |
62 |
63 |
--------------------------------------------------------------------------------
/JS/Chemistry/cg900656z_si_001 (1).pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/Chemistry/cg900656z_si_001 (1).pdf
--------------------------------------------------------------------------------
/JS/Chemistry/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Eugen
5 |
6 |
7 |
8 |
16 |
17 |
18 |
66 |
67 |
70 |
72 |
73 |
78 |
79 |
80 |
81 | Output:
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/JS/HDRAssembler/expansions.coffee:
--------------------------------------------------------------------------------
1 | unless String.prototype.startsWith
2 | String.prototype.startsWith = (thing) ->
3 | @.indexOf(thing) is 0
4 |
5 | throw "error in startsWith" unless "SOME_DO".startsWith("SOME")
6 | throw "error in startsWith" if "SOME_DO".startsWith("DO")
7 |
8 | unless String.prototype.endsWith
9 | String.prototype.endsWith = (thing) ->
10 | @.indexOf(thing) is (@.length - thing.length)
11 |
12 | throw "error in endsWith" unless "SOME_DO".endsWith("DO")
13 | throw "error in endsWith" if "SOME_DO".endsWith("SOME")
14 |
15 | unless String.prototype.lines
16 | Object.defineProperty String.prototype, 'lines', get: -> @.split /\n/
17 |
18 | throw "error in endsWith" if """Something
19 | is
20 | here
21 | """.lines.length isnt 3
--------------------------------------------------------------------------------
/JS/HDRAssembler/expansions.js:
--------------------------------------------------------------------------------
1 | (function() {
2 |
3 | if (!String.prototype.startsWith) {
4 | String.prototype.startsWith = function(thing) {
5 | return this.indexOf(thing) === 0;
6 | };
7 | }
8 |
9 | if (!"SOME_DO".startsWith("SOME")) throw "error in startsWith";
10 |
11 | if ("SOME_DO".startsWith("DO")) throw "error in startsWith";
12 |
13 | if (!String.prototype.endsWith) {
14 | String.prototype.endsWith = function(thing) {
15 | return this.indexOf(thing) === (this.length - thing.length);
16 | };
17 | }
18 |
19 | if (!"SOME_DO".endsWith("DO")) throw "error in endsWith";
20 |
21 | if ("SOME_DO".endsWith("SOME")) throw "error in endsWith";
22 |
23 | if (!String.prototype.lines) {
24 | Object.defineProperty(String.prototype, 'lines', {
25 | get: function() {
26 | return this.split(/\n/);
27 | }
28 | });
29 | }
30 |
31 | if ("Something\nis\nhere".lines.length !== 3) throw "error in endsWith";
32 |
33 | }).call(this);
34 |
--------------------------------------------------------------------------------
/JS/HDRAssembler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"HDR_assembler",
3 | "version":"0.0.1",
4 | "dependencies":{
5 | "async":"",
6 | "fs.extra":""
7 | }
8 | }
--------------------------------------------------------------------------------
/JS/HubbleDownloader/main.js:
--------------------------------------------------------------------------------
1 | var scrape = require('scrape');
2 | var _ = require('underscore')._;
3 | var async = require('async');
4 | var http = require('http-get');
5 | var path = require('path');
6 |
7 | var urlFunc = function(page){ return "http://www.spacetelescope.org/images/page/" + page };
8 | var baseUrl = "http://www.spacetelescope.org";
9 | var pathSaveTo = "/Volumes/New Mac HD/Downloads/MyHubble/";
10 |
11 | var imagePageQueue = async.queue(function (image, callback) {
12 | console.log("Starting with: " + image.url + " on page " + image.page);
13 |
14 | scrape.request(image.url, function (err, $) {
15 | if (err){
16 | callback();
17 | return console.error(err);
18 | }
19 |
20 | var found = false;
21 | var urls = $(".archive_download .archive_dl_text a").map(function(a){ return a.attribs.href;});
22 | var imageUrl = _.find(urls, function(url){ return url.indexOf('/publicationjpg/') > -1});
23 | if(!imageUrl){
24 | imageUrl = _.find(urls, function(url){ return url.indexOf('/large/') > -1});
25 | }
26 | if(imageUrl){
27 | http.get(baseUrl + imageUrl, pathSaveTo + path.basename(imageUrl), function (error, result) {
28 | if (error) {
29 | console.error(error);
30 | } else {
31 | console.log('File downloaded at: ' + result.file);
32 | }
33 | callback();
34 | });
35 | }else{
36 | console.error("Can't find link for " + image.url + "\nList of links:" + urls.join(", "));
37 | callback();
38 | }
39 | });
40 |
41 |
42 | }, 10);
43 |
44 | var imagesListPageQueue = async.queue(function (page, callback) {
45 | console.log("Starting page "+page);
46 | scrape.request(urlFunc(page), function (err, $) {
47 | var imagePages = $(".archive_normal td.imagerow a").map(function(a){
48 | return {url: baseUrl + a.attribs.href, page:page};
49 | });
50 | console.log("Page "+page+" contains "+imagePages.length+" images");
51 | imagePageQueue.push(imagePages);
52 | callback();
53 | });
54 | }, 10);
55 |
56 | for(var page=1; page<67; page++) {
57 | imagesListPageQueue.push(page);
58 | }
--------------------------------------------------------------------------------
/JS/HubbleDownloader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hubble-images-downloader",
3 | "version": "0.0.1",
4 | "author": "Aleksandr Motsjonov ",
5 | "description": "Downloads all HiRes images from http://www.spacetelescope.org",
6 | "dependencies" : {
7 | "scrape" : "*",
8 | "underscore": "*",
9 | "async" : "*",
10 | "http-get" : "*"
11 | },
12 | "license": "MIT",
13 | "engines": {
14 | "node": ">=0.6"
15 | }
16 | }
--------------------------------------------------------------------------------
/JS/NumberToWordsMath/chains.dot:
--------------------------------------------------------------------------------
1 | digraph G {
2 | 0 -> 4;
3 | 1 -> 4;
4 | 2 -> 3;
5 | 3 -> 3;
6 | 4 -> 4;
7 | 5 -> 4;
8 | 6 -> 5;
9 | 7 -> 4;
10 | 8 -> 6;
11 | 9 -> 6;
12 | 10 -> 6;
13 | 11 -> 11;
14 | 12 -> 10;
15 | 13 -> 10;
16 | 14 -> 12;
17 | 15 -> 10;
18 | 16 -> 11;
19 | 17 -> 10;
20 | 18 -> 12;
21 | 19 -> 12;
22 | 20 -> 8;
23 | 21 -> 13;
24 | 22 -> 12;
25 | 23 -> 12;
26 | 24 -> 15;
27 | 25 -> 13;
28 | 26 -> 14;
29 | 27 -> 13;
30 | 28 -> 15;
31 | 29 -> 15;
32 | 30 -> 8;
33 | 31 -> 13;
34 | 32 -> 12;
35 | 33 -> 12;
36 | 34 -> 15;
37 | 35 -> 13;
38 | 36 -> 14;
39 | 37 -> 13;
40 | 38 -> 15;
41 | 39 -> 15;
42 | 40 -> 5;
43 | 41 -> 10;
44 | 42 -> 9;
45 | 43 -> 9;
46 | 44 -> 12;
47 | 45 -> 10;
48 | 46 -> 11;
49 | 47 -> 10;
50 | 48 -> 12;
51 | 49 -> 12;
52 | 50 -> 9;
53 | 51 -> 14;
54 | 52 -> 13;
55 | 53 -> 13;
56 | 54 -> 16;
57 | 55 -> 14;
58 | 56 -> 15;
59 | 57 -> 14;
60 | 58 -> 16;
61 | 59 -> 16;
62 | 60 -> 10;
63 | 61 -> 15;
64 | 62 -> 14;
65 | 63 -> 14;
66 | 64 -> 17;
67 | 65 -> 15;
68 | 66 -> 16;
69 | 67 -> 15;
70 | 68 -> 17;
71 | 69 -> 17;
72 | 70 -> 9;
73 | 71 -> 14;
74 | 72 -> 13;
75 | 73 -> 13;
76 | 74 -> 16;
77 | 75 -> 14;
78 | 76 -> 15;
79 | 77 -> 14;
80 | 78 -> 16;
81 | 79 -> 16;
82 | 80 -> 11;
83 | 81 -> 16;
84 | 82 -> 15;
85 | 83 -> 15;
86 | 84 -> 18;
87 | 85 -> 16;
88 | 86 -> 17;
89 | 87 -> 16;
90 | 88 -> 18;
91 | 89 -> 18;
92 | 90 -> 9;
93 | 91 -> 14;
94 | 92 -> 13;
95 | 93 -> 13;
96 | 94 -> 16;
97 | 95 -> 14;
98 | 96 -> 15;
99 | 97 -> 14;
100 | 98 -> 16;
101 | 99 -> 16;
102 | 100 -> 3;
103 | }
104 |
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/09-DD_receipts-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/09-DD_receipts-2.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_212741.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_212741.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_212747.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_212747.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_212805.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_212805.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_212908.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_212908.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_212919.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_212919.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_213005.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_213005.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_213053.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_213053.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_213114.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_213114.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180226_213125.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180226_213125.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180227_125726.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180227_125726.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180301_191122.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180301_191122.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180301_191148.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180301_191148.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180301_191200.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180301_191200.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180302_104542.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180302_104542.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180302_110406.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180302_110406.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180302_111131.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180302_111131.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/IMG_20180302_114002.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/IMG_20180302_114002.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/health_receipt_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/health_receipt_target.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/images/photo35.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/OpenCV.js-receipt/images/photo35.jpg
--------------------------------------------------------------------------------
/JS/OpenCV.js-receipt/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Remap test
6 |
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_diagonals-thick_15_444444_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_diagonals-thick_15_444444_40x40.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_diagonals-thick_95_ffdc2e_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_diagonals-thick_95_ffdc2e_40x40.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_glass_55_fbf5d0_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_glass_55_fbf5d0_1x400.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_highlight-hard_30_285c00_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_highlight-hard_30_285c00_1x100.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_highlight-soft_33_3a8104_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_highlight-soft_33_3a8104_1x100.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_highlight-soft_50_4eb305_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_highlight-soft_50_4eb305_1x100.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_highlight-soft_60_4ca20b_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_highlight-soft_60_4ca20b_1x100.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-bg_inset-soft_10_285c00_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-bg_inset-soft_10_285c00_1x100.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-icons_4eb305_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-icons_4eb305_256x240.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-icons_72b42d_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-icons_72b42d_256x240.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/JS/ParticleFilter/images/ui-icons_ffffff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/ParticleFilter/images/ui-icons_ffffff_256x240.png
--------------------------------------------------------------------------------
/JS/UI-design/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "app/components"
3 | }
4 |
--------------------------------------------------------------------------------
/JS/UI-design/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = space
12 | indent_size = 4
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
--------------------------------------------------------------------------------
/JS/UI-design/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/JS/UI-design/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .tmp
3 | .sass-cache
4 | app/components
5 |
--------------------------------------------------------------------------------
/JS/UI-design/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "browser": true,
4 | "es5": true,
5 | "esnext": true,
6 | "bitwise": true,
7 | "camelcase": true,
8 | "curly": true,
9 | "eqeqeq": true,
10 | "immed": true,
11 | "indent": 4,
12 | "latedef": true,
13 | "newcap": true,
14 | "noarg": true,
15 | "quotmark": "single",
16 | "regexp": true,
17 | "undef": true,
18 | "unused": true,
19 | "strict": true,
20 | "trailing": true,
21 | "smarttabs": true
22 | }
23 |
--------------------------------------------------------------------------------
/JS/UI-design/TODO.txt:
--------------------------------------------------------------------------------
1 | TODO Bugs:
2 | * "From shelf" is not the best name and doesn't currently confirms user action as remove button on "My shelf" page
3 | * Rating tooltip is not working in popup right now.
4 | * No "Read more" for description doesn't appear in case of description longer then box
5 |
6 | TODO Features:
7 | * Make explicit button for submitting the search (for mobile users)
8 | * Paging for my shelf
9 | * Reminder for books borrowed long time ago
10 | * Integration with my-books in goodreads.com
11 |
12 | TODO Required features:
13 | * Column sorting for my shelf
14 | -* Registration
15 | -* Authorization
16 | * Compact list mode with open additional info (or maybe my books is enough)
17 | * Specific fields search
18 | * Extra book
--------------------------------------------------------------------------------
/JS/UI-design/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/JS/UI-design/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/app/favicon.ico
--------------------------------------------------------------------------------
/JS/UI-design/app/images/goodreads-badge-read-reviews.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/app/images/goodreads-badge-read-reviews.png
--------------------------------------------------------------------------------
/JS/UI-design/app/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/JS/UI-design/app/scripts/books.coffee:
--------------------------------------------------------------------------------
1 | class app.Book extends Backbone.Model
2 | @parseGoogle = (raw) ->
3 | volume = raw.volumeInfo
4 |
5 | id: raw.id
6 | title: volume.title
7 | subtitle: volume.subtitle
8 | authors: volume.authors
9 | authorsStr: (volume.authors || ["unknown author"]).join(", ")
10 | description: volume.description
11 | averageRating: volume.averageRating
12 | ratingsCount: volume.ratingsCount
13 | categories: volume.categories
14 | image: volume.imageLinks?.thumbnail
15 | ISBN: volume.industryIdentifiers[1]?.identifier
16 | language: volume.language
17 | publishedDate: Date.parse(volume.publishedDate)
18 | publisher: volume.publisher
19 |
20 | defaults:
21 | borrowedBy: false
22 | borrowedDate: null
23 | title: null
24 | subtitle: null
25 | authors: null
26 | authorsStr: null
27 | description: null
28 | averageRating: null
29 | ratingsCount: null
30 | categories: null
31 | image: null
32 | ISBN: null
33 | language: null
34 | publishedDate: null
35 | publisher: null
36 |
37 | class app.GoogleBooksCollection extends Backbone.Collection
38 | model: app.Book
39 |
40 | initialize: ->
41 | @gapi = new app.GoogleApi()
42 |
43 | search: (@q) ->
44 | @page = 1
45 | @gapi.search @q, (books) =>
46 | @total = books.totalItems
47 | books = books.items.map (book) => app.Book.parseGoogle(book)
48 | @reset books
49 |
50 | searchMore: ->
51 | @page += 1
52 | @gapi.search @q, {page: @page}, (books) =>
53 | books = books.items.map (book) => app.Book.parseGoogle(book)
54 | @add books
55 |
56 | sync: ->
57 |
58 |
59 | class app.MyBooksCollection extends Backbone.Collection
60 | model: app.Book
61 | localStorage: new Backbone.LocalStorage("MyShelf")
62 |
63 | app.googleBooks = new app.GoogleBooksCollection()
64 | app.myBooks = new app.MyBooksCollection()
--------------------------------------------------------------------------------
/JS/UI-design/app/scripts/google-api.coffee:
--------------------------------------------------------------------------------
1 | class app.GoogleApi
2 | constructor: (@perPage=20) ->
3 | @key = "AIzaSyBh4CXjrAS1zFJPO_2KWTG5HavZnDjhjkQ"
4 |
5 | search: (q, options, cb) ->
6 | unless cb
7 | cb = options
8 | options = {}
9 |
10 | options = $.extend {page: 1}, options
11 |
12 | filterBy = [
13 | "id"
14 | "volumeInfo/title"
15 | "volumeInfo/subtitle"
16 | "volumeInfo/authors"
17 | "volumeInfo/description"
18 | "volumeInfo/publisher"
19 | "volumeInfo/publishedDate"
20 | "volumeInfo/imageLinks"
21 | "volumeInfo/categories"
22 | "volumeInfo/mainCategory"
23 | "volumeInfo/averageRating"
24 | "volumeInfo/ratingsCount"
25 | "volumeInfo/language"
26 | "volumeInfo/industryIdentifiers"
27 | "volumeInfo/imageLinks"
28 | ].join(",")
29 |
30 | $.ajax
31 | url: "https://www.googleapis.com/books/v1/volumes"
32 | data:
33 | key: @key
34 | q: q
35 | country: "us"
36 | startIndex: (options.page-1) * @perPage
37 | maxResults: @perPage
38 | callback: "callback"
39 | fields: "items(#{filterBy}),totalItems"
40 | dataType: 'jsonp'
41 | error: -> console.log 'Error', arguments
42 | success: cb
43 |
44 |
45 | #api = new app.GoogleApi()
46 | #api.search "Harry Potter", (books) ->
47 | # console.log(books)
--------------------------------------------------------------------------------
/JS/UI-design/app/scripts/main.coffee:
--------------------------------------------------------------------------------
1 | class App extends Backbone.Router
2 | routes:
3 | '': 'index'
4 | 'login': 'login'
5 | 'registration': 'registration'
6 | 'search': 'search'
7 | 'my-shelf': 'myShelf'
8 | 'modal-info/:id': 'showModelInfo'
9 |
10 | initialize: ->
11 |
12 | index: ->
13 | if @name
14 | @navigate "search", {trigger: true}
15 | else
16 | @navigate "login", {trigger: true}
17 | return false
18 |
19 | login: ->
20 | @mainView.showLogin()
21 |
22 | registration: ->
23 | @mainView.showRegistration()
24 |
25 | search: ->
26 | @mainView.showSearch()
27 |
28 | myShelf: ->
29 | @mainView.showMyShelf()
30 |
31 | showModelInfo: (id) ->
32 | @myShelf()
33 | @mainView.myShelfView.showModelInfo id
34 |
35 | setName: (@name) ->
36 | $("#userNamePlace").text(@name)
37 |
38 | start: ->
39 | @mainView = new @MainView()
40 | Backbone.history.start pushState: true
41 | app.myBooks.fetch()
42 |
43 | $("body").on "click", "a", (evt) ->
44 | href = $(this).attr("href")
45 | # console.log (href.indexOf("http") isnt 0), (href isnt '#')
46 | if href.indexOf("http") isnt 0 and href isnt '#'
47 | evt.preventDefault()
48 | app.navigate href, {trigger: true}
49 | else
50 | return true
51 |
52 | return this
53 |
54 | window.app = new App()
55 |
56 | $ ->
57 | app.start()
58 |
--------------------------------------------------------------------------------
/JS/UI-design/component.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ui-design",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "sass-bootstrap": "~2.3.0",
6 | "modernizr": "~2.6.2",
7 | "jquery": "~1.9.1",
8 | "font-awesome": "3.0.2",
9 | "backbone": "*",
10 | "backbone.localStorage": "*",
11 | "underscore": "~1.4.4",
12 | "datejs": "latest"
13 | },
14 | "devDependencies": {}
15 | }
16 |
--------------------------------------------------------------------------------
/JS/UI-design/dist/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/favicon.ico
--------------------------------------------------------------------------------
/JS/UI-design/dist/images/goodreads-badge-read-reviews.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/images/goodreads-badge-read-reviews.png
--------------------------------------------------------------------------------
/JS/UI-design/dist/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/JS/UI-design/dist/styles/font/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/styles/font/FontAwesome.otf
--------------------------------------------------------------------------------
/JS/UI-design/dist/styles/font/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/styles/font/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/JS/UI-design/dist/styles/font/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/styles/font/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/JS/UI-design/dist/styles/font/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UI-design/dist/styles/font/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/JS/UI-design/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ui-design",
3 | "version": "0.0.0",
4 | "dependencies": {},
5 | "devDependencies": {
6 | "grunt": "~0.4.0",
7 | "grunt-contrib-copy": "~0.4.0",
8 | "grunt-contrib-concat": "~0.1.2",
9 | "grunt-contrib-coffee": "~0.4.0",
10 | "grunt-contrib-uglify": "~0.1.1",
11 | "grunt-contrib-compass": "~0.1.2",
12 | "grunt-contrib-jshint": "~0.1.1",
13 | "grunt-contrib-cssmin": "~0.4.1",
14 | "grunt-contrib-connect": "0.1.2",
15 | "grunt-contrib-clean": "0.4.0",
16 | "grunt-contrib-htmlmin": "0.1.1",
17 | "grunt-contrib-imagemin": "0.1.2",
18 | "grunt-contrib-livereload": "0.1.1",
19 | "grunt-bower-hooks": "~0.2.0",
20 | "grunt-usemin": "~0.1.9",
21 | "grunt-regarde": "~0.1.1",
22 | "grunt-mocha": "~0.2.2",
23 | "grunt-open": "~0.2.0",
24 | "matchdep": "~0.1.1",
25 | "request": "~2.14.0"
26 | },
27 | "engines": {
28 | "node": ">=0.8.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/JS/UniversalBibTexKeys/README.md:
--------------------------------------------------------------------------------
1 | coffee -wco ./js ./coffee/*
--------------------------------------------------------------------------------
/JS/UniversalBibTexKeys/css/custom.css:
--------------------------------------------------------------------------------
1 | body {
2 | position: relative;
3 | padding-top: 70px;
4 | margin: 0;
5 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
6 | font-size: 14px;
7 | line-height: 20px;
8 | color: #333333;
9 | background-color: #ffffff;
10 | }
11 |
12 | @media (max-width: 979px) and (min-width: 768px){
13 | body {
14 | padding-top: 0;
15 | }
16 | }
17 |
18 | .buttons-row{
19 | text-align: center;
20 | }
21 | .btn.icon-arrow-right{
22 | color: white;
23 | }
--------------------------------------------------------------------------------
/JS/UniversalBibTexKeys/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UniversalBibTexKeys/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/JS/UniversalBibTexKeys/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/UniversalBibTexKeys/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/JS/UniversalBibTexKeys/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bibtex Cit Converter
5 |
6 |
7 |
8 |
9 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.gcode
3 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/app.nw:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/VerticalPlotter/app.nw
--------------------------------------------------------------------------------
/JS/VerticalPlotter/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VerticalPlotter",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "jquery": "~2.0.3"
6 | }
7 | }
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/VerticalPlotter/components/.DS_Store
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/README.md:
--------------------------------------------------------------------------------
1 | jQuery Component
2 | ================
3 |
4 | Shim repository for the [jQuery](http://jquery.com).
5 |
6 | Package Managers
7 | ----------------
8 |
9 | * [Bower](http://bower.io/): `jquery`
10 | * [Component](https://github.com/component/component): `components/jquery`
11 | * [Composer](http://packagist.org/packages/components/jquery): `components/jquery`
12 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "version": "2.0.3",
4 | "description": "jQuery component",
5 | "keywords": [
6 | "jquery",
7 | "component"
8 | ],
9 | "main": "jquery.js",
10 | "license": "MIT",
11 | "gitHead": "452a56b52b8f4a032256cdb8b6838f25f0bdb3d2",
12 | "readme": "jQuery Component\n================\n\nShim repository for the [jQuery](http://jquery.com).\n\nPackage Managers\n----------------\n\n* [Bower](http://bower.io/): `jquery`\n* [Component](https://github.com/component/component): `components/jquery`\n* [Composer](http://packagist.org/packages/components/jquery): `components/jquery`\n",
13 | "readmeFilename": "README.md",
14 | "_id": "jquery@2.0.3",
15 | "repository": {
16 | "type": "git",
17 | "url": "git://github.com/components/jquery.git"
18 | }
19 | }
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/component.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "repo": "components/jquery",
4 | "version": "2.0.3",
5 | "description": "jQuery component",
6 | "keywords": [
7 | "jquery",
8 | "component"
9 | ],
10 | "main": "jquery.js",
11 | "scripts": [
12 | "jquery.js"
13 | ],
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "components/jquery",
3 | "description": "jQuery JavaScript Library",
4 | "type": "component",
5 | "homepage": "http://jquery.com",
6 | "license": "MIT",
7 | "support": {
8 | "irc": "irc://irc.freenode.org/jquery",
9 | "issues": "http://bugs.jquery.com",
10 | "forum": "http://forum.jquery.com",
11 | "wiki": "http://docs.jquery.com/",
12 | "source": "https://github.com/jquery/jquery"
13 | },
14 | "authors": [
15 | {
16 | "name": "John Resig",
17 | "email": "jeresig@gmail.com"
18 | }
19 | ],
20 | "require": {
21 | "robloach/component-installer": "*"
22 | },
23 | "extra": {
24 | "component": {
25 | "scripts": [
26 | "jquery.js"
27 | ],
28 | "files": [
29 | "jquery.min.js",
30 | "jquery-migrate.js",
31 | "jquery-migrate.min.js"
32 | ]
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/components/jquery/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "components-jquery",
3 | "version": "2.0.3",
4 | "description": "jQuery component",
5 | "keywords": ["jquery"],
6 | "main": "./jquery.js"
7 | }
8 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World!
5 |
6 |
7 |
8 |
9 | Hello World!
10 |
11 |
12 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/main.coffee:
--------------------------------------------------------------------------------
1 | console.log 'start'
2 |
3 | dirPin1 = 8
4 | stepPin1 = 9
5 | dirPin2 = 10
6 | stepPin2 = 11
7 | dir = null
8 | goUp = ->
9 | board.digitalWrite dirPin2, board.HIGH
10 | board.digitalWrite dirPin1, board.LOW
11 | dir = "up"
12 |
13 | goDown = ->
14 | board.digitalWrite dirPin2, board.LOW
15 | board.digitalWrite dirPin1, board.HIGH
16 | dir = "down"
17 |
18 | goRight = ->
19 | board.digitalWrite dirPin2, board.LOW
20 | board.digitalWrite dirPin1, board.LOW
21 | # dir = "right"
22 |
23 | firmata = require('firmata')
24 | board = new firmata.Board("/dev/cu.usbserial-A700ejJW", (err) ->
25 | return console.log(err) if err
26 | console.log('connected')
27 | # console.log "pins", board.pins
28 | # console.log "analpins", board.analogPins
29 | # console.log "version", board.version
30 | # console.log "firmware", board.firmware
31 | # board.pinMode dirPin1, board.MODES.OUTPUT
32 | # board.pinMode stepPin1, board.MODES.OUTPUT
33 | board.pinMode dirPin2, board.MODES.OUTPUT
34 | board.pinMode stepPin2, board.MODES.OUTPUT
35 | goDown()
36 | doStep()
37 | )
38 |
39 | stepRight = ->
40 | board.digitalWrite stepPin2, board.HIGH
41 | board.digitalWrite stepPin2, board.LOW
42 |
43 | stepLeft = ->
44 | board.digitalWrite stepPin1, board.HIGH
45 | board.digitalWrite stepPin1, board.LOW
46 |
47 | kill = false
48 | stepNo = 0
49 | prevWas = 'down'
50 | doStep = ->
51 | stepRight()
52 | setTimeout doStep, 10 unless kill
53 | stepNo += 1
54 |
55 | process.on 'SIGINT', ->
56 | kill = true
57 | console.log( "\ngracefully shutting down from SIGINT (Crtl-C)" )
58 | console.log "#{stepNo} steps done"
59 | board.digitalWrite stepPin1, board.LOW
60 | board.digitalWrite stepPin2, board.LOW
61 | process.exit()
--------------------------------------------------------------------------------
/JS/VerticalPlotter/main.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.6.3
2 | (function() {
3 | var board, dir, dirPin1, dirPin2, doStep, firmata, goDown, goRight, goUp, kill, prevWas, stepLeft, stepNo, stepPin1, stepPin2, stepRight;
4 |
5 | console.log('start');
6 |
7 | dirPin1 = 8;
8 |
9 | stepPin1 = 9;
10 |
11 | dirPin2 = 10;
12 |
13 | stepPin2 = 11;
14 |
15 | dir = null;
16 |
17 | goUp = function() {
18 | board.digitalWrite(dirPin2, board.HIGH);
19 | board.digitalWrite(dirPin1, board.LOW);
20 | return dir = "up";
21 | };
22 |
23 | goDown = function() {
24 | board.digitalWrite(dirPin2, board.LOW);
25 | board.digitalWrite(dirPin1, board.HIGH);
26 | return dir = "down";
27 | };
28 |
29 | goRight = function() {
30 | board.digitalWrite(dirPin2, board.LOW);
31 | return board.digitalWrite(dirPin1, board.LOW);
32 | };
33 |
34 | firmata = require('firmata');
35 |
36 | board = new firmata.Board("/dev/cu.usbserial-A700ejJW", function(err) {
37 | if (err) {
38 | return console.log(err);
39 | }
40 | console.log('connected');
41 | board.pinMode(dirPin2, board.MODES.OUTPUT);
42 | board.pinMode(stepPin2, board.MODES.OUTPUT);
43 | goDown();
44 | return doStep();
45 | });
46 |
47 | stepRight = function() {
48 | board.digitalWrite(stepPin2, board.HIGH);
49 | return board.digitalWrite(stepPin2, board.LOW);
50 | };
51 |
52 | stepLeft = function() {
53 | board.digitalWrite(stepPin1, board.HIGH);
54 | return board.digitalWrite(stepPin1, board.LOW);
55 | };
56 |
57 | kill = false;
58 |
59 | stepNo = 0;
60 |
61 | prevWas = 'down';
62 |
63 | doStep = function() {
64 | stepRight();
65 | if (!kill) {
66 | setTimeout(doStep, 10);
67 | }
68 | return stepNo += 1;
69 | };
70 |
71 | process.on('SIGINT', function() {
72 | kill = true;
73 | console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
74 | console.log("" + stepNo + " steps done");
75 | board.digitalWrite(stepPin1, board.LOW);
76 | board.digitalWrite(stepPin2, board.LOW);
77 | return process.exit();
78 | });
79 |
80 | }).call(this);
81 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vertical-plotter",
3 | "version": "0.0.1",
4 | "main": "index.html",
5 | "dependencies": {
6 | "firmata": "latest",
7 | "svgmill": "0.0.1"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/plotter-simulator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
17 |
18 |
19 |
23 |
27 | Angles: ,
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/JS/VerticalPlotter/process.coffee:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/VerticalPlotter/process.coffee
--------------------------------------------------------------------------------
/JS/VerticalPlotter/process.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.6.3
2 | (function() {
3 |
4 |
5 | }).call(this);
6 |
--------------------------------------------------------------------------------
/JS/animated-number-field/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Animate things
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/JS/bravais/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Cristal Grid Translation
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
17 |
21 |
25 |
26 |
30 |
34 |
38 |
39 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
52 | |
53 | |
54 |
55 | |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/JS/bravais/js/ajax.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | function setOptions() {
3 | BRAVAIS.options.n_max = parseInt($("[name=nmax]").val(), 10);
4 | BRAVAIS.options.displaceVector = BRAVAIS.doDisplaceVector(
5 | parseFloat($("[name=ax]").val(), 10),
6 | parseFloat($("[name=ay]").val(), 10),
7 | parseFloat($("[name=az]").val(), 10)
8 | );
9 | BRAVAIS.options.angelsVector = BRAVAIS.doAnglesVector(
10 | parseFloat($("[name=alpha]").val(), 10),
11 | parseFloat($("[name=beta]").val(), 10),
12 | parseFloat($("[name=gamma]").val(), 10)
13 | );
14 | }
15 | function round(x){
16 | return Math.round(x*1000) / 1000;
17 | }
18 | function decimalizer(num){
19 | //TODO
20 | return num;
21 | }
22 | var button = $("#translate");
23 | button.click(function(){
24 | setOptions();
25 | var result = BRAVAIS.generateParticles($("#from").val());
26 | $("#to").val(result.map(function(p){
27 | return [p.value, p.point.x, p.point.y, p.point.z].map(round).map(decimalizer).join(" ");
28 | }).join("\n"));
29 | });
30 | });
--------------------------------------------------------------------------------
/JS/bravais/js/bravais.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var BRAVAIS = {};
4 | (function(){
5 |
6 | var that;
7 | BRAVAIS = that = {
8 | options:{
9 | n_max:1,
10 | displaceVector: null,
11 | angelsVector: null
12 | },
13 | doDisplaceVector: vectorConstructor('ax', 'ay', 'az'), //('a¹','a²','a³')
14 | doPointVector: vectorConstructor('x', 'y', 'z'),
15 | doAnglesVector: vectorConstructor('a', 'b', 'c'), //('ɑ','β','ɣ')
16 | doParticle: vectorConstructor('point', 'value'),
17 | generateParticles: function(rawData){
18 | var n_max = that.options.n_max,
19 | result = [];
20 | that.parseData(rawData).forEach(function(particle){
21 | var origPoint = particle.point, point,
22 | displaceVector = that.options.displaceVector;
23 | for(var xn = 0; xn < n_max+1; xn++){
24 | for(var yn = 0; yn < n_max+1; yn++){
25 | for(var zn = 0; zn < n_max+1; zn++){
26 | point = that.doPointVector( origPoint.x + xn * displaceVector.ax,
27 | origPoint.y + yn * displaceVector.ay,
28 | origPoint.z + zn * displaceVector.az);
29 | result.push(that.doParticle(point, particle.value));
30 | }
31 | }
32 | }
33 | });
34 | return result;
35 | },
36 | parseData: function(rawData){
37 | return rawData.split(/[\r|\n]+/).map(function(rawLine){
38 | var lineData = rawLine.split(/\s+/).map(parseFloat);
39 | var value = lineData.shift();
40 | return that.doParticle(that.doPointVector(lineData), value);
41 | });
42 | }
43 | };
44 | }());
--------------------------------------------------------------------------------
/JS/bravais/js/compatibility.js:
--------------------------------------------------------------------------------
1 | // Production steps of ECMA-262, Edition 5, 15.4.4.18
2 | // Reference: http://es5.github.com/#x15.4.4.18
3 | if ( !Array.prototype.forEach ) {
4 |
5 | Array.prototype.forEach = function( callback, thisArg ) {
6 |
7 | var T, k;
8 |
9 | if ( this == null ) {
10 | throw new TypeError( " this is null or not defined" );
11 | }
12 |
13 | // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
14 | var O = Object(this);
15 |
16 | // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
17 | // 3. Let len be ToUint32(lenValue).
18 | var len = O.length >>> 0; // Hack to convert O.length to a UInt32
19 |
20 | // 4. If IsCallable(callback) is false, throw a TypeError exception.
21 | // See: http://es5.github.com/#x9.11
22 | if ( {}.toString.call(callback) != "[object Function]" ) {
23 | throw new TypeError( callback + " is not a function" );
24 | }
25 |
26 | // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
27 | if ( thisArg ) {
28 | T = thisArg;
29 | }
30 |
31 | // 6. Let k be 0
32 | k = 0;
33 |
34 | // 7. Repeat, while k < len
35 | while( k < len ) {
36 |
37 | var kValue;
38 |
39 | // a. Let Pk be ToString(k).
40 | // This is implicit for LHS operands of the in operator
41 | // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
42 | // This step can be combined with c
43 | // c. If kPresent is true, then
44 | if ( k in O ) {
45 |
46 | // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
47 | kValue = O[ k ];
48 |
49 | // ii. Call the Call internal method of callback with T as the this value and
50 | // argument list containing kValue, k, and O.
51 | callback.call( T, kValue, k, O );
52 | }
53 | // d. Increase k by 1.
54 | k++;
55 | }
56 | // 8. return undefined
57 | };
58 | }
59 |
60 | if(!Array.isArray) {
61 | Array.isArray = function (arg) {
62 | return Object.prototype.toString.call(arg) == '[object Array]';
63 | };
64 | }
--------------------------------------------------------------------------------
/JS/bravais/tests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Tests
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/JS/canvas-life-game/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | JS Bin
6 |
7 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/JS/canvas-pong-client/canvas-game.js:
--------------------------------------------------------------------------------
1 | const W = 84; // Original Atari Size
2 | const H = 84; //
3 | const UP = 'UP';
4 | const DOWN = 'DOWN';
5 |
6 | const magnify = 3;
7 |
8 | const initCanvas = (id, width, height) => {
9 | const canvas = document.getElementById('main');
10 | canvas.width = W;
11 | canvas.height = H;
12 | canvas.style.width = `${W * magnify}px`;
13 | const context = canvas.getContext('2d');
14 | context.width = W;
15 | context.height = H;
16 | return context;
17 | }
18 |
19 | const context = initCanvas('main', W, H);
20 | const pong = makePongGame(W, H, context);
21 |
22 | let keysPressed = {};
23 | const PLAYER1_ARROWUP_KEY_CODE = 87;
24 | const PLAYER1_ARROWDOWN_KEY_CODE = 83;
25 | const PLAYER2_ARROWUP_KEY_CODE = 38;
26 | const PLAYER2_ARROWDOWN_KEY_CODE = 40;
27 |
28 | const timeAverage = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
29 | const timeElement = document.getElementById('time');
30 |
31 | const redraw = () => {
32 | if (keysPressed[PLAYER1_ARROWUP_KEY_CODE]) {
33 | pong.move(pong.PLAYER1, UP);
34 | }
35 | if (keysPressed[PLAYER1_ARROWDOWN_KEY_CODE]) {
36 | pong.move(pong.PLAYER1, DOWN);
37 | }
38 | if (keysPressed[PLAYER2_ARROWUP_KEY_CODE]) {
39 | pong.move(pong.PLAYER2, UP);
40 | }
41 | if (keysPressed[PLAYER2_ARROWDOWN_KEY_CODE]) {
42 | pong.move(pong.PLAYER2, DOWN);
43 | }
44 |
45 | const start = Date.now();
46 | pong.tick();
47 | const data = pong.generateData();
48 | const time = Date.now() - start;
49 | pong.applyData(data);
50 |
51 | timeAverage.push(time);
52 | timeAverage.shift();
53 | const avgTime = timeAverage.reduce((memo, el) => el + memo, 0) / timeAverage.length;
54 | timeElement.innerHTML = avgTime.toFixed(3);
55 |
56 | requestAnimationFrame(redraw);
57 | }
58 |
59 | document.addEventListener('keydown', (e) => {
60 | keysPressed[e.keyCode || e.which] = true;
61 | });
62 | document.addEventListener('keyup', (e) => {
63 | keysPressed[e.keyCode || e.which] = false;
64 | });
65 |
66 | redraw();
67 |
--------------------------------------------------------------------------------
/JS/canvas-pong-client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Keys W/S for Player1 and Up/Down arrow keys for Player2
12 | Tick, draw and getImageData took: ms
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/JS/canvas-pong-client/styles.css:
--------------------------------------------------------------------------------
1 | body, html {
2 | color: white;
3 | background: rgb(30,30,30);
4 | }
5 |
6 | .centered{
7 | text-align: center;
8 | }
9 |
10 | #main {
11 | margin: 0 auto;
12 | display: block;
13 | position: relative;
14 | }
--------------------------------------------------------------------------------
/JS/celullar automaton/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/JS/common.js:
--------------------------------------------------------------------------------
1 | function Vector(varNames, values){
2 | var that = this;
3 | varNames.slice(0, values.length).forEach(function(varName, i){
4 | that[varName] = values[i];
5 | });
6 |
7 | Object.defineProperty(this, 'object', {
8 | get: function(){
9 | var map = {};
10 | for(var key in this){
11 | var val = this[key];
12 | map[key] = val.object || val;
13 | }
14 | return map;
15 | }
16 | });
17 | Object.defineProperty(this, 'keys', { value: varNames});
18 | Object.defineProperty(this, 'values', { value: values });
19 | }
20 |
21 | function vectorConstructor(){
22 | var varNames = Array.prototype.slice.call(arguments);
23 | return function(){
24 | var values = Array.prototype.slice.call(arguments);
25 | if(Array.isArray(values[0])){
26 | values = values[0];
27 | }
28 | return new Vector(varNames, values);
29 | }
30 | }
31 |
32 | Array.prototype.sum = function() {
33 | var sum = 0;
34 | this.forEach(function(k) {
35 | sum += k;
36 | });
37 | return sum;
38 | };
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | package-lock.json
3 |
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Webpack App
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "drawing-robot-2d-simulation",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "@types/matter-js": "^0.10.2",
8 | "matter-js": "^0.14.2",
9 | "ts-loader": "^6.0.2",
10 | "typescript": "^3.5.2",
11 | "webpack": "^4.34.0",
12 | "webpack-cli": "^3.3.4"
13 | },
14 | "devDependencies": {
15 | "html-webpack-plugin": "^3.2.0"
16 | },
17 | "scripts": {
18 | "webpack-watch": "webpack --watch --colors",
19 | "test": "echo \"Error: no test specified\" && exit 1"
20 | },
21 | "author": "",
22 | "license": "ISC"
23 | }
24 |
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/src/main.ts:
--------------------------------------------------------------------------------
1 | import * as Matter from 'matter-js';
2 |
3 | const {
4 | Engine, Render, World, Bodies, Body, Composites, Constraint, Mouse, MouseConstraint
5 | } = Matter;
6 |
7 | // create an engine
8 | const engine = Engine.create();
9 |
10 | // create a renderer
11 | const render = Render.create({
12 | element: document.body,
13 | engine: engine,
14 | options: {
15 | width: 800,
16 | height: 600,
17 | showAngleIndicator: true
18 | }
19 | });
20 |
21 | const arm = Bodies.rectangle(200, 200, 200, 50);
22 |
23 | const constraint = Constraint.create({
24 | pointA: {x: 300, y: 100},
25 | bodyB: arm,
26 | pointB: {x: 100, y: 0}
27 | });
28 |
29 |
30 | const ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });
31 |
32 | // add all of the bodies to the world
33 | World.add(engine.world, [constraint, arm, ground]);
34 |
35 | var mouse = Mouse.create(render.canvas),
36 | mouseConstraint = MouseConstraint.create(engine, {
37 | mouse: mouse,
38 | constraint: {
39 | stiffness: 0.2,
40 | render: {
41 | visible: false
42 | }
43 | }
44 | });
45 |
46 | World.add(engine.world, mouseConstraint);
47 |
48 | render.mouse = mouse;
49 |
50 | // run the engine
51 | Engine.run(engine);
52 |
53 | // run the renderer
54 | Render.run(render);
55 |
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["src/**/*"],
3 | "compilerOptions": {
4 | "outDir": "./dist",
5 | "sourceMap": true,
6 | "noImplicitAny": true,
7 | "module": "es6",
8 | "target": "es5",
9 | "jsx": "react",
10 | "allowJs": true,
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/JS/drawing-robot-2d-simulation/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
3 |
4 | const isProduction = typeof NODE_ENV !== 'undefined' && NODE_ENV === 'production';
5 | const mode = isProduction ? 'production' : 'development';
6 | const devtool = isProduction ? false : 'inline-source-map';
7 |
8 | module.exports =
9 | {
10 | entry: './src/main.ts',
11 | target: 'web',
12 | mode,
13 | devtool,
14 | module: {
15 | rules: [
16 | {
17 | test: /\.tsx?$/,
18 | use: 'ts-loader',
19 | exclude: /node_modules/,
20 | }
21 | ]
22 | },
23 | resolve: {
24 | extensions: [ '.tsx', '.ts', '.js' ]
25 | },
26 | output: {
27 | filename: 'main.js',
28 | path: path.join(__dirname, 'dist')
29 | },
30 | plugins: [new HtmlWebpackPlugin()]
31 | };
32 |
--------------------------------------------------------------------------------
/JS/drawing-robot-ab-xy-simulator/.flowconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/drawing-robot-ab-xy-simulator/.flowconfig
--------------------------------------------------------------------------------
/JS/drawing-robot-ab-xy-simulator/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": false,
3 | "esversion": "7",
4 | "browser": true,
5 | "esnext": true,
6 | "bitwise": true,
7 | "camelcase": true,
8 | "curly": true,
9 | "eqeqeq": true,
10 | "immed": true,
11 | "indent": 2,
12 | "latedef": true,
13 | "newcap": true,
14 | "noarg": true,
15 | "quotmark": "single",
16 | "regexp": true,
17 | "undef": true,
18 | "unused": true,
19 | "strict": false,
20 | "trailing": true,
21 | "smarttabs": true,
22 | "jquery": true
23 | }
24 |
--------------------------------------------------------------------------------
/JS/drawing-robot-ab-xy-simulator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Acc/Dec
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/JS/drawing-robot-ab-xy-simulator/planner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Planner
6 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS/drawing-robot-ab-xy-simulator/planner.js:
--------------------------------------------------------------------------------
1 | const W = 900;
2 | const H = 600;
3 |
4 | const setupCanvas = (canvasId, canvasWith, canvasHeight) => {
5 | const canvasEl = document.getElementById(canvasId);
6 | const dpr = window.devicePixelRatio || 1;
7 | const ctx = canvasEl.getContext('2d');
8 | canvasEl.width = canvasWith * 2;
9 | canvasEl.height = canvasHeight * 2;
10 | canvasEl.style.width = `${canvasWith}px`;
11 | canvasEl.style.height = `${canvasHeight}px`;
12 | ctx.scale(dpr, dpr);
13 | return ctx;
14 | };
15 |
16 | const setupSvg = (svgId, svgWith, svgHeight) => {
17 | const svg = document.getElementById('svg');
18 | svg.width = svgWith;
19 | svg.height = svgHeight;
20 | svg.style.width = `${svgWith}px`;
21 | svg.style.height = `${svgHeight}px`;
22 | svg.setAttribute('viewBox',`0 0 ${svgWith} ${svgHeight}`);
23 | svg.classList.add('show');
24 | return svg;
25 | };
26 |
27 | const ctx = setupCanvas('canvas', W, H);
28 | const svg = setupSvg('svg', W, H);
29 |
30 | const addCircle = (svg, x, y, r) => {
31 | const circle = document.createElementNS(
32 | 'http://www.w3.org/2000/svg',
33 | 'circle'
34 | );
35 | circle.setAttribute('cx', x);
36 | circle.setAttribute('cy', y);
37 | circle.setAttribute('r', r);
38 | svg.appendChild(circle);
39 |
40 | return circle;
41 | };
42 |
43 |
44 | const circle = addCircle(svg, 50, 50, 20);
45 | circle.addEventListener('mousedown', console.log);
46 |
--------------------------------------------------------------------------------
/JS/evolution-strategies/es-optimization.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ES Optimization
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/JS/evolution-strategies/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/JS/evolution-strategies/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "point-in-polygon": {
6 | "version": "1.0.1",
7 | "resolved": "https://registry.npmjs.org/point-in-polygon/-/point-in-polygon-1.0.1.tgz",
8 | "integrity": "sha1-1Ztk6P7kHElFiqyCtWcYxZV7Kvc="
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/JS/evolution-strategies/style.css:
--------------------------------------------------------------------------------
1 | #main, #data {
2 | margin: 0 auto;
3 | display: block;
4 | position: relative;
5 | }
6 | #data{
7 | top:-600px;
8 | }
--------------------------------------------------------------------------------
/JS/evolution-strategies/webclgl.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/JS/evolution-strategies/webclgl.js:
--------------------------------------------------------------------------------
1 | // FILL ARRAYS A AND B
2 | var _length = 512 * 512;
3 | var arrayA = [];
4 | var arrayB = [];
5 | for(var n = 0; n < _length; n++) {
6 | var randA = Math.random()/2.0;
7 | var randB = Math.random()/2.0;
8 | arrayA.push(randA);
9 | arrayB.push(randB);
10 | }
11 |
12 | var gpu = new GPU();
13 | // Create the GPU accelerated function from a kernel
14 | // function that computes a single element in the
15 | // 512 x 512 matrix (2D array). The kernel function
16 | // is run in a parallel manner in the GPU resulting
17 | // in very fast computations! (...sometimes)
18 | var mat_mult = gpu.createKernel(function(A, B) {
19 | return A[this.thread.x] + B[this.thread.y];
20 | }).dimensions([3, 3]);
21 |
22 | // Perform matrix multiplication on 2 matrices of size 512 x 512
23 | var C = mat_mult(, [4,5,6]);
24 | console.log(C);
--------------------------------------------------------------------------------
/JS/evolution-strategies/ziggurat.js:
--------------------------------------------------------------------------------
1 | function Ziggurat(seed) {
2 | seed = arguments.length
3 | ? seed
4 | : new Date().getTime();
5 |
6 | let jsr = 123456789;
7 |
8 | const wn = new Array(128);
9 | const fn = new Array(128);
10 | const kn = new Array(128);
11 |
12 | const RNOR = () => {
13 | const hz = SHR3();
14 | const iz = hz & 127;
15 | return (Math.abs(hz) < kn[iz]) ? hz * wn[iz] : nfix(hz, iz);
16 | };
17 |
18 | this.nextGaussian = function(){
19 | return RNOR();
20 | };
21 |
22 | const nfix = (hz, iz) => {
23 | const r = 3.442619855899;
24 | const r1 = 1.0 / r;
25 | let x;
26 | let y;
27 | while(true){
28 | x = hz * wn[iz];
29 | if( iz === 0 ){
30 | x = (-Math.log(UNI()) * r1);
31 | y = -Math.log(UNI());
32 | while( y + y < x * x){
33 | x = (-Math.log(UNI()) * r1);
34 | y = -Math.log(UNI());
35 | }
36 | return ( hz > 0 ) ? r+x : -r-x;
37 | }
38 |
39 | if( fn[iz] + UNI() * (fn[iz-1] - fn[iz]) < Math.exp(-0.5 * x * x) ){
40 | return x;
41 | }
42 | hz = SHR3();
43 | iz = hz & 127;
44 |
45 | if( Math.abs(hz) < kn[iz]){
46 | return (hz * wn[iz]);
47 | }
48 | }
49 | };
50 |
51 | const SHR3 = () => {
52 | let jz = jsr;
53 | let jzr = jsr;
54 | jzr ^= (jzr << 13);
55 | jzr ^= (jzr >>> 17);
56 | jzr ^= (jzr << 5);
57 | jsr = jzr;
58 | return (jz+jzr) | 0;
59 | };
60 |
61 | const UNI = () => 0.5 * (1 + SHR3() / -Math.pow(2,31));
62 |
63 | function zigset(seed) {
64 | // seed generator based on current time
65 | jsr ^= seed;
66 |
67 | const m1 = 2147483648.0;
68 | let dn = 3.442619855899;
69 | let tn = dn;
70 | const vn = 9.91256303526217e-3;
71 |
72 | const q = vn / Math.exp(-0.5 * dn * dn);
73 | kn[0] = Math.floor((dn/q)*m1);
74 | kn[1] = 0;
75 |
76 | wn[0] = q / m1;
77 | wn[127] = dn / m1;
78 |
79 | fn[0] = 1.0;
80 | fn[127] = Math.exp(-0.5 * dn * dn);
81 |
82 | for(let i = 126; i >= 1; i--){
83 | dn = Math.sqrt(-2.0 * Math.log( vn / dn + Math.exp( -0.5 * dn * dn)));
84 | kn[i+1] = Math.floor((dn/tn)*m1);
85 | tn = dn;
86 | fn[i] = Math.exp(-0.5 * dn * dn);
87 | wn[i] = dn / m1;
88 | }
89 | }
90 |
91 | zigset(seed);
92 | }
--------------------------------------------------------------------------------
/JS/fisheye-lines/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | .cache
--------------------------------------------------------------------------------
/JS/fisheye-lines/dist/app.6bf29a0e.css:
--------------------------------------------------------------------------------
1 | body{box-sizing:border-box;padding:0;margin:0;background-color:#283747;color:#fff;font-family:Montserrat,sans-serif}.container{display:flex;flex-direction:column;justify-content:center;align-items:flex-start}
2 | /*# sourceMappingURL=https://soswow.github.io/Various-JS-and-Python/JS/fisheye-lines/dist/app.6bf29a0e.css.map */
--------------------------------------------------------------------------------
/JS/fisheye-lines/dist/app.6bf29a0e.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["src/styles.scss"],"names":[],"mappings":"AAGA,KACC,qBAAA,CACA,SAAA,CACA,QAAA,CACG,wBAPO,CAQP,UAAA,CACA,kCAGJ,WACI,YAAA,CACA,qBAAA,CACA,sBAAA,CACA","file":"app.6bf29a0e.css","sourceRoot":"..","sourcesContent":["$bg-color: #283747;\n$txt-color: white;\n\nbody {\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n background-color: $bg-color;\n color: white;\n font-family: 'Montserrat', sans-serif;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n}"]}
--------------------------------------------------------------------------------
/JS/fisheye-lines/dist/index.html:
--------------------------------------------------------------------------------
1 | Flow field
--------------------------------------------------------------------------------
/JS/fisheye-lines/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Flow field
4 |
5 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/JS/fisheye-lines/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fisheye-lines",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "parcel index.html --open",
8 | "build": "parcel build index.html --public-url https://soswow.github.io/Various-JS-and-Python/JS/fisheye-lines/dist/"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "@types/dat.gui": "^0.7.7",
14 | "@types/p5": "^1.4.2",
15 | "dat.gui": "^0.7.9",
16 | "p5": "^1.4.2",
17 | "p5.js-svg": "^1.3.3",
18 | "parcel-bundler": "^1.12.5",
19 | "sass": "^1.54.0",
20 | "typescript": "^4.7.4"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/JS/fisheye-lines/src/styles.scss:
--------------------------------------------------------------------------------
1 | $bg-color: #283747;
2 | $txt-color: white;
3 |
4 | body {
5 | box-sizing: border-box;
6 | padding: 0;
7 | margin: 0;
8 | background-color: $bg-color;
9 | color: white;
10 | font-family: 'Montserrat', sans-serif;
11 | }
12 |
13 | .container {
14 | display: flex;
15 | flex-direction: column;
16 | justify-content: center;
17 | align-items: flex-start;
18 | }
--------------------------------------------------------------------------------
/JS/fisheye-lines/src/types.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Vector,
3 | } from "p5";
4 |
5 | export interface VanishingPointPair {
6 | p1?: Vector;
7 | p2?: Vector;
8 | }
9 |
10 | export interface Settings {
11 | verticalOffset: number,
12 | horizontalOffset: number,
13 | verticalGridSize: number,
14 | horizontalGridSize: number,
15 | verticalUpDownShift: number,
16 | verticalRightLeftShift: number,
17 | horizontalUpDownShift: number,
18 | horizontalRightLeftShift: number,
19 | centralGridSize: number;
20 | type: '5 point' | '3 point',
21 | presets: Record;
22 | export: Function,
23 | debug1: number,
24 | debug2: number,
25 | }
26 |
27 | export type RawLine = Vector[];
28 |
29 | export interface CurvedSegment {
30 | center: Vector;
31 | diameter: number;
32 | startAngle: number;
33 | finishAngle: number;
34 | vpPair: VanishingPointPair;
35 | p1: Vector;
36 | p2: Vector;
37 | }
38 |
39 | export interface CentralVPSegment {
40 | center: Vector;
41 | angle: number;
42 | startDistance: number;
43 | finishDistance: number;
44 | }
--------------------------------------------------------------------------------
/JS/fisheye-lines/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "jsx": "preserve",
5 | "esModuleInterop": true,
6 | "sourceMap": true,
7 | "allowJs": true,
8 | "lib": [
9 | "es6",
10 | "dom"
11 | ],
12 | "rootDir": "src",
13 | "moduleResolution": "node"
14 | }
15 | }
--------------------------------------------------------------------------------
/JS/flow-field/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | .cache
--------------------------------------------------------------------------------
/JS/flow-field/dist/app.533c3afa.css:
--------------------------------------------------------------------------------
1 | body{box-sizing:border-box;padding:0;margin:0;background-color:#283747;color:#fff;font-family:Montserrat,sans-serif}.container{display:flex;flex-direction:column;justify-content:center;align-items:center}
2 | /*# sourceMappingURL=https://soswow.github.io/Various-JS-and-Python/JS/flow-field/dist/app.533c3afa.css.map */
--------------------------------------------------------------------------------
/JS/flow-field/dist/app.533c3afa.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["src/styles.scss"],"names":[],"mappings":"AAGA,KACC,qBAAA,CACA,SAAA,CACA,QAAA,CACG,wBAPO,CAQP,UAAA,CACA,kCAGJ,WACI,YAAA,CACA,qBAAA,CACA,sBAAA,CACA","file":"app.533c3afa.css","sourceRoot":"..","sourcesContent":["$bg-color: #283747;\n$txt-color: white;\n\nbody {\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n background-color: $bg-color;\n color: white;\n font-family: 'Montserrat', sans-serif;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}"]}
--------------------------------------------------------------------------------
/JS/flow-field/dist/app.5cec07dd.css:
--------------------------------------------------------------------------------
1 | body {
2 | box-sizing: border-box;
3 | padding: 0;
4 | margin: 0;
5 | background-color: #283747;
6 | color: white;
7 | font-family: "Montserrat", sans-serif;
8 | }
9 |
10 | .container {
11 | display: flex;
12 | flex-direction: column;
13 | justify-content: center;
14 | align-items: center;
15 | }
16 |
17 | /*# sourceMappingURL=/app.5cec07dd.css.map */
--------------------------------------------------------------------------------
/JS/flow-field/dist/app.5cec07dd.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["src/styles.scss"],"names":[],"mappings":"AAGA;EACC;EACA;EACA;EACG,kBAPO;EAQP;EACA;;;AAGJ;EACI;EACA;EACA;EACA","file":"app.5cec07dd.css","sourceRoot":"..","sourcesContent":["$bg-color: #283747;\n$txt-color: white;\n\nbody {\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n background-color: $bg-color;\n color: white;\n font-family: 'Montserrat', sans-serif;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}"]}
--------------------------------------------------------------------------------
/JS/flow-field/dist/index.html:
--------------------------------------------------------------------------------
1 | Flow field
--------------------------------------------------------------------------------
/JS/flow-field/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Flow field
4 |
5 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/JS/flow-field/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flow-field",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.html",
6 | "scripts": {
7 | "start": "parcel index.html --open",
8 | "build": "parcel build index.html --public-url https://soswow.github.io/Various-JS-and-Python/JS/flow-field/dist/"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "@types/dat.gui": "^0.7.7",
14 | "@types/ndarray": "^1.0.11",
15 | "@types/p5": "^1.4.0",
16 | "canvas-capture": "^1.1.9",
17 | "dat.gui": "^0.7.7",
18 | "fit-curve": "^0.2.0",
19 | "ndarray": "^1.0.19",
20 | "open-simplex-noise": "^2.5.0",
21 | "p5": "^1.4.1"
22 | },
23 | "devDependencies": {
24 | "parcel-bundler": "^1.12.5",
25 | "sass": "^1.49.7",
26 | "typescript": "^4.5.5"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/JS/flow-field/src/MyCircle.ts:
--------------------------------------------------------------------------------
1 | import P5 from "p5";
2 |
3 | export default class MyCircle {
4 | private p5: P5;
5 | private pos: P5.Vector;
6 | private size: number;
7 |
8 | constructor(p5: P5, atPosition: P5.Vector, size: number) {
9 | this.p5 = p5;
10 | this.pos = atPosition;
11 | this.size = size;
12 | }
13 |
14 | draw() {
15 | const p5 = this.p5; // just for convenience
16 |
17 | p5.push();
18 |
19 | p5.translate(this.pos);
20 | p5.noStroke();
21 | p5.fill("orange");
22 | p5.ellipse(0, 0, this.size);
23 |
24 | p5.pop();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/JS/flow-field/src/styles.scss:
--------------------------------------------------------------------------------
1 | $bg-color: #283747;
2 | $txt-color: white;
3 |
4 | body {
5 | box-sizing: border-box;
6 | padding: 0;
7 | margin: 0;
8 | background-color: $bg-color;
9 | color: white;
10 | font-family: 'Montserrat', sans-serif;
11 | }
12 |
13 | .container {
14 | display: flex;
15 | flex-direction: column;
16 | justify-content: center;
17 | align-items: center;
18 | }
--------------------------------------------------------------------------------
/JS/flow-field/src/utils.ts:
--------------------------------------------------------------------------------
1 | import { NdArray } from "ndarray";
2 | import P5, { Vector } from "p5";
3 |
4 | const bilinearInterpolation = (p5: P5, Q11: number, Q21: number, Q12: number, Q22: number, xportion: number, yportion: number) => {
5 | // https://en.wikipedia.org/wiki/Bilinear_interpolation
6 | const xy1 = p5.lerp(Q11, Q21, xportion);
7 | const xy2 = p5.lerp(Q12, Q22, xportion);
8 | return p5.lerp(xy1, xy2, yportion);
9 | }
10 |
11 | export const getVectorValue = (p5: P5, point: Vector, vectorField: NdArray, cellSize: number) => {
12 | // Simple way
13 | // const vx = Math.floor(point.x / settings.cellSize);
14 | // const vy = Math.floor(point.y / settings.cellSize);
15 | // const cellVector = vectorField.get(vx, vy);
16 | const [width, height] = vectorField.shape;
17 | const vx = point.x / cellSize;
18 | const vy = point.y / cellSize;
19 | const vxlow = Math.floor(vx);
20 | const vylow = Math.floor(vy);
21 | let vxhigh = Math.ceil(vx);
22 | let vyhigh = Math.ceil(vy);
23 | if(vxhigh >= width){
24 | vxhigh = vxlow;
25 | }
26 | if(vyhigh >= height){
27 | vyhigh = vylow;
28 | }
29 | const vxperc = vx - vxlow;
30 | const vyperc = vy - vylow;
31 | const topleft = vectorField.get(vxlow, vylow);
32 | const topright = vectorField.get(vxhigh, vylow) || topleft;
33 | const bottomleft = vectorField.get(vxlow, vyhigh) || topleft;
34 | const bottomright = vectorField.get(vxhigh, vyhigh) || topright;
35 |
36 | const xValue = bilinearInterpolation(p5, topleft.x, topright.x, bottomleft.x, bottomright.x, vxperc, vyperc);
37 | const yValue = bilinearInterpolation(p5, topleft.y, topright.y, bottomleft.y, bottomright.y, vxperc, vyperc);
38 | return p5.createVector(xValue, yValue);
39 | };
--------------------------------------------------------------------------------
/JS/flow-field/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "jsx": "preserve",
5 | "esModuleInterop": true,
6 | "sourceMap": true,
7 | "allowJs": true,
8 | "lib": [
9 | "es6",
10 | "dom"
11 | ],
12 | "rootDir": "src",
13 | "moduleResolution": "node"
14 | }
15 | }
--------------------------------------------------------------------------------
/JS/force-acceleration-drag/1d.example.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/JS/force-acceleration-drag/1d.example.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var state = {
3 | x: -1, //position
4 | sx: 0 //speed
5 | };
6 | var cons = {
7 | maxSpeed: 1,
8 | acceleration: 0.001,
9 | friction: 0.98
10 | };
11 |
12 | var keyStatus = {
13 | left: false,
14 | right: false,
15 | horizontal: function(){
16 | if(this.left === this.right){
17 | return 0;
18 | }else if(this.left){
19 | return -1;
20 | }else{
21 | return 1;
22 | }
23 | }
24 | };
25 |
26 | $(document).on('keyup keydown', function(e){
27 | if(e.keyCode == 37){
28 | keyStatus.left = e.type == 'keydown';
29 | }else if(e.keyCode == 39){
30 | keyStatus.right = e.type == 'keydown';
31 | }
32 | });
33 |
34 | var object = $("#object");
35 | var container = $("#container");
36 | var log1 = $("#log1");
37 | var containerWidth = container.width();
38 | var objectWidth = object.width();
39 |
40 | var stateLoop = function(dt){
41 | state.sx += cons.acceleration * keyStatus.horizontal() * dt;
42 | if(state.sx > cons.maxSpeed) {
43 | state.sx = cons.maxSpeed;
44 | }
45 |
46 | state.sx *= cons.friction;
47 | if(Math.abs(state.sx) < 0.009){
48 | state.sx = 0;
49 | }
50 |
51 | var newx = state.x + dt * state.sx;
52 | if(newx < -1){
53 | newx = containerWidth - 1;
54 | }
55 | if(newx > containerWidth - objectWidth && state.sx > 0){
56 | newx = - 1;
57 | }
58 | log1.html(state.sx + " " + Math.round(newx));
59 | state.x = newx;
60 | };
61 | var uiLoop = function(){
62 | object.css('left', state.x);
63 | };
64 |
65 |
66 |
67 | var makeLooper = function(loop){
68 | return function looper(frameTime) {
69 | var t = frameTime - prevT;
70 | loop(t);
71 | prevT = frameTime;
72 | return requestAnimFrame(looper);
73 | };
74 | };
75 | var stateLooper = makeLooper(stateLoop);
76 | var uiLooper = makeLooper(uiLoop);
77 |
78 | var prevT = Date.now();
79 | stateLooper(prevT);
80 | uiLooper(prevT)
81 | });
--------------------------------------------------------------------------------
/JS/force-acceleration-drag/2d.example.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
27 |
28 |
29 |
30 |
31 | Control:
32 |
35 |
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/JS/force-acceleration-drag/arrow_right_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/force-acceleration-drag/arrow_right_32x32.png
--------------------------------------------------------------------------------
/JS/force-gravity-experiment/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Smoother Animation
4 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |