├── .gitignore ├── Datamining ├── Books parsing │ ├── books.py │ ├── draw.py │ ├── test copy 2.png │ ├── test copy.png │ └── test.png ├── apriori │ └── parse.py ├── datamining.js ├── google-finance-parser │ ├── edges.csv │ ├── miner.py │ ├── nodes.csv │ └── test.html ├── test.html └── ttu-user-account-parser │ └── main.py ├── Dynamic Programming └── zero-one-matrix.py ├── JS ├── AddressBook │ ├── .bowerrc │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .jshintrc │ ├── Gruntfile.coffee │ ├── README.md │ ├── TestResult.png │ ├── app │ │ ├── .htaccess │ │ ├── 404.html │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── robots.txt │ │ ├── scripts │ │ │ ├── boot.coffee │ │ │ ├── main.coffee │ │ │ ├── memory-storage.coffee │ │ │ ├── models.coffee │ │ │ ├── vendor │ │ │ │ └── bootstrap │ │ │ │ │ ├── affix.js │ │ │ │ │ ├── alert.js │ │ │ │ │ ├── button.js │ │ │ │ │ ├── carousel.js │ │ │ │ │ ├── collapse.js │ │ │ │ │ ├── dropdown.js │ │ │ │ │ ├── modal.js │ │ │ │ │ ├── popover.js │ │ │ │ │ ├── scrollspy.js │ │ │ │ │ ├── tab.js │ │ │ │ │ ├── tooltip.js │ │ │ │ │ └── transition.js │ │ │ └── views.coffee │ │ └── styles │ │ │ ├── bootstrap │ │ │ ├── _alerts.scss │ │ │ ├── _badges.scss │ │ │ ├── _breadcrumbs.scss │ │ │ ├── _button-groups.scss │ │ │ ├── _buttons.scss │ │ │ ├── _carousel.scss │ │ │ ├── _close.scss │ │ │ ├── _code.scss │ │ │ ├── _component-animations.scss │ │ │ ├── _dropdowns.scss │ │ │ ├── _forms.scss │ │ │ ├── _grid.scss │ │ │ ├── _input-groups.scss │ │ │ ├── _jumbotron.scss │ │ │ ├── _labels.scss │ │ │ ├── _list-group.scss │ │ │ ├── _media.scss │ │ │ ├── _mixins.scss │ │ │ ├── _modals.scss │ │ │ ├── _navbar.scss │ │ │ ├── _navs.scss │ │ │ ├── _normalize.scss │ │ │ ├── _pager.scss │ │ │ ├── _pagination.scss │ │ │ ├── _panels.scss │ │ │ ├── _popovers.scss │ │ │ ├── _print.scss │ │ │ ├── _progress-bars.scss │ │ │ ├── _responsive-utilities.scss │ │ │ ├── _scaffolding.scss │ │ │ ├── _tables.scss │ │ │ ├── _thumbnails.scss │ │ │ ├── _tooltip.scss │ │ │ ├── _type.scss │ │ │ ├── _utilities.scss │ │ │ ├── _variables.scss │ │ │ ├── _wells.scss │ │ │ └── bootstrap.scss │ │ │ └── main.scss │ ├── bower.json │ ├── dist │ │ ├── .htaccess │ │ ├── 404.html │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── robots.txt │ │ ├── scripts │ │ │ ├── 0729250d.vendor.js │ │ │ ├── 4e75e8bd.main.js │ │ │ └── vendor │ │ │ │ └── f7f27360.modernizr.js │ │ └── styles │ │ │ ├── 88db0965.main.css │ │ │ ├── cb4ae5ce.vendor.css │ │ │ └── font │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ ├── karma.conf.coffee │ ├── package.json │ └── test │ │ ├── casperjs │ │ └── simple-test.coffee │ │ └── spec │ │ ├── ContactSpec.coffee │ │ ├── GroupSpec.coffee │ │ └── SmokeSpec.coffee ├── Ai-class │ ├── 5-6unit.js │ └── motion-model.js ├── BlueToggl │ ├── 404.html │ ├── favicon.ico │ ├── images │ │ ├── 24a891da.outer.png │ │ ├── 37637e2d.center.png │ │ ├── 5d462625.glyphicons-halflings-white.png │ │ └── 9cc6609b.glyphicons-halflings.png │ ├── index.html │ ├── robots.txt │ ├── scripts │ │ ├── 000fe0ee.plugins.js │ │ ├── 0647c018.main.js │ │ ├── 7bbebd55.coffee.js │ │ ├── main.coffee │ │ └── vendor │ │ │ └── 0e15c528.modernizr.js │ └── styles │ │ └── 18bd0726.main.css ├── Chemistry │ ├── ajax.js │ ├── buildLattice.html │ ├── calcYakub.html │ ├── cg900656z_si_001 (1).pdf │ ├── chemical-funcs.js │ ├── eugen.js │ ├── index.html │ ├── renderIons.html │ └── tests.html ├── HDRAssembler │ ├── assembler.coffee │ ├── assembler.js │ ├── expansions.coffee │ ├── expansions.js │ └── package.json ├── HubbleDownloader │ ├── main.js │ └── package.json ├── MonoPong │ └── js │ │ ├── main.js │ │ └── utils.js ├── NumberToWordsMath │ ├── chains.dot │ └── russianNumbers.js ├── OpenCV.js-receipt │ ├── dat.gui.css │ ├── dat.gui.js │ ├── images │ │ ├── 09-DD_receipts-2.jpg │ │ ├── IMG_20180226_212741.jpg │ │ ├── IMG_20180226_212747.jpg │ │ ├── IMG_20180226_212805.jpg │ │ ├── IMG_20180226_212908.jpg │ │ ├── IMG_20180226_212919.jpg │ │ ├── IMG_20180226_213005.jpg │ │ ├── IMG_20180226_213053.jpg │ │ ├── IMG_20180226_213114.jpg │ │ ├── IMG_20180226_213125.jpg │ │ ├── IMG_20180227_125726.jpg │ │ ├── IMG_20180301_191122.jpg │ │ ├── IMG_20180301_191148.jpg │ │ ├── IMG_20180301_191200.jpg │ │ ├── IMG_20180302_104542.jpg │ │ ├── IMG_20180302_110406.jpg │ │ ├── IMG_20180302_111131.jpg │ │ ├── IMG_20180302_114002.jpg │ │ ├── health_receipt_target.jpg │ │ └── photo35.jpg │ ├── index.html │ ├── opencv.js │ └── perspective-test.js ├── ParticleFilter │ ├── gridworld.coffee │ ├── gridworld.js │ ├── images │ │ ├── ui-bg_diagonals-small_0_aaaaaa_40x40.png │ │ ├── ui-bg_diagonals-thick_15_444444_40x40.png │ │ ├── ui-bg_diagonals-thick_95_ffdc2e_40x40.png │ │ ├── ui-bg_glass_55_fbf5d0_1x400.png │ │ ├── ui-bg_highlight-hard_30_285c00_1x100.png │ │ ├── ui-bg_highlight-soft_33_3a8104_1x100.png │ │ ├── ui-bg_highlight-soft_50_4eb305_1x100.png │ │ ├── ui-bg_highlight-soft_60_4ca20b_1x100.png │ │ ├── ui-bg_inset-soft_10_285c00_1x100.png │ │ ├── ui-icons_4eb305_256x240.png │ │ ├── ui-icons_72b42d_256x240.png │ │ ├── ui-icons_cd0a0a_256x240.png │ │ └── ui-icons_ffffff_256x240.png │ ├── index.html │ ├── jquery-ui-1.8.18.custom.css │ ├── script.coffee │ ├── script.js │ ├── unit4.html │ ├── unit5.coffee │ ├── unit5.html │ └── unit5.js ├── UI-design │ ├── .bowerrc │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .jshintrc │ ├── Gruntfile.js │ ├── TODO.txt │ ├── app │ │ ├── .htaccess │ │ ├── 404.html │ │ ├── app.iml │ │ ├── favicon.ico │ │ ├── images │ │ │ └── goodreads-badge-read-reviews.png │ │ ├── index.html │ │ ├── robots.txt │ │ ├── scripts │ │ │ ├── books.coffee │ │ │ ├── google-api.coffee │ │ │ ├── main.coffee │ │ │ └── views.coffee │ │ └── styles │ │ │ └── main.scss │ ├── component.json │ ├── dist │ │ ├── .htaccess │ │ ├── 404.html │ │ ├── favicon.ico │ │ ├── images │ │ │ └── goodreads-badge-read-reviews.png │ │ ├── index.html │ │ ├── robots.txt │ │ ├── scripts │ │ │ ├── main.js │ │ │ ├── vendor.js │ │ │ └── vendor │ │ │ │ └── modernizr.js │ │ └── styles │ │ │ ├── font │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ │ │ └── main.css │ └── package.json ├── UniversalBibTexKeys │ ├── README.md │ ├── coffee │ │ └── transformer.coffee │ ├── css │ │ ├── bootstrap-responsive.css │ │ ├── bootstrap-responsive.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.min.css │ │ └── custom.css │ ├── img │ │ ├── glyphicons-halflings-white.png │ │ └── glyphicons-halflings.png │ ├── index.html │ ├── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── transformer.js │ └── test-data │ │ ├── Article_str.trans_RTIL_accepted.bib │ │ ├── Article_str.trans_RTIL_accepted.tex │ │ ├── elsarticle-num.bst │ │ └── elsarticle.cls ├── VerticalPlotter │ ├── .gitignore │ ├── app.nw │ ├── bower.json │ ├── components │ │ ├── .DS_Store │ │ └── jquery │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── bower.json │ │ │ ├── component.json │ │ │ ├── composer.json │ │ │ ├── jquery-migrate.js │ │ │ ├── jquery-migrate.min.js │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.min.map │ │ │ └── package.json │ ├── gcode-manipulation │ │ └── gcode_from_xy_to_ab.js │ ├── index.html │ ├── main.coffee │ ├── main.js │ ├── package.json │ ├── plotter-simulator.html │ ├── process.coffee │ ├── process.js │ ├── simulator.coffee │ └── simulator.js ├── animated-number-field │ ├── index.html │ ├── jquery.format-1.2.js │ ├── jquery.format-1.2.min.js │ └── script.js ├── bravais │ ├── index.html │ ├── js │ │ ├── ajax.js │ │ ├── bravais.js │ │ ├── compatibility.js │ │ └── tests.js │ └── tests.html ├── canvas-life-game │ ├── index.html │ └── main.js ├── canvas-pong-client │ ├── canvas-game.js │ ├── index.html │ ├── pong.js │ └── styles.css ├── celullar automaton │ ├── index.html │ └── main.js ├── coffee-script.js ├── common.js ├── drawing-robot-2d-simulation │ ├── .gitignore │ ├── dist │ │ ├── index.html │ │ └── main.js │ ├── package.json │ ├── src │ │ └── main.ts │ ├── tsconfig.json │ └── webpack.config.js ├── drawing-robot-ab-xy-simulator │ ├── .flowconfig │ ├── .jshintrc │ ├── index.html │ ├── main.js │ ├── planner.html │ └── planner.js ├── evolution-strategies │ ├── dat.gui.css │ ├── dat.gui.js │ ├── es-optimization-module.js │ ├── es-optimization.html │ ├── es-optimization.js │ ├── gpu.js │ ├── gpu2.js │ ├── index.html │ ├── math.js │ ├── nes.js │ ├── package-lock.json │ ├── style.css │ ├── webclgl.html │ ├── webclgl.js │ └── ziggurat.js ├── fisheye-lines │ ├── .gitignore │ ├── dist │ │ ├── app.6bf29a0e.css │ │ ├── app.6bf29a0e.css.map │ │ ├── app.8f606666.js │ │ ├── app.8f606666.js.map │ │ └── index.html │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── app.ts │ │ ├── draggable.ts │ │ ├── geometry-utils.ts │ │ ├── segment.ts │ │ ├── styles.scss │ │ └── types.ts │ └── tsconfig.json ├── flow-field │ ├── .gitignore │ ├── dist │ │ ├── app.055ed647.js │ │ ├── app.055ed647.js.map │ │ ├── app.0f8cf105.js │ │ ├── app.0f8cf105.js.map │ │ ├── app.4a69db9f.js │ │ ├── app.4a69db9f.js.map │ │ ├── app.4efef98f.js │ │ ├── app.4efef98f.js.map │ │ ├── app.533c3afa.css │ │ ├── app.533c3afa.css.map │ │ ├── app.5cec07dd.css │ │ ├── app.5cec07dd.css.map │ │ ├── app.5cec07dd.js │ │ ├── app.5cec07dd.js.map │ │ ├── app.b34e5f9e.js │ │ ├── app.b34e5f9e.js.map │ │ ├── app.ca32bc49.js │ │ ├── app.ca32bc49.js.map │ │ └── index.html │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── MyCircle.ts │ │ ├── Particle.ts │ │ ├── PoissonDistribution.ts │ │ ├── app.ts │ │ ├── simplexNoiseFast.js │ │ ├── styles.scss │ │ └── utils.ts │ └── tsconfig.json ├── force-acceleration-drag │ ├── 1d.example.html │ ├── 1d.example.js │ ├── 2d.example.coffee │ ├── 2d.example.html │ ├── 2d.example.js │ ├── 2d.example.orig.js │ ├── arrow_right_32x32.png │ └── requestAnimFrame.js ├── force-gravity-experiment │ ├── index.html │ ├── keys-status-monitor.coffee │ ├── keys-status-monitor.js │ ├── main.coffee │ ├── main.js │ ├── newton.coffee │ ├── newton.js │ └── requestAnimFrame.js ├── gcodes │ ├── gcode_from_xy_to_ab.js │ ├── output_0001.gcode │ ├── output_0001.ngc │ ├── output_0001_ab_system.gcode │ ├── output_0002.gcode │ ├── output_0002_ab_system.gcode │ ├── output_0003.gcode │ ├── output_0003_ab_system.gcode │ ├── output_0004.gcode │ ├── output_0004_ab_system.gcode │ ├── output_0005.gcode │ ├── output_0005_ab_system.gcode │ ├── package-lock.json │ └── package.json ├── hexagonal-rgb-led-matrix-editor │ ├── .gitignore │ ├── README.md │ ├── build │ │ ├── asset-manifest.json │ │ ├── favicon.png │ │ ├── index.html │ │ ├── manifest.json │ │ ├── service-worker.js │ │ └── static │ │ │ ├── css │ │ │ ├── main.03b45d40.css │ │ │ └── main.03b45d40.css.map │ │ │ └── js │ │ │ ├── main.23ac359c.js │ │ │ └── main.23ac359c.js.map │ ├── images.d.ts │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ ├── index.html │ │ └── manifest.json │ ├── src │ │ ├── App.css │ │ ├── App.test.tsx │ │ ├── App.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── logo.svg │ │ └── registerServiceWorker.ts │ ├── tsconfig.json │ ├── tsconfig.prod.json │ ├── tsconfig.test.json │ ├── tslint.json │ └── yarn.lock ├── index.html ├── jquery.1.7.1.min.js ├── orthographic-projection-test │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .nvmrc │ ├── .yarn │ │ └── install-state.gz │ ├── .yarnrc.yml │ ├── dist │ │ ├── index.2a21120e.js │ │ ├── index.2a21120e.js.map │ │ ├── index.acfa0869.css │ │ ├── index.acfa0869.css.map │ │ ├── index.ec62b55e.js │ │ ├── index.ec62b55e.js.map │ │ └── index.html │ ├── index.html │ ├── package.json │ ├── src │ │ ├── app.ts │ │ └── styles.scss │ ├── tsconfig.json │ └── yarn.lock ├── other │ ├── bullseye.coffee │ ├── bullseye.in │ └── num-sorting.coffee ├── pong-training │ ├── index-webgl.html │ ├── index.html │ ├── lib │ │ └── convnetjs │ │ │ ├── convnet-webgl.js │ │ │ ├── convnet.js │ │ │ ├── deepqlearn.js │ │ │ ├── util.js │ │ │ └── vis.js │ ├── main.js │ ├── model.js │ └── style.css ├── pong │ └── MultiPong │ │ ├── index.html │ │ ├── js │ │ ├── main.js │ │ ├── server.js │ │ ├── sockets.js │ │ └── utils.js │ │ ├── libs │ │ ├── jquip.min.js │ │ ├── requestAnimFrame.js │ │ ├── underscore-min.js │ │ └── underscore.js │ │ ├── main.coffee │ │ ├── package.json │ │ ├── server.coffee │ │ ├── sounds │ │ ├── ball1.wav │ │ ├── sound1.wav │ │ ├── sound2.wav │ │ ├── sound3.wav │ │ ├── sound4.wav │ │ ├── sound5.wav │ │ ├── sound6.wav │ │ └── sound7.wav │ │ └── utils.coffee ├── sample.coffee ├── udacity │ └── robotics │ │ ├── arrow_down_32x32.png │ │ ├── arrow_up_32x32.png │ │ ├── final.coffee │ │ ├── final.html │ │ └── final.js └── viz-grid │ ├── simple.gird.world.coffee │ ├── simple.gird.world.html │ └── simple.gird.world.js ├── Processing └── gcode_tier_generator │ └── gcode_tier_generator.pde └── Python ├── Inkscape ├── vertical_plotter_transform.inx └── vertical_plotter_transform.py ├── MovieTweeterRanking ├── .gitignore ├── config.json.sample ├── main.py └── twitter.py ├── Udacity ├── Deep Learning │ ├── .gitignore │ ├── 1_notmnist.ipynb │ ├── 2_fullyconnected.ipynb │ ├── 3_regularization.ipynb │ ├── 4_convolutions.ipynb │ ├── 5_word2vec.ipynb │ ├── 6_lstm.ipynb │ ├── Dockerfile │ └── README.md └── Robotic Car │ ├── hw1.py │ └── unit1.py ├── elec_calc ├── elec_calc.py └── input.txt ├── halite ├── .gitignore ├── MyBot2.py ├── MyBot3.py ├── MyMLBot.py ├── MyMLBotTest.py ├── RandomBot.py ├── convolutional_network.py ├── download_games.py ├── halite-mac ├── halite-ubuntu ├── halite_cnn_bot.ipynb ├── hlt.py ├── hlt_debug.py ├── machine_learning.py ├── pipe_socket_translator.py ├── process_replay.py ├── pull_data_from.js ├── replay.py ├── script │ ├── debugGame.sh │ └── runGame.sh └── ui.py ├── red-button ├── LibusbSheild.kext │ └── Info.plist ├── install_sheild.sh ├── redbutton.py └── redbutton2.py └── special-sorting └── main.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | bower_components 4 | node_modules 5 | Datamining/Google Inc. NASDAQ GOOG quotes & news - Google Finance.html 6 | JS/EUGEN/cg900656z_si_001 (1).pdf 7 | *hlt.json 8 | -------------------------------------------------------------------------------- /Datamining/Books parsing/books.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | def clientGenerator(): 4 | f = open("data.txt") 5 | for line in f: 6 | yield map(int, line.strip().split(",")) 7 | 8 | def clientBookMap(): 9 | m = {} 10 | for client, book in clientGenerator(): 11 | if client not in m: 12 | m[client] = [] 13 | m[client].append(book) 14 | return m 15 | 16 | def bookClientMap(): 17 | m = {} 18 | for client, book in clientGenerator(): 19 | if book not in m: 20 | m[book] = [] 21 | m[book].append(client) 22 | return m 23 | 24 | def crossings(li1, li2): 25 | return sum([1 for el in li1 if el in li2]) 26 | 27 | def countClientWithBooks(books, bcMap): 28 | clients = [bcMap[book] for book in books] 29 | return crossings(*clients) 30 | 31 | def allPairsCounts(): 32 | bcMap = bookClientMap() 33 | l = len(bcMap) 34 | books = bcMap.keys() 35 | result = {} 36 | f = open("stats.csv",'w') 37 | print "book1,book2count,seconds,left" 38 | f.write("book1,book2count,seconds,left\n") 39 | for i, book1 in enumerate(books): 40 | cc = 0 41 | t1 = datetime.now() 42 | for j in range(i+1, l): 43 | if j in books: 44 | book2 = books[j] 45 | pair = (book1, book2) 46 | res = countClientWithBooks(pair, bcMap) 47 | if res: 48 | result[pair] = res 49 | cc += 1 50 | yield book1, book2, res 51 | t2 = datetime.now() 52 | dt = t2 - t1 53 | stat = "%d,%d,%d.%06d,%d" % (book1, cc, dt.seconds, dt.microseconds, (l-i+1)) 54 | f.write(stat + "\n") 55 | f.flush() 56 | print stat 57 | f.close() 58 | 59 | 60 | def main(): 61 | #f = open('pairsres.txt', 'w') 62 | #for b1, b2, res in allPairsCounts(): 63 | # f.write("%d, %d, %d\n" % (b1, b2, res)) 64 | #f.close() 65 | print "Reading original list and making Book/Client map" 66 | bcMap = bookClientMap() 67 | print "Done." 68 | 69 | f = open('revData2.csv', 'w') 70 | f.write("raamatX,raamatY,mitu_inimest_ostis_molemit\n") 71 | [f.write("%d,%d,%d\n" % bookPairAndRes) for bookPairAndRes in allPairsCounts()] 72 | f.close() 73 | print "Done" 74 | 75 | if __name__ == '__main__': 76 | main() 77 | 78 | -------------------------------------------------------------------------------- /Datamining/Books parsing/draw.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.cm as cm 3 | import matplotlib.pyplot as plt 4 | from datetime import datetime 5 | 6 | start = datetime.now() 7 | print "Reading big file ... " 8 | #fileSource = "/Users/soswow/Dropbox/TTU - Magister/IDN0100 - Datamining/Link Test/part.txt" 9 | fileSource = "/Users/soswow/Dropbox/TTU - Magister/IDN0100 - Datamining/Link Test/revData3.csv" 10 | x,y,c = np.loadtxt(fileSource,dtype=int,delimiter=',',skiprows=1,unpack=True) 11 | 12 | xmin = x.min() 13 | xmax = x.max() 14 | ymin = y.min() 15 | ymax = y.max() 16 | 17 | end = datetime.now() 18 | delta = end - start 19 | print "Done in %d.%06d. Drawing ..." % (delta.seconds, delta.microseconds) 20 | 21 | plt.scatter(x,y,s=c,alpha=0.005,cmap=cm.jet) 22 | #plt.hexbin(x,y,c,cmap=cm.jet,bins='log') 23 | #plt.axis([xmin, xmax, ymin, ymax]) 24 | #plt.title("Hexagon binning") 25 | #cb = plt.colorbar() 26 | #cb.set_label('counts') 27 | end2 = datetime.now() 28 | delta = end2 - end 29 | print "Done in %d.%06d. Saving ... " % (delta.seconds, delta.microseconds) 30 | #plt.show() 31 | end3 = datetime.now() 32 | delta = end3 - end2 33 | plt.savefig("test.png") 34 | 35 | print "Done in %d.%06d" % (delta.seconds, delta.microseconds) 36 | -------------------------------------------------------------------------------- /Datamining/Books parsing/test copy 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/Datamining/Books parsing/test copy 2.png -------------------------------------------------------------------------------- /Datamining/Books parsing/test copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/Datamining/Books parsing/test copy.png -------------------------------------------------------------------------------- /Datamining/Books parsing/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/Datamining/Books parsing/test.png -------------------------------------------------------------------------------- /Datamining/apriori/parse.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | dir = '/Volumes/New Mac HD/Users/soswow/Dropbox/TTU - Magister/IDN0100 - Datamining/apriori' 4 | fi = open('%s/%s' % (dir, 'tshekid3.csv')) 5 | fo = open('%s/%s' % (dir, 'input4.txt'), 'w') 6 | fi.readline() 7 | old_id = None 8 | goods = [] 9 | for line in fi: 10 | _, good, id, _ = line.replace('\n','').split(';') 11 | if old_id and old_id != id: 12 | fo.write("%s\n" % " ".join(goods)) 13 | goods = [] 14 | old_id = id 15 | goods.append(good.replace(' ', '_').lower()) 16 | fo.close() 17 | fi.close() 18 | 19 | if __name__ == "__main__": 20 | main() -------------------------------------------------------------------------------- /Datamining/datamining.js: -------------------------------------------------------------------------------- 1 | function doit(){ 2 | var inputObj = document.getElementById('input'); 3 | var input = inputObj.value; 4 | var outputObj = document.getElementById('output'); 5 | 6 | function parseData(input) { 7 | return input.trim().split("\n").map(function(line){ 8 | return line.replace(/"|-ga/g,"").trim().split("rääkis").map(function(item){ 9 | return item.trim(); 10 | }); 11 | }); 12 | } 13 | 14 | function getPeople(data){ 15 | var people = []; 16 | data.forEach(function(pair){ 17 | pair.forEach(function(man){ 18 | if(people.indexOf(man) == -1){ 19 | people.push(man); 20 | } 21 | }); 22 | }); 23 | return people; 24 | } 25 | 26 | function getData(input) { 27 | var pairs = parseData(input); 28 | var people = getPeople(pairs); 29 | var str = "*Vertices "+people.length; 30 | 31 | people.forEach(function(man, i){ 32 | str += "
" + (i+1) +" " + man; 33 | }); 34 | str += "
*Edges " + people.length; 35 | pairs.forEach(function(pair){ 36 | str += "
" + (people.indexOf(pair[0])+1) +" " + (people.indexOf(pair[1])+1); 37 | }); 38 | return str; 39 | } 40 | 41 | outputObj.innerHTML = getData(input); 42 | } -------------------------------------------------------------------------------- /Datamining/test.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 42 | 43 |
44 | 45 | -------------------------------------------------------------------------------- /Datamining/ttu-user-account-parser/main.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | def find_word(from_id, to_id, words): 4 | valid = 0 5 | for student_id in range(from_id, to_id): 6 | if student_id % 100 == 0: 7 | print "%06d is going ... (%d found accounts)" % (student_id, valid) 8 | try: 9 | d = requests.get(url='http://www.tud.ttu.ee/~t%06d/' % student_id) 10 | except: 11 | print "Exception for (%d) ... " % student_id 12 | for line in d.content.split("\n"): 13 | if 'Index of' in line: 14 | valid += 1 15 | if any([word in line for word in words]): 16 | print "Ho-ho! - %d" % student_id 17 | 18 | return valid 19 | 20 | 21 | def main(): 22 | valid = find_word(000000,109999,['itv0090','.svg']) 23 | print "There is %d accounts open" % valid 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /Dynamic Programming/zero-one-matrix.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | pass 4 | 5 | if __name__ == "__main__": 6 | main() -------------------------------------------------------------------------------- /JS/AddressBook/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "app/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /JS/AddressBook/.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 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 2 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /JS/AddressBook/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /JS/AddressBook/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .tmp 3 | .sass-cache 4 | app/bower_components 5 | app/styles/font -------------------------------------------------------------------------------- /JS/AddressBook/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "jquery": true 22 | } 23 | -------------------------------------------------------------------------------- /JS/AddressBook/README.md: -------------------------------------------------------------------------------- 1 | Prerequisites 2 | ------------- 3 | * casperjs (```brew install casperjs --devel```) -------------------------------------------------------------------------------- /JS/AddressBook/TestResult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/TestResult.png -------------------------------------------------------------------------------- /JS/AddressBook/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/AddressBook/app/favicon.ico -------------------------------------------------------------------------------- /JS/AddressBook/app/robots.txt: -------------------------------------------------------------------------------- 1 | # robotstxt.org/ 2 | 3 | User-agent: * 4 | -------------------------------------------------------------------------------- /JS/AddressBook/app/scripts/boot.coffee: -------------------------------------------------------------------------------- 1 | window.app = {} 2 | app.models = {} 3 | app.views = {} 4 | _.mixin _.str.exports() -------------------------------------------------------------------------------- /JS/AddressBook/app/scripts/main.coffee: -------------------------------------------------------------------------------- 1 | app.mainPage = new app.views.MainPage() 2 | app.mainPage.render() -------------------------------------------------------------------------------- /JS/AddressBook/app/scripts/memory-storage.coffee: -------------------------------------------------------------------------------- 1 | data = null 2 | class MemoryStorage 3 | constructor: -> data = {} 4 | setItem: (key, value) -> data[key] = value 5 | getItem: (key) -> data[key] 6 | removeItem: (key) -> delete data[key] 7 | length: -> data.length 8 | 9 | Backbone.LocalStorage::localStorage = -> 10 | try 11 | window.localStorage.setItem 'safari private mode test', true 12 | window.localStorage.removeItem 'safari private mode test' 13 | localStorage 14 | catch e 15 | new MemoryStorage() -------------------------------------------------------------------------------- /JS/AddressBook/app/scripts/models.coffee: -------------------------------------------------------------------------------- 1 | class BaseModel extends Backbone.Model 2 | mandatory: [] 3 | 4 | validate: (attrs) -> 5 | errorFields = 6 | for field in @mandatory when not attrs[field] 7 | field 8 | 9 | if errorFields.length 10 | failedFieldsStr = _.map(errorFields, _.capitalize).join(', ') 11 | isAre = if errorFields.length > 1 then 'are' else 'is' 12 | [errorFields, "#{failedFieldsStr} #{isAre} mandatory"] 13 | 14 | 15 | class app.models.Group extends BaseModel 16 | defaults: 17 | name: '' 18 | mandatory: ['name'] 19 | 20 | 21 | class app.models.Contact extends BaseModel 22 | defaults: 23 | name: '' 24 | phone: '' 25 | groupId: null 26 | 27 | mandatory: ['name', 'phone'] 28 | 29 | 30 | class ContactsCollection extends Backbone.Collection 31 | model: app.models.Contact 32 | localStorage: new Backbone.LocalStorage("ContactsCollection") 33 | comparator: (contact) -> contact.get("name") 34 | notNew: -> @filter (contact) -> not contact.isNew() 35 | 36 | class GroupsCollection extends Backbone.Collection 37 | 38 | model: app.models.Group 39 | 40 | localStorage: new Backbone.LocalStorage("GroupCollection") 41 | 42 | makeOptions: (selectedId) -> 43 | @map((group) -> 44 | id = group.id or group.cid 45 | selected = if id is selectedId then "selected" else "" 46 | "<option value='#{id}' #{selected}>#{group.escape('name')}</option>" 47 | ).join("") 48 | 49 | app.models.contacts = new ContactsCollection() 50 | 51 | app.models.groups = new GroupsCollection() 52 | app.models.groups.fetch() 53 | if app.models.groups.length is 0 54 | for name in ['Work', 'Family', 'Other'] 55 | app.models.groups.create name: name -------------------------------------------------------------------------------- /JS/AddressBook/app/scripts/vendor/bootstrap/transition.js: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Bootstrap: transition.js v3.0.0 3 | * http://twbs.github.com/bootstrap/javascript.html#transitions 4 | * ======================================================================== 5 | * Copyright 2013 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ======================================================================== */ 19 | 20 | 21 | +function ($) { "use strict"; 22 | 23 | // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 24 | // ============================================================ 25 | 26 | function transitionEnd() { 27 | var el = document.createElement('bootstrap') 28 | 29 | var transEndEventNames = { 30 | 'WebkitTransition' : 'webkitTransitionEnd' 31 | , 'MozTransition' : 'transitionend' 32 | , 'OTransition' : 'oTransitionEnd otransitionend' 33 | , 'transition' : 'transitionend' 34 | } 35 | 36 | for (var name in transEndEventNames) { 37 | if (el.style[name] !== undefined) { 38 | return { end: transEndEventNames[name] } 39 | } 40 | } 41 | } 42 | 43 | // http://blog.alexmaccaw.com/css-transitions 44 | $.fn.emulateTransitionEnd = function (duration) { 45 | var called = false, $el = this 46 | $(this).one($.support.transition.end, function () { called = true }) 47 | var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 48 | setTimeout(callback, duration) 49 | return this 50 | } 51 | 52 | $(function () { 53 | $.support.transition = transitionEnd() 54 | }) 55 | 56 | }(window.jQuery); 57 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_alerts.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: $alert-padding; 11 | margin-bottom: $line-height-computed; 12 | color: $alert-text; 13 | background-color: $alert-bg; 14 | border: 1px solid $alert-border; 15 | border-radius: $alert-border-radius; 16 | 17 | // Headings for larger alerts 18 | h4 { 19 | margin-top: 0; 20 | // Specified for the h4 to prevent conflicts of changing $headingsColor 21 | color: inherit; 22 | } 23 | // Match the hr to the border of the alert 24 | hr { 25 | border-top-color: darken($alert-border, 5%); 26 | } 27 | // Provide class for links that match alerts 28 | .alert-link { 29 | font-weight: $alert-link-font-weight; 30 | color: darken($alert-text, 10%); 31 | } 32 | 33 | // Improve alignment and spacing of inner content 34 | > p, 35 | > ul { 36 | margin-bottom: 0; 37 | } 38 | > p + p { 39 | margin-top: 5px; 40 | } 41 | } 42 | 43 | // Dismissable alerts 44 | // 45 | // Expand the right padding and account for the close button's positioning. 46 | 47 | .alert-dismissable { 48 | padding-right: ($alert-padding + 20); 49 | 50 | // Adjust close link position 51 | .close { 52 | position: relative; 53 | top: -2px; 54 | right: -21px; 55 | color: inherit; 56 | } 57 | } 58 | 59 | // Alternate styles 60 | // 61 | // Generate contextual modifier classes for colorizing the alert. 62 | 63 | .alert-success { 64 | @include alert-variant($alert-success-bg, $alert-success-border, $alert-success-text); 65 | } 66 | .alert-danger { 67 | @include alert-variant($alert-danger-bg, $alert-danger-border, $alert-danger-text); 68 | } 69 | .alert-info { 70 | @include alert-variant($alert-info-bg, $alert-info-border, $alert-info-text); 71 | } 72 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_badges.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base classes 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: $font-size-small; 12 | font-weight: $badge-font-weight; 13 | color: $badge-color; 14 | line-height: $badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: $badge-bg; 19 | border-radius: $badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | } 26 | 27 | // Hover state, but only for links 28 | a.badge { 29 | &:hover, 30 | &:focus { 31 | color: $badge-link-hover-color; 32 | text-decoration: none; 33 | cursor: pointer; 34 | } 35 | } 36 | 37 | // Quick fix for labels/badges in buttons 38 | .btn .badge { 39 | position: relative; 40 | top: -1px; 41 | } 42 | 43 | // Account for counters in navs 44 | a.list-group-item.active > .badge, 45 | .nav-pills > .active > a > .badge { 46 | color: $badge-active-color; 47 | background-color: $badge-active-bg; 48 | } 49 | .nav-pills > li > a > .badge { 50 | margin-left: 3px; 51 | } 52 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_breadcrumbs.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: 8px 15px; 8 | margin-bottom: $line-height-computed; 9 | list-style: none; 10 | background-color: $breadcrumb-bg; 11 | border-radius: $border-radius-base; 12 | > li { 13 | display: inline-block; 14 | &+li:before { 15 | content: "/\00a0"; // Unicode space added since inline-block means non-collapsing white-space 16 | padding: 0 5px; 17 | color: $breadcrumb-color; 18 | } 19 | } 20 | > .active { 21 | color: $breadcrumb-active-color; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_close.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: ($font-size-base * 1.5); 9 | font-weight: $close-font-weight; 10 | line-height: 1; 11 | color: $close-color; 12 | text-shadow: $close-text-shadow; 13 | @include opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: $close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | @include opacity(.5); 21 | } 22 | } 23 | 24 | // Additional properties for button version 25 | // iOS requires the button element instead of an anchor tag. 26 | // If you want the anchor version, it requires `href="#"`. 27 | button.close { 28 | padding: 0; 29 | cursor: pointer; 30 | background: transparent; 31 | border: 0; 32 | -webkit-appearance: none; 33 | } 34 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_code.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and blocK) 3 | // -------------------------------------------------- 4 | 5 | 6 | // Inline and block code styles 7 | code, 8 | pre { 9 | font-family: $font-family-monospace; 10 | } 11 | 12 | // Inline code 13 | code { 14 | padding: 2px 4px; 15 | font-size: 90%; 16 | color: $code-color; 17 | background-color: $code-bg; 18 | white-space: nowrap; 19 | border-radius: $border-radius-base; 20 | } 21 | 22 | // Blocks of code 23 | pre { 24 | display: block; 25 | padding: (($line-height-computed - 1) / 2); 26 | margin: 0 0 ($line-height-computed / 2); 27 | font-size: ($font-size-base - 1); // 14px to 13px 28 | line-height: $line-height-base; 29 | word-break: break-all; 30 | word-wrap: break-word; 31 | color: $pre-color; 32 | background-color: $pre-bg; 33 | border: 1px solid $pre-border-color; 34 | border-radius: $border-radius-base; 35 | 36 | // Make prettyprint styles more spaced out for readability 37 | &.prettyprint { 38 | margin-bottom: $line-height-computed; 39 | } 40 | 41 | // Account for some code outputs that place code tags in pre tags 42 | code { 43 | padding: 0; 44 | font-size: inherit; 45 | color: inherit; 46 | white-space: pre-wrap; 47 | background-color: transparent; 48 | border: 0; 49 | } 50 | } 51 | 52 | // Enable scrollable blocks of code 53 | .pre-scrollable { 54 | max-height: $pre-scrollable-max-height; 55 | overflow-y: scroll; 56 | } 57 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_component-animations.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | @include transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | &.in { 21 | display: block; 22 | } 23 | } 24 | .collapsing { 25 | position: relative; 26 | height: 0; 27 | overflow: hidden; 28 | @include transition(height .35s ease); 29 | } 30 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_jumbotron.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: 30px; 8 | margin-bottom: 30px; 9 | font-size: ($font-size-base * 1.5); 10 | font-weight: 200; 11 | line-height: ($line-height-base * 1.5); 12 | color: $jumbotron-lead-color; 13 | background-color: $jumbotron-bg; 14 | h1 { 15 | line-height: 1; 16 | color: $jumbotron-heading-color; 17 | } 18 | p { 19 | line-height: 1.4; 20 | } 21 | 22 | @media screen and (min-width: $screen-tablet) { 23 | padding: 50px 60px; 24 | border-radius: $border-radius-large; // Only round corners at higher resolutions 25 | h1 { 26 | font-size: ($font-size-base * 4.5); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_labels.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .25em .6em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: $label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // Add hover effects, but only for links 18 | &[href] { 19 | &:hover, 20 | &:focus { 21 | color: $label-link-hover-color; 22 | text-decoration: none; 23 | cursor: pointer; 24 | } 25 | } 26 | 27 | // Empty labels collapse automatically (not available in IE8) 28 | &:empty { 29 | display: none; 30 | } 31 | } 32 | 33 | // Colors 34 | // Contextual variations (linked labels get darker on :hover) 35 | 36 | .label-default { 37 | @include label-variant($label-default-bg); 38 | } 39 | 40 | .label-danger { 41 | @include label-variant($label-danger-bg); 42 | } 43 | 44 | .label-success { 45 | @include label-variant($label-success-bg); 46 | } 47 | 48 | .label-warning { 49 | @include label-variant($label-warning-bg); 50 | } 51 | 52 | .label-info { 53 | @include label-variant($label-info-bg); 54 | } 55 | -------------------------------------------------------------------------------- /JS/AddressBook/app/styles/bootstrap/_list-group.scss: -------------------------------------------------------------------------------- 1 | // 2 | // List groups 3 | // -------------------------------------------------- 4 | 5 | // Base class 6 | // 7 | // Easily usable on <ul>, <ol>, or <div>. 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 /<option.*<\/option>/ -------------------------------------------------------------------------------- /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<T/dt; i++){ 11 | x = x + v * dt * Math.cos(tetha); 12 | y = y + v * dt * Math.sin(tetha); 13 | tetha = tetha + omega * dt; 14 | console.log(x, y, tetha*180/Math.PI); 15 | } 16 | 17 | return {x:x, y:y, tetha:tetha, tetha_degr:tetha*180/Math.PI}; 18 | } -------------------------------------------------------------------------------- /JS/BlueToggl/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/BlueToggl/favicon.ico -------------------------------------------------------------------------------- /JS/BlueToggl/images/24a891da.outer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/BlueToggl/images/24a891da.outer.png -------------------------------------------------------------------------------- /JS/BlueToggl/images/37637e2d.center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/BlueToggl/images/37637e2d.center.png -------------------------------------------------------------------------------- /JS/BlueToggl/images/5d462625.glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/BlueToggl/images/5d462625.glyphicons-halflings-white.png -------------------------------------------------------------------------------- /JS/BlueToggl/images/9cc6609b.glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/BlueToggl/images/9cc6609b.glyphicons-halflings.png -------------------------------------------------------------------------------- /JS/BlueToggl/index.html: -------------------------------------------------------------------------------- 1 | <!doctype html> 2 | <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 3 | <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> 4 | <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> 5 | <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> 6 | <head> 7 | <meta charset="utf-8"> 8 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 9 | <title> 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 | 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 | 53 | 54 | 56 | 57 |
49 |
50 | 52 |

