Skip to content

Instantly share code, notes, and snippets.

Linell Bonnette Linell

Block or report user

Report or block Linell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Linell
Linell / question.rb
Created Sep 4, 2019
Is there a better version of this code?
View question.rb
# Original code. The problem here is that if there's an existing
# Bar object for the user then we end up with two objects. That's
# a valid case though -- we just don't want it here. I want it to
# result in the user having one confirmed Bar object.
foo = Bar.create_or_raise(
user: user,
entity: entity,
status: :confirmed,
role: :owner
)
View temperaturePutTest.json
{
"body": "{\"temperature\":\"72.00\",\"pressure\":\"1234.45\",\"rh\":\"12.34\"}",
"resource": "/{proxy+}",
"requestContext": {
"resourceId": "123456",
"apiId": "1234567890",
"resourcePath": "/{proxy+}",
"httpMethod": "POST",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"accountId": "123456789012",
View .vimrc
filetype plugin on
filetype plugin indent on
syntax on
filetype indent on
set autoindent
set autoread
set backspace=2
set clipboard=unnamed
set cursorline
@Linell
Linell / Procfile
Created Feb 7, 2018
Sidekiq Web UI
View Procfile
web: bundle exec puma -t 4:16 config.ru -p $PORT
worker: bundle exec sidekiq -r ./app.rb
View ImageMagick 6.9.7-3 Homebrew Formula.md

Homebrew Formula patching old ImageMagick release 6.9.7-3

Install

$ brew install https://gist.githubusercontent.com/afaur/15fbb18b28e2140ec3fda8b098262e55/raw/b733366d08da64f87bc889eebf173f4e50e394bc/imagemagick.rb

Tested

View parser.ex
defmodule Mix.Tasks.Parser do
use Mix.Task
require IEx
@shortdoc "A test of the parser."
def run(_args) do
Mix.shell.info "Greetings from the parser"
# The following tree represents a query that looks like:
View thing.sql
-- 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:
@Linell
Linell / euler_one.ex
Created Sep 2, 2015
Project Euler problem on in Elixir.
View euler_one.ex
Enum.filter(1..999, fn(x) -> rem(x, 5) == 0 || rem(x, 3) == 0 end)
|> Enum.reduce(fn(x, acc) -> acc + x end)
# 233168
@Linell
Linell / jose.ex
Created Apr 28, 2015
split a string up into given chunks
View jose.ex
"Jose"
|> String.codepoints()
|> Enum.chunk(2)
|> Enum.map(&Enum.join(&1, ""))
# ["Jo", "se"]
@Linell
Linell / pe_problem_one.ex
Created Apr 27, 2015
Project Euler problem on in Elixir.
View pe_problem_one.ex
# 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
You can’t perform that action at this time.