Skip to content

Instantly share code, notes, and snippets.

View Linell's full-sized avatar
🧙

Linell Bonnette Linell

🧙
View GitHub Profile
@Linell
Linell / jarascrit.js
Last active August 29, 2015 14:03
Loops through each a tag in the `#navbar` and compares it to the url. If it's a match BOOM add active to it.
$(document).ready(function() {
p = location.pathname.replace('/', '').split('/')[0];
$("#navbar a").each(function() {
if ( $(this).attr('href').replace('/', '') == p ) {
$(this).parent().addClass('active');
return;
}
});
});
@Linell
Linell / .phoenix.js
Last active August 29, 2015 14:03
My dotfile for Phoenix - (https://github.com/sdegutis/Phoenix).
/*
▄███████▄ ▄█ █▄ ▄██████▄ ▄████████ ███▄▄▄▄ ▄█ ▀████ ▐████▀
███ ███ ███ ███ ███ ███ ███ ███ ███▀▀▀██▄ ███ ███▌ ████▀
███ ███ ███ ███ ███ ███ ███ █▀ ███ ███ ███▌ ███ ▐███
███ ███ ▄███▄▄▄▄███▄▄ ███ ███ ▄███▄▄▄ ███ ███ ███▌ ▀███▄███▀
▀█████████▀ ▀▀███▀▀▀▀███▀ ███ ███ ▀▀███▀▀▀ ███ ███ ███▌ ████▀██▄
███ ███ ███ ███ ███ ███ █▄ ███ ███ ███ ▐███ ▀███
███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███ ███▄
▄████▀ ███ █▀ ▀██████▀ ██████████ ▀█ █▀ █▀ ████ ███▄

Keybase proof

I hereby claim:

  • I am Linell on github.
  • I am linell (https://keybase.io/linell) on keybase.
  • I have a public key whose fingerprint is E285 1A23 F740 2AAF 6EE5 73C4 ACB8 24FC 7396 12F9

To claim this, I am signing this object:

@Linell
Linell / Project Euler Problem One.swift
Last active March 10, 2016 19:12
Project Euler Problem One If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
func isGood(number: Int) -> Bool {
return (number % 3 == 0 || number % 5 == 0)
}
Array(3...999)
.filter { (number) in isGood(number) }
.reduce(0) { (total, number) in total + number }
@Linell
Linell / random_date.rb
Last active August 29, 2015 14:11
Generates a random date between two given dates.
def random_date
date1 = DateTime.new(2014,8,1)
date2 = DateTime.now()
Time.at( (date2.to_f - date1.to_f)*rand + date1.to_f).to_date
end
# Type(<scope>): <subject>
# <body>
# <footer>
# Type should be one of the following:
# * feat (new feature)
# * fix (bug fix)
# * docs (changes to documentation)
@Linell
Linell / pe_problem_one.ex
Created April 27, 2015 20:44
Project Euler problem on in Elixir.
# The fancy anonymous function syntax. I'm kind of not a fan of it in this case.
divisible? = &(rem(&1, 5) == 0 || rem(&1, 3) == 0)
1..999 |> Enum.filter(divisible?) |> Enum.sum
@Linell
Linell / jose.ex
Created April 28, 2015 18:00
split a string up into given chunks
"Jose"
|> String.codepoints()
|> Enum.chunk(2)
|> Enum.map(&Enum.join(&1, ""))
# ["Jo", "se"]
@Linell
Linell / euler_one.ex
Created September 2, 2015 20:55
Project Euler problem on in Elixir.
Enum.filter(1..999, fn(x) -> rem(x, 5) == 0 || rem(x, 3) == 0 end)
|> Enum.reduce(fn(x, acc) -> acc + x end)
# 233168
-- Works perfectly!
SELECT COUNT(*),
ST_Union(geom) as location_union,
ST_SnapToGrid(ST_Transform(ST_SnapToGrid(ST_Transform(geom, _ST_BestSRID(geom)), 10,10),4326),0.0001, 0.0001) AS snap_pt
FROM locations
GROUP BY snap_pt
HAVING COUNT(*) > 1;
-- But what's a decent way to figure out which groups contain a given user?
-- I can use the following query to get the list of users in an example ST_Union from above: