Skip to content

Instantly share code, notes, and snippets.

View ryanwinchester's full-sized avatar
⚗️
Working on open-source and side projects

Ryan Winchester ryanwinchester

⚗️
Working on open-source and side projects
View GitHub Profile
@ryanwinchester
ryanwinchester / poker.exs
Last active May 15, 2018 21:50
Just having fun...
defmodule Poker do
@deck ~w(
A♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣ 8♣ 9♣ 10♣ J♣ Q♣ K♣
A◆ 2◆ 3◆ 4◆ 5◆ 6◆ 7◆ 8◆ 9◆ 10◆ J◆ Q◆ K◆
A♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠ 8♠ 9♠ 10♠ J♠ Q♠ K♠
A♥ 2♥ 3♥ 4♥ 5♥ 6♥ 7♥ 8♥ 9♥ 10♥ J♥ Q♥ K♥
)
def deck, do: Enum.with_index(@deck)
@ryanwinchester
ryanwinchester / fib.exs
Last active April 3, 2018 20:08
Fibonacci Solution
defmodule Fibonacci do
def fib(0), do: 0
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)
end
@ryanwinchester
ryanwinchester / stop keybase from auto launching.sh
Created February 7, 2018 21:35
Stop keybase from auto launch
keybase uninstall --components service
@ryanwinchester
ryanwinchester / PHP-Guzzle.php
Last active January 19, 2021 00:18 — forked from bkilshaw/gist:3624901
MACVendors.com API :: V1 Code Samples
<?php
// PHP using Guzzle example
use GuzzleHttp\Client;
$client = new Client();
$mac_address = "FC:FB:FB:01:FA:21";

Here’s an example of an list comprehension in Haskell from Wikipedia:

a = [(x,y) | x <- [1..5], y <- [3..5]]
-- [(1,3),(1,4),(1,5),(2,3),(2,4) ...

In this example, a list of pair of integers is constructed from 2 lists of integers.

Here is what that example would be in Python:

@ryanwinchester
ryanwinchester / example.php
Created December 12, 2017 08:04
Is it clean?
<?php
function canView(string $scope, int $owner_id): bool
{
return $scope === 'public' || $this->userCanView(Auth::user(), $owner_id);
}
function userCanView(User $user, int $owner_id): bool
{
return $user->hasRole('admin') || $user->id === $owner_id;
@ryanwinchester
ryanwinchester / _hover_example.py
Created October 4, 2017 19:54 — forked from dankrause/_hover_example.py
Example code to use the (unofficial, unsupported, undocumented) hover.com DNS API.
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)
@ryanwinchester
ryanwinchester / paginator.vue
Last active September 29, 2017 22:22
Vue Paginator Component
<template>
<div class="ui basic segment grid">
<!-- page info -->
<div class="left floated left aligned six wide column">
Displaying results <b>{{pagination.from}}</b> to <b>{{pagination.to}}</b>
on page <b>{{pagination.current_page}}</b> of <b>{{pagination.last_page}}</b>
</div>
<!-- paging -->

Keybase proof

I hereby claim:

  • I am ryanwinchester on github.
  • I am ryanwinchester (https://keybase.io/ryanwinchester) on keybase.
  • I have a public key ASCDTtHOe-VLx_hFRhGVznpVgxf5AkbpRO1pGvUXXFQtsgo

To claim this, I am signing this object:

@ryanwinchester
ryanwinchester / rectangle.ex
Last active June 1, 2017 02:34
Resize with max width or height
defmodule Rectangle do
@doc """
Resize a rectangle using the same logic as similar
triangles to keep the aspect ratio with a max size.
## Algebra
`{300, 400} => {x, 100}`