Skip to content

Instantly share code, notes, and snippets.

require 'benchmark'
# Solution 1
def solution_1(list_of_inputs)
list_of_inputs
.sort { |x, y| x<=>y }
.first(3)
.reduce(&:*)
end
@desmondhume
desmondhume / map_to_query_string.ex
Created August 6, 2016 18:13
Convert elixir map to query string
defmodule URL do
def to_query(input, namespace) do
Enum.map(input, fn({key, value}) -> parse("#{namespace}[#{key}]",value)end)
|> Enum.join("&")
end
def to_query(input) do
Enum.map(input, fn({key, value}) -> parse(key,value) end)
|> Enum.join("&")
end
@desmondhume
desmondhume / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@desmondhume
desmondhume / Ajax single page
Created June 7, 2014 17:14
Ajax single page
<?php
function curl_download($Url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
/usr/bin/make all-recursive
Making all in include
Making all in libxml
make[3]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all-am'.
Making all in .
CC entities.lo
CC encoding.lo
CC SAX.lo
CC error.lo
@desmondhume
desmondhume / snippet.html
Created May 7, 2013 16:58
Pure css cross-browser arrow
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<a href="">Scopri<span></span></a>
</body>
</html>
@desmondhume
desmondhume / gist:5510040
Last active December 16, 2015 22:49
Example of pure css fold on top of a box.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tests</title>
<style>
.badge {
background: green;
width: 200px;