This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implement generic for two way linked list for different items type. | |
| interface ILinkedList<T> { | |
| append(value: T); | |
| pop():T|null; | |
| showlist():void; | |
| } | |
| class LinkedList<T> implements ILinkedList<T> { | |
| public head:MyNode<T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ruby -v: 2.3.4 | |
| # Chart: https://jsfiddle.net/81ef590x/116/ | |
| require 'benchmark' | |
| def without_gc | |
| GC.start | |
| GC.disable | |
| yield | |
| GC.enable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getFakeHistory = function(){ | |
| return (new Array(20000).join('a')) | |
| } | |
| function Record(id, description) { | |
| this.id = id; | |
| this.description = description; | |
| } | |
| # We need that function to prevent V8 optimisation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://github.com/gtaranas/forecaster/blob/47707dcbfd7c23acedbd7428ae35a8696aaa8c49/src/renderer/datastore.js | |
| https://codepen.io/lonekorean/pen/xGLLwX?editors=1100 | |
| import PouchDB from 'pouchdb-browser' | |
| import path from 'path' | |
| import { remote } from 'electron' | |
| const db = new PouchDB(path.join(remote.app.getPath('userData'), '/data.db')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| todos_reducer = -> (state, action) { | |
| state ||= [] | |
| case action[:type] | |
| when 'add' | |
| state.push(action[:todo]) | |
| when 'remove' | |
| state.remove(action[:todo]) | |
| else | |
| state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'faraday' | |
| require 'pluck_all' | |
| require 'eventmachine' | |
| require 'em-http-request' | |
| require 'pry' | |
| EventMachine.run { | |
| total_size = 0 | |
| p 'start' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pluck_all' | |
| require 'eventmachine' | |
| require 'em-http-request' | |
| # require 'pry' | |
| # EventMachine.run do | |
| # page = EventMachine::HttpRequest.new('http://google.ca/').get | |
| # page.errback { p "Google is down! terminate?" } | |
| # page.callback { | |
| # about = EventMachine::HttpRequest.new('http://google.ca/search?q=eventmachine').get |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| desc 'Video thumbnails' | |
| task video_thumbnails_ping: :environment do | |
| p 'video_thumbnails_ping START' | |
| t1 = Time.now | |
| THREAD_COUNT = 8 # tweak this number for maximum performance. | |
| MAX_COUNT = 5000 | |
| thumbnails = Thumbnail.last(MAX_COUNT).pluck(:id, :combined_url_2, :combined_url_1) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.routes.draw do | |
| ActiveAdmin.routes(self) | |
| devise_for :users, skip: [:sessions, :registrations, :passwords, :confirmations] | |
| devise_scope :user do | |
| # Sessions: | |
| post 'auth/sign_in', to: 'auth/sessions#create', as: :user_session, defaults: { format: 'js' } | |
| get 'auth/sign_out', to: 'auth/sessions#destroy', as: :destroy_user_session, defaults: { format: 'html' } | |
| # Registrations: | |
| post 'auth', to: 'auth/registrations#create', as: :user_registration, defaults: { format: 'js' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.paths['config/routes.rb'] = Dir[Rails.root.join('config/routes/*.rb')] |