Skip to content

Instantly share code, notes, and snippets.

// Script to randomly select participants in FMFs design contest
//
// Requirements:
// - Nodejs 4.0+
//
// Instructions:
// 1) Download script to directory
// 2) In directory, run `node formosa-vote.js`
// 3) Output is the Telegram display name and telegram url.
@MattNguyen
MattNguyen / graph.png
Last active February 16, 2018 06:46
Images for Decentralized Identities for the Cannabis Industries
Images
@MattNguyen
MattNguyen / gist:3ff7f5bf23d896f89d13
Last active August 29, 2015 14:04
Coin Change Problem
# Coin Change Problem:
# Given a set of coin denominations, find the minimum number of coins to make change for a target amount.
#
# Analysis:
# 1. Optimal substructure (combination of optimal solutions to subproblems):
# Let S be the set of denominations and d(sub i) an individual denomination
# Let n be the target number.
# Let OS(n) be the optimal solution for n.
#
# If n > d(sub i)
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr> " Ctrl+n toggles relative line numbers on and off
:au FocusLost * :set number " Turns relative numbers off for all buffers not in focus
@MattNguyen
MattNguyen / book.rb
Created June 16, 2012 03:03
Create a book class
class Book
attr_accessor :title
def title
split_titles = @title.split
split_titles.each_with_index do |title, index|
case
when title =~ /(\Aan\z)|(\Aa\z)|(\Aand\z)|(\Ain\z)/ then next
when title =~ /(^the)/ && index != 0 then next
else title.capitalize!
@MattNguyen
MattNguyen / number_to_words.rb
Created June 15, 2012 03:46
Number to words
module InWords
def in_words
single = { 1 => "one", 2 => "two", 3 => "three", 4 => "four",
5 => "five", 6 => "six", 7 => "seven", 8 => "eight",
9 => "nine" }
teens = { 10 => "ten", 1 => "eleven", 2 => "twelve", 3 => "thirteen",
4 => "fourteen", 5 => "fifteen", 6 => "sixteen", 7 => "seventeen",
8 => "eighteen", 9 => "ninteen" }