55 |
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 |

Bravais Unit tests

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 | 23 | 24 | 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 |
    12 |
    13 |
    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 |
    13 |
    14 |
    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 |
    32 |
    33 |
    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 |
    40 |
    41 |
    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 | -------------------------------------------------------------------------------- /JS/force-gravity-experiment/keys-status-monitor.coffee: -------------------------------------------------------------------------------- 1 | keysStatusMonitor = (keysMap) -> 2 | keysState = {} 3 | keysState[v] = false for k, v of keysMap 4 | 5 | window.addEventListener 'keydown', (event) -> 6 | key = keysMap[event.keyCode] 7 | if key and not keysState[key] 8 | console.log('press down ->', key) 9 | keysState[key] = true 10 | 11 | window.addEventListener 'keyup', (event) -> 12 | key = keysMap[event.keyCode] 13 | if key and keysState[key] 14 | console.log('press up ->', key) 15 | keysState[key] = false 16 | 17 | return keysState 18 | 19 | exports = window unless exports 20 | exports.keysStatusMonitor = keysStatusMonitor -------------------------------------------------------------------------------- /JS/force-gravity-experiment/keys-status-monitor.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.12.5 2 | (function() { 3 | var exports, keysStatusMonitor; 4 | 5 | keysStatusMonitor = function(keysMap) { 6 | var k, keysState, v; 7 | keysState = {}; 8 | for (k in keysMap) { 9 | v = keysMap[k]; 10 | keysState[v] = false; 11 | } 12 | window.addEventListener('keydown', function(event) { 13 | var key; 14 | key = keysMap[event.keyCode]; 15 | if (key && !keysState[key]) { 16 | console.log('press down ->', key); 17 | return keysState[key] = true; 18 | } 19 | }); 20 | window.addEventListener('keyup', function(event) { 21 | var key; 22 | key = keysMap[event.keyCode]; 23 | if (key && keysState[key]) { 24 | console.log('press up ->', key); 25 | return keysState[key] = false; 26 | } 27 | }); 28 | return keysState; 29 | }; 30 | 31 | if (!exports) { 32 | exports = window; 33 | } 34 | 35 | exports.keysStatusMonitor = keysStatusMonitor; 36 | 37 | }).call(this); 38 | -------------------------------------------------------------------------------- /JS/force-gravity-experiment/main.coffee: -------------------------------------------------------------------------------- 1 | W = 900 2 | H = 400 3 | 4 | now = Date.now 5 | mainLoop = -> 6 | env = new Environment() 7 | center = new P(W/2,H/2) 8 | obj = new RigObject(center, 10) 9 | env.friction = 0.00005 10 | env.gravity = new Force(0, 0.0005) 11 | env.addObject obj, true 12 | 13 | keysMap = 14 | 37: 'left' 15 | 39: 'right' 16 | 38: 'up' 17 | 40: 'down' 18 | keysState = keysStatusMonitor keysMap 19 | 20 | canvas = $('#canvas') 21 | canvas.attr width:W, height:H 22 | ctx = canvas.get(0).getContext '2d' 23 | 24 | prevT = now() 25 | runOnce = (frameTime) -> 26 | t = frameTime - prevT 27 | prevT = frameTime 28 | forceAmount = 0.0008 29 | 30 | env.controllable.kick keysState.up*forceAmount, keysState.down*forceAmount, 31 | keysState.left*forceAmount, keysState.right*forceAmount 32 | env.nextTick t 33 | 34 | if obj.pos.y > H 35 | obj.pos.y = H 36 | 37 | canvas.attr width:W, height:H 38 | draw ctx, env 39 | requestAnimFrame -> runOnce(now()) 40 | 41 | runOnce prevT 42 | 43 | draw = (ctx, env) -> 44 | for obj in env.objects 45 | # Draw velocity 46 | ctx.beginPath() 47 | ctx.moveTo(obj.pos.x, obj.pos.y) 48 | velocity = obj.velocity.clone() 49 | velocity.setAmount(velocity.getAmount() * 2000) 50 | ctx.lineTo(obj.pos.x + velocity.x, obj.pos.y + velocity.y) 51 | ctx.strokeStyle = 'red'; 52 | ctx.stroke() 53 | # Draw Ball 54 | ctx.beginPath() 55 | ctx.arc obj.pos.x, obj.pos.y, obj.mass, 0, 2 * Math.PI, true 56 | ctx.closePath() 57 | ctx.fill() 58 | 59 | 60 | mainLoop() 61 | 62 | 63 | -------------------------------------------------------------------------------- /JS/force-gravity-experiment/main.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.12.5 2 | (function() { 3 | var H, W, draw, mainLoop, now; 4 | 5 | W = 900; 6 | 7 | H = 400; 8 | 9 | now = Date.now; 10 | 11 | mainLoop = function() { 12 | var canvas, center, ctx, env, keysMap, keysState, obj, prevT, runOnce; 13 | env = new Environment(); 14 | center = new P(W / 2, H / 2); 15 | obj = new RigObject(center, 10); 16 | env.friction = 0.00005; 17 | env.gravity = new Force(0, 0.0005); 18 | env.addObject(obj, true); 19 | keysMap = { 20 | 37: 'left', 21 | 39: 'right', 22 | 38: 'up', 23 | 40: 'down' 24 | }; 25 | keysState = keysStatusMonitor(keysMap); 26 | canvas = $('#canvas'); 27 | canvas.attr({ 28 | width: W, 29 | height: H 30 | }); 31 | ctx = canvas.get(0).getContext('2d'); 32 | prevT = now(); 33 | runOnce = function(frameTime) { 34 | var forceAmount, t; 35 | t = frameTime - prevT; 36 | prevT = frameTime; 37 | forceAmount = 0.0008; 38 | env.controllable.kick(keysState.up * forceAmount, keysState.down * forceAmount, keysState.left * forceAmount, keysState.right * forceAmount); 39 | env.nextTick(t); 40 | if (obj.pos.y > H) { 41 | obj.pos.y = H; 42 | } 43 | canvas.attr({ 44 | width: W, 45 | height: H 46 | }); 47 | draw(ctx, env); 48 | return requestAnimFrame(function() { 49 | return runOnce(now()); 50 | }); 51 | }; 52 | return runOnce(prevT); 53 | }; 54 | 55 | draw = function(ctx, env) { 56 | var i, len, obj, ref, results, velocity; 57 | ref = env.objects; 58 | results = []; 59 | for (i = 0, len = ref.length; i < len; i++) { 60 | obj = ref[i]; 61 | ctx.beginPath(); 62 | ctx.moveTo(obj.pos.x, obj.pos.y); 63 | velocity = obj.velocity.clone(); 64 | velocity.setAmount(velocity.getAmount() * 2000); 65 | ctx.lineTo(obj.pos.x + velocity.x, obj.pos.y + velocity.y); 66 | ctx.strokeStyle = 'red'; 67 | ctx.stroke(); 68 | ctx.beginPath(); 69 | ctx.arc(obj.pos.x, obj.pos.y, obj.mass, 0, 2 * Math.PI, true); 70 | ctx.closePath(); 71 | results.push(ctx.fill()); 72 | } 73 | return results; 74 | }; 75 | 76 | mainLoop(); 77 | 78 | }).call(this); 79 | -------------------------------------------------------------------------------- /JS/gcodes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gcodes", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "gcode_from_xy_to_ab.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "left-pad": "^1.3.0", 13 | "yargs": "^11.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | # /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/README.md: -------------------------------------------------------------------------------- 1 | ## Hexagonal LEDs matrix playground 2 | 3 | `yarn start` to start. 4 | 5 | ## Working Demo page 6 | 7 | Demo page is [over here](http://soswow.github.io/Various-JS-and-Python/JS/hexagonal-rgb-led-matrix-editor/build/). 8 | The workflow is the following: 9 | 1. Specify overall size of you grid (one that would fit all the pixels) 10 | 2. Switch to "Strip enum mode" 11 | 3. Start selecting pixels in the order of your strip. From first to last. 12 | 4. Press "Leave only selected as active" 13 | 5. Press "Stringify state" 14 | 6. Copy the text somewhere. Next time you can paste it in and press "Parse state" 15 | 7. Choose your animation. Like "Matrix rain Mode" 16 | 17 | Try this state: 18 | ```json 19 | { 20 | "rows":4, 21 | "columns":9, 22 | "isVerticalPattern":true, 23 | "activeKeys":[null,true,null,null,null,null,null,true,null,true,true,true,true,null,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,null,null,null,true,true,true], 24 | "stipIndexToGrid":[14,15,7,17,26,35,34,25,16,24,33,23,22,12,11,1,9,18,27,28,19,10,20,29,21] 25 | } 26 | ``` 27 | 28 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 29 | 30 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "main.css": "static/css/main.03b45d40.css", 3 | "main.css.map": "static/css/main.03b45d40.css.map", 4 | "main.js": "static/js/main.23ac359c.js", 5 | "main.js.map": "static/js/main.23ac359c.js.map" 6 | } -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/hexagonal-rgb-led-matrix-editor/build/favicon.png -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | React App 10 | 11 | 12 | 13 | 14 |
    15 | 16 | 17 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "LED matrix editor", 3 | "name": "LED matrix editor", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/static/css/main.03b45d40.css: -------------------------------------------------------------------------------- 1 | #root,body,html{height:100%;background-color:#d3d3d3}.App{display:grid;height:100%;grid-template-columns:1fr 600px 1fr;grid-gap:15px}.side-panel{padding:10px}textarea{font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace}path{pointer-events:all;cursor:pointer}path:hover{stroke:red}@-webkit-keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}body{margin:0;padding:0;font-family:sans-serif} 2 | /*# sourceMappingURL=main.03b45d40.css.map*/ -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/build/static/css/main.03b45d40.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["App.css","index.css"],"names":[],"mappings":"AAAA,gBACE,YACA,wBAA4B,CAG9B,KACE,aACA,YACA,oCACA,aAAe,CAGjB,YACE,YAAc,CAEhB,SACE,0HAA4H,CAG9H,KACE,mBACA,cAAgB,CAElB,WACE,UAAuB,CAGzB,iCACE,GAAO,+BAAiC,sBAAwB,CAChE,GAAK,gCAAmC,uBAA0B,CAAE,CAGtE,yBACE,GAAO,+BAAiC,sBAAwB,CAChE,GAAK,gCAAmC,uBAA0B,CAAE,CClCtE,KACE,SACA,UACA,sBAAwB","file":"static/css/main.03b45d40.css","sourcesContent":["body, html, #root{\n height: 100%;\n background-color: lightgrey;\n}\n\n.App {\n display: grid;\n height: 100%;\n grid-template-columns: 1fr 600px 1fr;\n grid-gap: 15px;\n}\n\n.side-panel{\n padding: 10px;\n}\ntextarea{\n font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;\n}\n\npath {\n pointer-events: all;\n cursor: pointer;\n}\npath:hover{\n stroke: rgb(255, 0, 0);\n}\n\n@-webkit-keyframes App-logo-spin {\n from { -webkit-transform: rotate(0deg); transform: rotate(0deg); }\n to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }\n}\n\n@keyframes App-logo-spin {\n from { -webkit-transform: rotate(0deg); transform: rotate(0deg); }\n to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/App.css","body {\n margin: 0;\n padding: 0;\n font-family: sans-serif;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.css"],"sourceRoot":""} -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/images.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' 2 | declare module '*.png' 3 | declare module '*.jpg' 4 | declare module '*.jpeg' 5 | declare module '*.gif' 6 | declare module '*.bmp' 7 | declare module '*.tiff' 8 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hexagonal-rgb-led-matrix-editor", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@types/raphael": "^2.1.30", 7 | "raphael": "^2.2.7", 8 | "react": "^16.6.0", 9 | "react-dom": "^16.6.0", 10 | "react-raphael": "^0.9.0", 11 | "react-scripts-ts": "3.1.0" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts-ts start", 15 | "build": "react-scripts-ts build", 16 | "test": "react-scripts-ts test --env=jsdom", 17 | "eject": "react-scripts-ts eject" 18 | }, 19 | "devDependencies": { 20 | "@types/jest": "^23.3.8", 21 | "@types/node": "^10.12.1", 22 | "@types/react": "^16.4.18", 23 | "@types/react-dom": "^16.0.9", 24 | "typescript": "^3.1.4" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/hexagonal-rgb-led-matrix-editor/public/favicon.png -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | React App 14 | 15 | 16 | 19 |
    20 | 21 | 22 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "LED matrix editor", 3 | "name": "LED matrix editor", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/src/App.css: -------------------------------------------------------------------------------- 1 | body, html, #root{ 2 | height: 100%; 3 | background-color: lightgrey; 4 | } 5 | 6 | .App { 7 | display: grid; 8 | height: 100%; 9 | grid-template-columns: 1fr 600px 1fr; 10 | grid-gap: 15px; 11 | } 12 | 13 | .side-panel{ 14 | padding: 10px; 15 | } 16 | textarea{ 17 | font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; 18 | } 19 | 20 | path { 21 | pointer-events: all; 22 | cursor: pointer; 23 | } 24 | path:hover{ 25 | stroke: rgb(255, 0, 0); 26 | } 27 | 28 | @keyframes App-logo-spin { 29 | from { transform: rotate(0deg); } 30 | to { transform: rotate(360deg); } 31 | } 32 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import './index.css'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render( 8 | , 9 | document.getElementById('root') as HTMLElement 10 | ); 11 | registerServiceWorker(); 12 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "outDir": "build/dist", 5 | "module": "esnext", 6 | "target": "es5", 7 | "lib": ["es6", "dom"], 8 | "sourceMap": true, 9 | "allowJs": true, 10 | "jsx": "react", 11 | "moduleResolution": "node", 12 | "rootDir": "src", 13 | "forceConsistentCasingInFileNames": true, 14 | "noImplicitReturns": true, 15 | "noImplicitThis": true, 16 | "noImplicitAny": true, 17 | "importHelpers": true, 18 | "strictNullChecks": true, 19 | "suppressImplicitAnyIndexErrors": true, 20 | "noUnusedLocals": false 21 | }, 22 | "exclude": [ 23 | "node_modules", 24 | "build", 25 | "scripts", 26 | "acceptance-tests", 27 | "webpack", 28 | "jest", 29 | "src/setupTests.ts" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/tsconfig.prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "commonjs" 5 | } 6 | } -------------------------------------------------------------------------------- /JS/hexagonal-rgb-led-matrix-editor/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], 3 | "rules": { 4 | "no-var-requires": false, 5 | "no-unused-variable": false, 6 | "no-console": false, 7 | "interface-name": [true, "never-prefix"], 8 | "object-literal-sort-keys": false 9 | }, 10 | "linterOptions": { 11 | "exclude": [ 12 | "config/**/*.js", 13 | "node_modules/**/*.ts", 14 | "coverage/lcov-report/*.js" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{js,json,yml}] 8 | charset = utf-8 9 | indent_style = space 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.gitattributes: -------------------------------------------------------------------------------- 1 | /.yarn/** linguist-vendored 2 | /.yarn/releases/* binary 3 | /.yarn/plugins/**/* binary 4 | /.pnp.* binary linguist-generated 5 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .parcel-cache -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.nvmrc: -------------------------------------------------------------------------------- 1 | v20 -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.yarn/install-state.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/orthographic-projection-test/.yarn/install-state.gz -------------------------------------------------------------------------------- /JS/orthographic-projection-test/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: "node-modules" -------------------------------------------------------------------------------- /JS/orthographic-projection-test/dist/index.acfa0869.css: -------------------------------------------------------------------------------- 1 | body{box-sizing:border-box;color:#fff;background-color:#283747;margin:0;padding:0;font-family:Montserrat,sans-serif}.container{flex-direction:column;justify-content:center;align-items:center;display:flex} 2 | /*# sourceMappingURL=index.acfa0869.css.map */ 3 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/dist/index.acfa0869.css.map: -------------------------------------------------------------------------------- 1 | {"mappings":"ACGA,oHASA","sources":["index.acfa0869.css","src/styles.scss"],"sourcesContent":["body {\n box-sizing: border-box;\n color: #fff;\n background-color: #283747;\n margin: 0;\n padding: 0;\n font-family: Montserrat, sans-serif;\n}\n\n.container {\n flex-direction: column;\n justify-content: center;\n align-items: center;\n display: flex;\n}\n/*# sourceMappingURL=index.acfa0869.css.map */\n","$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}"],"names":[],"version":3,"file":"index.acfa0869.css.map"} -------------------------------------------------------------------------------- /JS/orthographic-projection-test/dist/index.html: -------------------------------------------------------------------------------- 1 | Orthogonal test
    -------------------------------------------------------------------------------- /JS/orthographic-projection-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Orthogonal test 4 | 5 | 9 | 10 | 11 |
    12 |
    13 |
    14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "orthogonal-space-test", 3 | "packageManager": "yarn@4.5.1", 4 | "browserslist": "> 0.5%, last 2 versions, not dead", 5 | "scripts": { 6 | "start": "parcel index.html --open", 7 | "build": "parcel build index.html --public-url https://soswow.github.io/Various-JS-and-Python/JS/orthographic-projection-test/dist/" 8 | }, 9 | "devDependencies": { 10 | "@parcel/transformer-sass": "2.12.0", 11 | "@types/ndarray-ops": "^1", 12 | "parcel": "^2.12.0", 13 | "sass": "^1.80.4", 14 | "typescript": "^5.6.3" 15 | }, 16 | "dependencies": { 17 | "@types/dat.gui": "^0.7.13", 18 | "@types/ndarray": "^1.0.14", 19 | "@types/p5": "^1.7.6", 20 | "dat.gui": "^0.7.9", 21 | "ndarray": "^1.0.19", 22 | "ndarray-gemm": "^1.0.0", 23 | "ndarray-ops": "^1.2.2", 24 | "p5": "^1.11.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JS/orthographic-projection-test/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/orthographic-projection-test/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 | "target": "es2015", 13 | "rootDir": "src", 14 | "moduleResolution": "node" 15 | } 16 | } -------------------------------------------------------------------------------- /JS/other/bullseye.coffee: -------------------------------------------------------------------------------- 1 | fs = require 'fs' 2 | input = fs.readFileSync('bullseye.in', 'utf-8') 3 | 4 | arithmSum = (n) -> n/2 * (1 + n) 5 | ringsAreaPaint = (n, r) -> n * 2 * r + 4 * arithmSum(n-1) + n 6 | 7 | results = 8 | for [r, t] in input.split('\n')[1..].map( (s) -> [+s.split(' ')[0],+s.split(' ')[1]]) 9 | i = 0 10 | while ringsAreaPaint(i, r) < t 11 | i++ 12 | i 13 | 14 | console.log results -------------------------------------------------------------------------------- /JS/other/bullseye.in: -------------------------------------------------------------------------------- 1 | 5 2 | 1 9 3 | 1 10 4 | 3 40 -------------------------------------------------------------------------------- /JS/other/num-sorting.coffee: -------------------------------------------------------------------------------- 1 | testCases = [ 2 | { 3 | in: ["A1", "A10", "A2" ] 4 | out: ["A1", "A2", "A10" ] 5 | } 6 | { 7 | in: ["B9", "B345", "A10", "DAC", "B76"] 8 | out: ["A10", "B9", "B76", "B345", "DAC"] 9 | } 10 | { 11 | in: [ "11" , "1" , "21" , "122" , "A11" , "A2" , "A2B2" , "A2B11" , "A11B0" , "A1B11" , "A1C0D2" , "A1C0D11" ] 12 | out: [ "1" , "11" , "21" , "122" , "A1B11" , "A1C0D2" , "A1C0D11" , "A2" , "A2B2" , "A2B11" , "A11" , "A11B0"] 13 | } 14 | ] 15 | 16 | print = console.log 17 | 18 | assertEqualsArray = (arr1, arr2) -> 19 | throw "Lengths are different: #{arr1.length} and #{arr2.length}" unless arr1.length is arr2.length 20 | for el, i in arr1 21 | throw "Element #{i} is different: #{el} and #{arr2[i]}" unless el is arr2[i] 22 | 23 | sort = (input) -> 24 | max_tokens = 0 25 | input = input.map (item) -> 26 | tokenized = item.match(/(\D+)|(\d+)/g) 27 | max_tokens = tokenized.length if tokenized.length > max_tokens 28 | tokenized.map (token) -> 29 | int = parseInt token, 10 30 | if isNaN(int) then token else int 31 | for tok_i in [0...max_tokens] 32 | input.sort (a, b) -> 33 | # print a, b 34 | res = 35 | if a.length <= tok_i or b.length <= tok_i 36 | 0 37 | else if tok_i > 0 and a[tok_i-1] isnt b[tok_i-1] 38 | 0 39 | else if a[tok_i] is b[tok_i] 40 | 0 41 | else if a[tok_i] > b[tok_i] 42 | 1 43 | else 44 | -1 45 | # res = 0 46 | print tok_i, a.join(""), b.join(""), a[tok_i], b[tok_i], res 47 | res 48 | 49 | print tok_i, input.map (tokens) -> tokens.join "" 50 | input.map (tokens) -> tokens.join "" 51 | 52 | test = -> 53 | for {in: input, out: answer} in testCases 54 | print "=======" 55 | assertEqualsArray sort(input), answer 56 | 57 | test() 58 | 59 | 60 | a = ['1', '11', '21', '122', 'A11', 'A2', 'A1C0D11', 'A2B11', 'A11B0', 'A1B11', 'A1C0D2', 'A2B2'] -------------------------------------------------------------------------------- /JS/pong-training/index-webgl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
    20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /JS/pong-training/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
    20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /JS/pong-training/lib/convnetjs/util.js: -------------------------------------------------------------------------------- 1 | 2 | // contains various utility functions 3 | var cnnutil = (function(exports){ 4 | 5 | // a window stores _size_ number of values 6 | // and returns averages. Useful for keeping running 7 | // track of validation or training accuracy during SGD 8 | var Window = function(size, minsize) { 9 | this.v = []; 10 | this.size = typeof(size)==='undefined' ? 100 : size; 11 | this.minsize = typeof(minsize)==='undefined' ? 20 : minsize; 12 | this.sum = 0; 13 | } 14 | Window.prototype = { 15 | add: function(x) { 16 | this.v.push(x); 17 | this.sum += x; 18 | if(this.v.length>this.size) { 19 | var xold = this.v.shift(); 20 | this.sum -= xold; 21 | } 22 | }, 23 | get_average: function() { 24 | if(this.v.length < this.minsize) return -1; 25 | else return this.sum/this.v.length; 26 | }, 27 | reset: function(x) { 28 | this.v = []; 29 | this.sum = 0; 30 | } 31 | } 32 | 33 | // returns min, max and indeces of an array 34 | var maxmin = function(w) { 35 | if(w.length === 0) { return {}; } // ... ;s 36 | 37 | var maxv = w[0]; 38 | var minv = w[0]; 39 | var maxi = 0; 40 | var mini = 0; 41 | for(var i=1;i maxv) { maxv = w[i]; maxi = i; } 43 | if(w[i] < minv) { minv = w[i]; mini = i; } 44 | } 45 | return {maxi: maxi, maxv: maxv, mini: mini, minv: minv, dv:maxv-minv}; 46 | } 47 | 48 | // returns string representation of float 49 | // but truncated to length of d digits 50 | var f2t = function(x, d) { 51 | if(typeof(d)==='undefined') { var d = 5; } 52 | var dd = 1.0 * Math.pow(10, d); 53 | return '' + Math.floor(x*dd)/dd; 54 | } 55 | 56 | exports = exports || {}; 57 | exports.Window = Window; 58 | exports.maxmin = maxmin; 59 | exports.f2t = f2t; 60 | return exports; 61 | 62 | })(typeof module != 'undefined' && module.exports); // add exports to module.exports if in node.js 63 | 64 | 65 | -------------------------------------------------------------------------------- /JS/pong-training/model.js: -------------------------------------------------------------------------------- 1 | var layer_defs = []; 2 | 3 | // Input is 84x84x4 (width, height, depth) 4 | layer_defs.push({ type: 'input', out_sx: 84, out_sy: 84, out_depth: 4 }); 5 | // Conv 16 8x8 kernels, stride 4 6 | layer_defs.push({ type: 'conv', sx: 8, filters: 16, stride: 4, activation: 'relu' }); 7 | // rectifier nonlinearity 8 | 9 | // Conv 32 4x4 kernels, stride 2 10 | layer_defs.push({ type: 'conv', sx: 4, filters: 32, stride: 2, activation: 'relu' }); 11 | 12 | // FC with 256 rectifier unit 13 | layer_defs.push({ type: 'fc', num_neurons: 256, activation: 'relu' }); 14 | 15 | // FC liners with N number of outputs. for N actions 16 | layer_defs.push({ type: 'softmax', num_classes: 2 }); 17 | 18 | // create a net out of it 19 | var net1 = new convnetjs.Net(); 20 | net1.makeLayers(layer_defs); -------------------------------------------------------------------------------- /JS/pong-training/style.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | color: white; 3 | background: rgb(30,30,30); 4 | } 5 | 6 | #main { 7 | margin: 0 auto; 8 | display: block; 9 | position: relative; 10 | } -------------------------------------------------------------------------------- /JS/pong/MultiPong/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Multipong 5 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
    38 |
    39 | Wanna some Sharapova? 40 |
    41 | 42 |
    43 |
    44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
    52 |
    53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
    61 | 62 | -------------------------------------------------------------------------------- /JS/pong/MultiPong/js/sockets.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var User, socket; 3 | 4 | socket = io.connect('http://localhost:8080'); 5 | 6 | User = (function() { 7 | 8 | function User(name) { 9 | this.name = name; 10 | this.title = "Mr."; 11 | } 12 | 13 | User.prototype.toString = function() { 14 | return "" + this.title + " " + this.name; 15 | }; 16 | 17 | return User; 18 | 19 | })(); 20 | 21 | this.addUser = function() { 22 | var nameObj; 23 | nameObj = document.getElementById("userName"); 24 | return socket.emit('addNewUser', new User(nameObj.value)); 25 | }; 26 | 27 | this.sendMessage = function() { 28 | var messageObj; 29 | messageObj = document.getElementById("message"); 30 | return socket.emit('msg', messageObj.value); 31 | }; 32 | 33 | socket.on('ready', function() { 34 | return console.log("Name is setted"); 35 | }); 36 | 37 | socket.on('set sessionId', function(id) { 38 | var idObj; 39 | console.log("Our id is " + id); 40 | idObj = document.getElementById("userSessionId"); 41 | return idObj.innerHTML = id; 42 | }); 43 | 44 | }).call(this); 45 | -------------------------------------------------------------------------------- /JS/pong/MultiPong/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Multipong", 3 | "version": "0.0.1-2", 4 | "dependencies": { 5 | "socket.io": "latest", 6 | "express": "latest", 7 | "underscore": "latest" 8 | }, 9 | "analyze": false, 10 | "scripts": { 11 | "start": "node js/server.js" 12 | }, 13 | "subdomain": "multipong", 14 | "engines": { 15 | "node": "0.6.x" 16 | } 17 | } -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/ball1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/ball1.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound1.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound2.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound3.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound4.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound5.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound6.wav -------------------------------------------------------------------------------- /JS/pong/MultiPong/sounds/sound7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/pong/MultiPong/sounds/sound7.wav -------------------------------------------------------------------------------- /JS/sample.coffee: -------------------------------------------------------------------------------- 1 | actions = 2 | plus: (a, b) -> a + b 3 | minus: (a, b) -> a - b 4 | 5 | calculate = (a, action="plus", others...) -> 6 | validAction = action in Object.keys(actions) 7 | throw "Wrong action" unless validAction 8 | while others.length > 0 9 | a = actions[action] a, others.shift() 10 | return a 11 | 12 | result = calculate 10, "plus", 20, 30, 40 13 | console.log result is 100 14 | 15 | yearsOld = max: 10, ida: 9, tim: 11 16 | 17 | for filename in list 18 | do (filename) -> 19 | fs.readFile filename, (err, contents) -> 20 | compile filename, contents.toString() 21 | 22 | numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] 23 | start = numbers[0..2] 24 | numbers[3..6] = [-3, -4, -5, -6] 25 | 26 | 27 | alert( 28 | try 29 | nonexistent / undefined 30 | catch error 31 | "And the error is ... #{error}" 32 | ) 33 | 34 | 35 | futurists = 36 | sculptor: "Umberto Boccioni" 37 | painter: "Vladimir Burliuk" 38 | poet: 39 | name: "F.T. Marinetti" 40 | address: [ 41 | "Via Roma 42R" 42 | "Bellagio, Italy 22021" 43 | ] 44 | 45 | {poet: {name, address: [street, city]}} = futurists 46 | 47 | 48 | switch day 49 | when "Mon" then go work 50 | when "Tue" then go relax 51 | when "Thu" then go iceFishing 52 | when "Fri", "Sat" 53 | if day is bingoDay 54 | go bingo 55 | go dancing 56 | when "Sun" then go church 57 | else go work 58 | 59 | 60 | cholesterol = 127 61 | healthy = 200 > cholesterol > 60 -------------------------------------------------------------------------------- /JS/udacity/robotics/arrow_down_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/udacity/robotics/arrow_down_32x32.png -------------------------------------------------------------------------------- /JS/udacity/robotics/arrow_up_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/JS/udacity/robotics/arrow_up_32x32.png -------------------------------------------------------------------------------- /JS/udacity/robotics/final.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Final demo 5 | 6 | 37 | 38 | 39 |
    40 | 41 | 42 | 43 |
    44 |
    45 | 46 | 53 | 54 | Final path cost is 55 |
    56 | 61 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /JS/viz-grid/simple.gird.world.coffee: -------------------------------------------------------------------------------- 1 | $ -> 2 | W = 700 3 | H = 500 4 | SIZE = 40 5 | columns = Math.ceil W/SIZE 6 | rows = Math.ceil H/SIZE 7 | 8 | c = $("#canvas").attr({width: W, height: H}).get(0).getContext '2d' 9 | 10 | drawGrid = -> 11 | c.fillStyle = "rgb(200,200,200)" 12 | c.strokeStyle = "rgb(100,100,100)" 13 | c.fillRect 0, 0, W, H 14 | 15 | for x in [SIZE...W] by SIZE 16 | c.moveTo x + 0.5, 0 17 | c.lineTo x + 0.5, H 18 | c.stroke() 19 | 20 | for y in [SIZE...H] by SIZE 21 | c.moveTo 0, y + 0.5 22 | c.lineTo W, y + 0.5 23 | c.stroke() 24 | 25 | maze = [ 26 | ['#', '#', '#', '#', '#', 'D', '#', '#', '#', '#', '#', '#'] 27 | ['#', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'] 28 | ['#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'] 29 | ['#', '#', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'] 30 | ['#', ' ', '#', ' ', ' ', 'C', ' ', ' ', ' ', ' ', ' ', 'E'] 31 | ['#', ' ', '#', ' ', ' ', ' ', ' ', ' ', '#', '#', ' ', '#'] 32 | ['#', '#', '#', ' ', ' ', ' ', ' ', ' ', '#', '#', ' ', '#'] 33 | ['#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', '#'] 34 | ['#', '#', '#', '#', '#', 'D', '#', '#', '#', '#', '#', '#'] 35 | ] 36 | 37 | gridLocation = (x, y) -> [x * SIZE, y * SIZE] 38 | 39 | drawMaze = -> 40 | mw = maze[0].length 41 | mh = maze.length 42 | colPadding = Math.round (columns - mw) / 2 43 | rowPadding = Math.round (rows - mh) / 2 44 | for row in [0...mh] 45 | for column in [0...mw] 46 | cell = maze[row][column] 47 | c.fillStyle = { 48 | '#': "rgb(200,200,200)" 49 | ' ': "rgb(240,240,240)" 50 | D: "rgb(200,100,100)" 51 | E: "rgb(100,200,100)" 52 | B: "rgb(100,100,200)" 53 | C: "rgb(100,200,200)" 54 | }[cell] 55 | c.fillRect (column + colPadding) * SIZE+1, (row + rowPadding) * SIZE+1, SIZE-1, SIZE-1 56 | 57 | drawGrid() 58 | drawMaze() -------------------------------------------------------------------------------- /JS/viz-grid/simple.gird.world.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Python/Inkscape/vertical_plotter_transform.inx: -------------------------------------------------------------------------------- 1 | 2 | 3 | <_name>Vertical Plotter Transform 4 | org.soswow.vertical.plotter.transform 5 | flatten.py 6 | addnodes.py 7 | inkex.py 8 | 9 | vertical_plotter_transform.py 10 | 10.0 11 | 10.0 12 | 13 | path 14 | 15 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /Python/Inkscape/vertical_plotter_transform.py: -------------------------------------------------------------------------------- 1 | 2 | import addnodes, flatten, inkex 3 | 4 | class Transform(flatten.MyEffect, addnodes.SplitIt): 5 | def __init__(self): 6 | flatten.MyEffect.__init__(self) 7 | flattenOptions = self.OptionParser._get_all_options() 8 | addnodes.SplitIt.__init__(self) 9 | self.OptionParser.set_conflict_handler("resolve") 10 | self.OptionParser.add_options(flattenOptions) 11 | 12 | def effect(self): 13 | flatten.MyEffect.effect(self) 14 | addnodes.SplitIt.effect(self) 15 | 16 | if __name__ == '__main__': 17 | e = Transform() 18 | e.affect() 19 | -------------------------------------------------------------------------------- /Python/MovieTweeterRanking/.gitignore: -------------------------------------------------------------------------------- 1 | config.json -------------------------------------------------------------------------------- /Python/MovieTweeterRanking/config.json.sample: -------------------------------------------------------------------------------- 1 | { 2 | "consumer_key": "", 3 | "consumer_secret": "", 4 | "access_token":"", 5 | "access_token_secret":"" 6 | } -------------------------------------------------------------------------------- /Python/MovieTweeterRanking/main.py: -------------------------------------------------------------------------------- 1 | import urllib2 2 | import twitter 3 | from nltk.stem import WordNetLemmatizer 4 | from nltk.stem.snowball import EnglishStemmer 5 | import re 6 | from senticnet.senticnet import Senticnet 7 | 8 | def get_words_bag(message): 9 | wnl = WordNetLemmatizer() 10 | es = EnglishStemmer() 11 | for word in re.finditer("\w+", message): 12 | yield (wnl.lemmatize(word.group()), es.stem(word.group())) 13 | 14 | def get_avg_polarity(message): 15 | threshold = 0.3 16 | sn = Senticnet() 17 | count = 0 18 | summ = 0 19 | for word_options in get_words_bag(message): 20 | polarity = 0 21 | for word in word_options: 22 | try: 23 | concept = sn.concept(word) 24 | polarity = concept['polarity'] 25 | break 26 | except urllib2.HTTPError: 27 | pass #Do next 28 | if abs(polarity) > threshold: 29 | summ += polarity 30 | count += 1 31 | 32 | return summ / count if count > 0 else 0 33 | 34 | 35 | def main(): 36 | pass 37 | # reader = twitter.TwitterReader() 38 | # tweets = reader.search("Python", 10) 39 | # print "\n".join(tweets) 40 | print get_avg_polarity("Ok thanks RT @KaYsutra: It is,,'RT @Chinellly Who has watched a good day to die hard?I wanna know if it's a gud movie 2 see in d cinema.") 41 | 42 | 43 | 44 | if __name__ == "__main__": 45 | main() -------------------------------------------------------------------------------- /Python/MovieTweeterRanking/twitter.py: -------------------------------------------------------------------------------- 1 | import tweepy 2 | import json 3 | 4 | class TwitterReader(object): 5 | def __init__(self): 6 | self.api = self._get_api() 7 | 8 | def _get_api(self): 9 | config = self._get_config() 10 | auth = tweepy.OAuthHandler(config['consumer_key'], config['consumer_secret']) 11 | auth.set_access_token(config['access_token'], config['access_token_secret']) 12 | return tweepy.API(auth) 13 | 14 | def _get_config(self): 15 | with open("config.json") as f: 16 | return json.load(f) 17 | 18 | def search(self, query, size): 19 | tweets = [] 20 | max_id = None 21 | print "Start searching ... " 22 | while len(tweets) < size: 23 | print "%d tweets read so far" % len(tweets) 24 | more = self.api.search(q=query, rpp=100, max_id=max_id) 25 | print "%d tweets read more" % len(more) 26 | tweets += map(lambda a: a.text, more) 27 | max_id = more[-1].id - 1 28 | print "Last id: %d" % more[-1].id 29 | return tweets[size:] -------------------------------------------------------------------------------- /Python/Udacity/Deep Learning/.gitignore: -------------------------------------------------------------------------------- 1 | notMNIST_large.tar.gz 2 | notMNIST_small.tar.gz 3 | notMNIST.pickle 4 | .ipynb_*/ 5 | -------------------------------------------------------------------------------- /Python/Udacity/Deep Learning/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcr.io/tensorflow/tensorflow:latest 2 | MAINTAINER Vincent Vanhoucke 3 | 4 | # Pillow needs libjpeg by default as of 3.0. 5 | RUN apt-get update && apt-get install -y --no-install-recommends \ 6 | libjpeg8-dev \ 7 | && \ 8 | apt-get clean && \ 9 | rm -rf /var/lib/apt/lists/* 10 | 11 | RUN pip install scikit-learn pyreadline Pillow 12 | RUN rm -rf /notebooks/* 13 | ADD *.ipynb /notebooks/ 14 | WORKDIR /notebooks 15 | CMD ["/run_jupyter.sh"] 16 | -------------------------------------------------------------------------------- /Python/Udacity/Robotic Car/hw1.py: -------------------------------------------------------------------------------- 1 | colors = [['red', 'green', 'green', 'red' , 'red'], 2 | ['red', 'red', 'green', 'red', 'red'], 3 | ['red', 'red', 'green', 'green', 'red'], 4 | ['red', 'red', 'red', 'red', 'red']] 5 | 6 | measurements = ['green', 'green', 'green' ,'green', 'green'] 7 | 8 | 9 | motions = [[0,0],[0,1],[1,0],[1,0],[0,1]] 10 | 11 | sensor_right = 0.7 12 | 13 | p_move = 0.8 14 | 15 | def show(p): 16 | for i in range(len(p)): 17 | print p[i] 18 | 19 | #DO NOT USE IMPORT 20 | #ENTER CODE BELOW HERE 21 | #ANY CODE ABOVE WILL CAUSE 22 | #HOMEWORK TO BE GRADED 23 | #INCORRECT 24 | world = colors 25 | pHit = sensor_right 26 | pMiss = 1 - sensor_right 27 | pExact = p_move 28 | pStay = 1 - p_move 29 | 30 | def get_dims(): 31 | return len(world), len(world[0]) 32 | 33 | def init(num=None): 34 | p = [] 35 | ydim, xdim = get_dims() 36 | if num is None: 37 | num = 1.0 / (xdim * ydim) 38 | for y in range(ydim): 39 | p.append([num] * xdim) 40 | return p 41 | 42 | def sense(p, measurement): 43 | total = 0 44 | 45 | for y, row in enumerate(p): 46 | for x, cell in enumerate(row): 47 | p[y][x] = cell * pHit if world[y][x] == measurement else cell * pMiss 48 | total += sum(p[y]) 49 | 50 | for y, row in enumerate(p): 51 | for x, cell in enumerate(row): 52 | p[y][x] = cell / total 53 | 54 | return p 55 | 56 | def move(p, U): 57 | ydim, xdim = get_dims() 58 | ydif, xdif = U[0] % ydim, U[1] % xdim 59 | accum = init(0) 60 | q = p[-ydif:] + p[:-ydif] 61 | for y, row in enumerate(q): 62 | q[y] = row[-xdif:] + row[:-xdif] 63 | 64 | for y, row in enumerate(q): 65 | for x, cell in enumerate(row): 66 | accum[y][x] += cell * pExact 67 | accum[y-ydif][x-xdif] += cell * pStay 68 | 69 | return accum 70 | 71 | p = init() 72 | for i, color in enumerate(measurements): 73 | p = move(p, motions[i]) 74 | p = sense(p, color) 75 | 76 | #Your probability array must be printed 77 | #with the following code. 78 | 79 | show(p) 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Python/Udacity/Robotic Car/unit1.py: -------------------------------------------------------------------------------- 1 | p=[0.2, 0.2, 0.2, 0.2, 0.2] 2 | world=['green', 'red', 'red', 'green', 'green'] 3 | measurements = ['red', 'green'] 4 | motions = [1,1] 5 | pHit = 0.6 6 | pMiss = 0.2 7 | pExact = 0.8 8 | pOvershoot = 0.1 9 | pUndershoot = 0.1 10 | 11 | def sense(p, measurement): 12 | q = [it * pHit if world[i] == measurement else it * pMiss for i, it in enumerate(p)] 13 | total = sum(q) 14 | return [it/total for it in q] 15 | 16 | def move(p, U): 17 | l = len(p) 18 | i = U % l 19 | accum = [0] * l 20 | q = p[-i:] + p[:-i] 21 | for i, k in enumerate(q): 22 | accum[i] += k * pExact 23 | accum[(i-1) % l] += k * pUndershoot 24 | accum[(i+1) % l] += k * pUndershoot 25 | return accum 26 | 27 | for i in range(len(measurements)): 28 | p = sense(p, measurements[i]) 29 | p = move(p, motions[i]) 30 | 31 | print p -------------------------------------------------------------------------------- /Python/elec_calc/input.txt: -------------------------------------------------------------------------------- 1 | 5.65, 0.05 2 | 0, 0, 0, -1 3 | 2.825, 2.825, 0, -1 4 | 0, 2.825, 2.825, -1 5 | 2.825, 0, 2.825, -1 6 | 2.825, 2.825, 2.825, 1 7 | 2.825, 0, 0, 1 8 | 0, 0, 2.825, 1 9 | 0, 2.825, 0, 1 -------------------------------------------------------------------------------- /Python/halite/.gitignore: -------------------------------------------------------------------------------- 1 | *.hlt 2 | *.log 3 | *.pyc 4 | __pycache__/ 5 | data/ 6 | saved_model/ 7 | -------------------------------------------------------------------------------- /Python/halite/MyMLBotTest.py: -------------------------------------------------------------------------------- 1 | from MyMLBot import Solver 2 | from hlt import Square, GameMap, grouper 3 | import numpy as np 4 | 5 | 6 | class FakeGameMap(GameMap): 7 | def __init__(self, size): 8 | self.width, self.height = size, size 9 | self.contents = None 10 | 11 | def update_frame(self, owners, strengths, productions): 12 | self.contents = [[Square(x, y, owner, strength, production) 13 | for x, (owner, strength, production) 14 | in enumerate(zip(owner_row, strength_row, production_row))] 15 | for y, (owner_row, strength_row, production_row) 16 | in enumerate(zip(grouper(owners, self.width), 17 | grouper(strengths, self.width), 18 | grouper(productions, self.width)))] 19 | 20 | def get_frame(self, map_string=None): 21 | pass 22 | 23 | 24 | productions = np.array([ 25 | [1, 2, 1, 2, 1], 26 | [1, 1, 2, 2, 1], 27 | [1, 1, 2, 2, 1], 28 | [1, 1, 1, 3, 1], 29 | [1, 2, 1, 3, 2] 30 | ]).flatten() 31 | 32 | owners = np.array([ 33 | [0, 0, 0, 0, 0], 34 | [0, 1, 0, 0, 0], 35 | [0, 0, 0, 0, 0], 36 | [0, 0, 0, 2, 0], 37 | [0, 0, 0, 0, 0], 38 | ]).flatten() 39 | 40 | strengths = np.array([ 41 | [1, 1, 1, 0, 0], 42 | [1, 5, 1, 0, 0], 43 | [1, 1, 1, 1, 1], 44 | [0, 0, 1, 6, 1], 45 | [0, 0, 1, 1, 1], 46 | ]).flatten() 47 | 48 | fake_map = FakeGameMap(5) 49 | fake_map.update_frame(owners, strengths, productions) 50 | solver = Solver(1, fake_map) 51 | moves = solver.process_frame() 52 | print(moves) 53 | -------------------------------------------------------------------------------- /Python/halite/RandomBot.py: -------------------------------------------------------------------------------- 1 | import hlt 2 | from hlt import NORTH, EAST, SOUTH, WEST, STILL, Move, Square 3 | import random 4 | 5 | 6 | myID, game_map = hlt.get_init() 7 | hlt.send_init("Ran9domPythonBot") 8 | 9 | while True: 10 | game_map.get_frame() 11 | moves = [ 12 | Move(square, random.choice((NORTH, EAST, SOUTH, WEST, STILL))) 13 | for square in game_map 14 | if square.owner == myID] 15 | hlt.send_frame(moves) 16 | -------------------------------------------------------------------------------- /Python/halite/halite-mac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/Python/halite/halite-mac -------------------------------------------------------------------------------- /Python/halite/halite-ubuntu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soswow/Various-JS-and-Python/67b81534cbc6307c93b58df0bf1d9d9cb320734b/Python/halite/halite-ubuntu -------------------------------------------------------------------------------- /Python/halite/pipe_socket_translator.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | 4 | # Connect 5 | socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | socket.bind(('localhost', int(sys.argv[1]))) 7 | socket.listen(1) 8 | connection, _ = socket.accept() 9 | 10 | 11 | # IO Functions 12 | def sendStringPipe(toBeSent): 13 | sys.stdout.write(toBeSent + '\n') 14 | sys.stdout.flush() 15 | 16 | 17 | def getStringPipe(): 18 | str = sys.stdin.readline().rstrip('\n') 19 | return (str) 20 | 21 | 22 | def sendStringSocket(toBeSent): 23 | global connection 24 | toBeSent += '\n' 25 | connection.sendall(bytes(toBeSent, 'ascii')) 26 | 27 | 28 | def getStringSocket(): 29 | global connection 30 | newString = "" 31 | buffer = '\0' 32 | while True: 33 | buffer = connection.recv(1).decode('ascii') 34 | if buffer != '\n': 35 | newString += str(buffer) 36 | else: 37 | return newString 38 | 39 | 40 | # Handle Init IO 41 | sendStringSocket(getStringPipe()) # Player ID 42 | sendStringSocket(getStringPipe()) # Map Dimensions 43 | sendStringSocket(getStringPipe()) # Productions 44 | sendStringSocket(getStringPipe()) # Starting Map 45 | sendStringPipe(getStringSocket()) # Player Name / Ready Response 46 | 47 | # Run Frame Loop 48 | while True: 49 | sendStringSocket(getStringPipe()) # Frame Map 50 | sendStringPipe(getStringSocket()) # Move List 51 | -------------------------------------------------------------------------------- /Python/halite/pull_data_from.js: -------------------------------------------------------------------------------- 1 | const request = require('request'); 2 | const fs = require('fs'); 3 | const _ = require('lodash'); 4 | 5 | const getJson = (url, qs={}) => { 6 | return new Promise((resolve, reject) => { 7 | console.log(`Requesting url: ${url}`); 8 | request.get({url:url, qs:qs, json:true, gzip: true}, (error, response, body) => { 9 | if (error) { 10 | return reject(error); 11 | } 12 | 13 | if(response.statusCode >= 400){ 14 | return reject(response); 15 | } 16 | 17 | return resolve(body); 18 | }); 19 | }); 20 | }; 21 | 22 | const getListOfTopUsers = (limit=20) => { 23 | return getJson( 24 | 'https://halite.io/api/web/user', 25 | { 26 | 'fields[]': 'isRunning', 27 | 'values[]': 1, 28 | 'orderBy': 'rank', 29 | 'limit': limit, 30 | 'page': 0 31 | }).then((data) => { 32 | return data.users; 33 | }); 34 | }; 35 | 36 | const getUserWonGames = (userID, limit=10) => { 37 | console.log(`Requesting games for ${userID} with limit ${limit}`); 38 | return getJson('https://halite.io/api/web/game', {userID, limit}) 39 | .then((games) => { 40 | console.log(`Loaded ${games.length} for user ${userID}`); 41 | return _.filter(games, (game) => _.find(game.users, {'rank': '1'}).userID === userID); 42 | }); 43 | }; 44 | 45 | const downloadGame = (replayFileName, username) => { 46 | const url = `https://s3.amazonaws.com/halitereplaybucket/${replayFileName}`; 47 | const dest = `data/${replayFileName}.json`; 48 | 49 | return getJson(url).then((data) => { 50 | data.winner = username; 51 | data.winner_index = _.findIndex(data.player_names, (name) => name.indexOf(username) === 0); 52 | fs.writeFileSync(dest, JSON.stringify(data)); 53 | return dest; 54 | }); 55 | }; 56 | 57 | getListOfTopUsers(10) 58 | .then((users) => { 59 | const usernames = _.map(users, (user) => `${user.username}\t(${user.userID})`).join('\t\n'); 60 | console.log(`Download following users games:\n${usernames}`); 61 | return users; 62 | }) 63 | .then((users) => 64 | Promise.all( 65 | users.map((user) => 66 | getUserWonGames(user.userID, 20).then((games) => 67 | Promise.all( 68 | games.map((game) => 69 | downloadGame(game.replayName, user.username) 70 | ) 71 | ) 72 | ) 73 | ) 74 | ) 75 | ) 76 | .catch((error) => { 77 | console.log(error); 78 | }); 79 | -------------------------------------------------------------------------------- /Python/halite/script/debugGame.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | trap "killall python3; exit" SIGHUP SIGINT SIGTERM 4 | ./halite-mac -t -d "30 30" "python3 MyBot2.py" "python3 pipe_socket_translator.py 2000" 5 | -------------------------------------------------------------------------------- /Python/halite/script/runGame.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if hash python3 2>/dev/null; then 4 | ./halite-mac -d "30 30" "python3 MyBot2.py" "python3 MyBot3.py" 5 | else 6 | ./halite-mac -d "30 30" "python MyBot2.py" "python MyMLBot.py" 7 | fi 8 | -------------------------------------------------------------------------------- /Python/red-button/LibusbSheild.kext/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleGetInfoString 8 | Libusb USB device 9 | Shield 10 | 11 | CFBundleIdentifier 12 | com.libusb.USB_Shield 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Libusb USB device Shield 17 | CFBundlePackageType 18 | KEXT 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 6.0 23 | IOKitPersonalities 24 | 25 | HCFR 26 | 27 | CFBundleIdentifier 28 | com.apple.driver.AppleUSBComposite 29 | IOClass 30 | AppleUSBComposite 31 | IOProviderClass 32 | IOUSBDevice 33 | idVendor 34 | 7476 35 | idProduct 36 | 13 37 | 38 | 39 | OSBundleCompatibleVersion 40 | 1.8 41 | OSBundleLibraries 42 | 43 | com.apple.kernel.iokit 44 | 6.0 45 | 46 | 47 | -------------------------------------------------------------------------------- /Python/red-button/install_sheild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo cp -R LibusbSheild.kext /System/Library/Extensions -------------------------------------------------------------------------------- /Python/red-button/redbutton.py: -------------------------------------------------------------------------------- 1 | import usb.core 2 | import usb.util 3 | 4 | dev = usb.core.find(idVendor=0x1D34,idProduct=0x000D) 5 | 6 | if dev is None: 7 | raise ValueError('Device not found') 8 | 9 | dev.set_configuration() 10 | cfg = dev.get_active_configuration() 11 | interface_number = cfg[(0,0)].bInterfaceNumber 12 | alternate_setting = usb.control.get_interface(dev, interface_number) 13 | intf = usb.util.find_descriptor( 14 | cfg, bInterfaceNumber = interface_number, 15 | bAlternateSetting = alternate_setting 16 | ) 17 | ep = usb.util.find_descriptor(intf,bEndpointAddress=0x81) 18 | a = ep.read(1) 19 | print a -------------------------------------------------------------------------------- /Python/red-button/redbutton2.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | import PyHID 3 | PyHID.initialise() 4 | d = PyHID.scan_devices()[-2] 5 | print d.name 6 | d.enable_monitoring() 7 | #el = d.elements[0] 8 | # 9 | # 10 | for el in d.elements: 11 | try: 12 | # el.enable_monitoring() 13 | print el.read(), el(), "ok" 14 | # print 15 | # print "ok" 16 | except: 17 | print "fail" 18 | #print "\n".join([str(e) for e in d.elements]) 19 | #print "\n".join([e.get_usage_string() for e in d.elements]) 20 | #print "\n".join([e.get_usage_page_string() for e in d.elements]) 21 | try: 22 | # pass 23 | while True: 24 | sleep(0.1) 25 | res = d.poll() 26 | if res: 27 | print res 28 | except KeyboardInterrupt: 29 | PyHID.finalise() 30 | 31 | PyHID.finalise() 32 | 33 | 34 | -------------------------------------------------------------------------------- /Python/special-sorting/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | from exceptions import BaseException, ValueError 3 | 4 | def try_to_int(el): 5 | try: 6 | return int(el) 7 | except ValueError: 8 | return el 9 | 10 | def comp(a,b,i): 11 | if i >= min(len(a), len(b)) or (i > 0 and a[i-1] != b[i-1]): 12 | return 0 13 | else: 14 | return 1 if a[i] > a[i] else -1 if a[i] < b[i] else 0 15 | 16 | def mega_sort(arr): 17 | arr = [[try_to_int(item2) for item2 in re.split('(\d*)', item) if item2] for item in arr] 18 | max_items = max([len(item) for item in arr]) 19 | for i in range(0, max_items): 20 | arr.sort(cmp=lambda a,b: comp(a,b,i) ) 21 | return ["".join(map(str, item)) for item in arr] 22 | 23 | def main(): 24 | arr = ["A10", "A11", "A2", "B1", "A2B1", "A2B11", "A2B2", "A2BCC", "A2BCC1", "A2BCC3", "B2", "A2BCC22",] 25 | right_result = ["A2","A2B1", "A2B2", "A2B11", "A2BCC", "A2BCC1", "A2BCC3", "A2BCC22","A10", "A11", "B1", "B2"] 26 | result = mega_sort(arr) 27 | if result != right_result: 28 | print result 29 | raise BaseException("Not equal") 30 | 31 | if __name__ =="__main__": 32 | main() --------------------------------------------------------------------------------