Skip to content

Instantly share code, notes, and snippets.

View malina's full-sized avatar
🌴

Alexandr Shumov malina

🌴
View GitHub Profile
@malina
malina / gist:f2158ec2c4262159cd231e05b2251d35
Created October 20, 2017 02:51 — forked from sirupsen/gist:6479740
Implementation of a trie in Ruby.
class Trie
attr_accessor :word, :trie
def initialize
@trie = {}
@word = false
end
def <<(string)
node = string.each_char.inject(self) { |node, char| node.trie[char] ||= Trie.new }
@malina
malina / trie.rb
Created October 20, 2017 02:50 — forked from ackintosh/trie.rb
Trie tree implementation in Ruby.
class Node
attr_reader :data, :children
attr_accessor :term
def initialize(data)
@data = data
@children = []
@term = false
end
def insert(char)
@malina
malina / README.md
Created May 29, 2017 07:05 — forked from devotox/README.md
Ember Engines With Ember Simple Auth

Using Ember Simple Auth with Ember Engines (In Repo Engine)

  • This shows the steps needed to get Ember Simple Auth to work with Ember Engines as if they are the same application

  • Things to note

    • engine login page needs to transitionToExternal('login')
    • login has to be passed in as an external route to the engine
    • session and cookie services both need to be passed into engine
    • sessionAuthenticated function needs to be overwritten in the Application Controller of the Engine
  • in /app/app.js add to const engines object { [Engine Name]: dependencies }

@malina
malina / adapters.application.js
Created February 10, 2017 02:25 — forked from pangratz/adapters.application.js
POC store.cachedQuery()
import DS from "ember-data";
export default DS.JSONAPIAdapter.extend();
@malina
malina / README.md
Created February 7, 2017 01:48 — forked from HaNdTriX/README.md
Creating a webextension generator

Hi

I am Henrik and I want to create a webextension generator that supports chrome, firefox, opera and safari. The stack I would like to use will contain:

  • yeoman for scaffolding
  • gulp as a build system
  • webpack for script compilation (modules, env variables, polyfills)
  • npm as a module system
  • and babel for ES2015
@malina
malina / kmeans.rb
Created February 2, 2017 08:55
k-means clustering implemented in ruby
class Point
attr_accessor :x, :y
# Constructor that takes in an x,y coordinate
def initialize(x,y)
@x = x
@y = y
end
# Calculates the distance to Point p
@malina
malina / application.controller.js
Created January 6, 2017 08:40 — forked from patrickarlt/application.controller.js
ember-with-custom-events
import Ember from 'ember';
class ItemRating extends HTMLElement {
createdCallback () {
this.insertAdjacentHTML('afterbegin', `
<a data-rating="1">&#9733;</a>
<a data-rating="2">&#9733;</a>
<a data-rating="3">&#9733;</a>
<a data-rating="4">&#9733;</a>
<a data-rating="5">&#9733;</a>
@malina
malina / bracketsMatchingTest.js
Created September 1, 2016 07:33 — forked from jenyayel/bracketsMatchingTest.js
Implement function check (text) which checks whether brackets within text are correctly nested. You need to consider brackets of three kinds: (), [], {}.
var expect = require('expect')
var _matches = {
'{': { invert: '}', isOpening: true },
'}': { invert: '{', isOpening: false },
'(': { invert: ')', isOpening: true },
')': { invert: '(', isOpening: false },
'[': { invert: ']', isOpening: true },
']': { invert: '[', isOpening: false }
};
@malina
malina / gist:c29faab366252c12f1e165a1b5794eae
Created September 1, 2016 07:33 — forked from paveleremin/gist:86dafdb4341244fc3a94
Brackets are correctly nested (two different approaches)
/**
* Implement function check (text) which checks whether brackets within text are correctly nested.
* You need to consider brackets of three kinds: (), [], {}.
*/
/**
* STACK approach
*/
function check(str){
var brackets = "()[]{}",
find ~/.bundle/cache -type d -exec chmod 0755 {} +