Skip to content

Instantly share code, notes, and snippets.

View afghl's full-sized avatar
👨‍💻
Engineering

airport1030 afghl

👨‍💻
Engineering
View GitHub Profile
const fs = require('fs')
class KeyValue {
constructor(key, value) {
this.key = key
this.value = value
}
}
const mapF = (fileName, contents) =>
@afghl
afghl / LRUCache.java
Created June 23, 2018 16:35
A LRU cache implementation
package cache;
import java.util.HashMap;
import java.util.Map;
public class LRUCache {
private static final int NOTHING = -1;
private int capacity;
private int size;
private Map<Integer, Node> map = new HashMap<>();
# http://group.jobbole.com/22681/?utm_source=blog.jobbole.com&utm_medium=sidebar-group-topic
def test_str(str)
str_arr = str.split ''
if has_continuous_char(str_arr) || has_pattern(str_arr)
'Dislikes'
else
'Likes'
end
end

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@afghl
afghl / count_change.rb
Created February 28, 2016 14:40
count_change :)
def count_change(n, coins = [50, 25, 10, 5, 1])
return 1 if n == 0
return 0 if n < 0 || coins.length == 0
count_change(n - coins[0], coins) + count_change(n, coins[1 .. -1])
end
p count_change(100)