Skip to content

Instantly share code, notes, and snippets.

Keith ktec

Block or report user

Report or block ktec

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
@ktec
ktec / README.md
Created Feb 19, 2019
Elixir Test Runner - Test Driven Development with Entr
View README.md
@ktec
ktec / README
Last active May 16, 2018
Script to control keyboard led lights for Macbook Pro on Arch Linux
View README
Controlling the keyboard led lights on a Macbook Pro running linux is harder than it should be.
For ...reasons the bundled `kbdlight` doesn't work, so we're left with no option but to roll
up our sleaves and get our hands dirty. Fortunately various bash commands and `bc` makes this
task pretty trivial so here is a script to control the brightness.
This script supports the following api:
$ kbdlight -set 10
$ kbdlight -set +10
@ktec
ktec / README
Last active Apr 3, 2018
Script to control the screen brightness (Backlight) for Linux
View README
Controlling the screen brightness on a Macbook Pro running linux is harder than it should be.
For ...reasons the bundled `xbacklight` doesn't work, so we're left with no option but to roll
up our sleaves and get our hands dirty. Fortunately various bash commands and `bc` makes this
task pretty trivial so here is a script to control the brightness.
This script supports the following api:
$ brightness -set 10
$ brightness -set +10
@ktec
ktec / App.js
Last active Mar 29, 2019
HOW TO USE PHOENIX WITH WEBPACK + REACT + REDUX - This is a collection of small changes related to: https://www.dailydrip.com/blog/how-to-use-phoenix-with-webpack-react-redux.html
View App.js
import React, { Component } from "react";
import { connect } from "react-redux";
import MessageList from "../components/MessageList";
import MessageInput from "../components/MessageInput";
import Actions from "../actions";
function App(props) {
const { messages, sendMessage } = props;
return (
@ktec
ktec / application.ex
Last active Oct 16, 2017
Example MasterProxy for Elixir Umbrella applications supporting websockets
View application.ex
defmodule MasterProxy.Application do
@moduledoc """
Custom Cowboy specification to support hosting multiple Phoenix apps within the same umbrella,
all served via the same port. This is only really necessary if you're deploying your umbrella
to a restricted hosting environment like Heroku where they only expose 1 port per dyno.
Don't for get to configure your endpoints, something like this should work:
config :myapp_web, MyAppWeb.Endpoint,
url: [scheme: "https", host: "myapp.herokuapp.com", port: 443],
View pyramid_calculator.ex
defmodule PyramidCalculator do
@doc """
iex> PyramidCalculator.pyramid_prices_percents([1, 2, 3], 10)
[10.0, 33.33333333333333, 56.666666666666664]
iex> PyramidCalculator.pyramid_prices_percents([1, 2, 3], 40)
[40.0, 33.333333333333336, 26.666666666666668]
iex> PyramidCalculator.pyramid_prices_percents([1, 3, 7, 22], 5)
[5.0, 10.517241379310345, 21.551724137931036, 62.93103448275862]
"""
View sumFolds.js
// const Box = x =>
// ({
// map: f => Box(f(x)),
// fold: f => f(x),
// inspect: () => `Box(${x})`
// })
const fmap = f => xs => xs.map(x => f(x))
@ktec
ktec / ssl_puma.sh
Created Jan 17, 2017 — forked from tadast/ssl_puma.sh
localhost SSL with puma
View ssl_puma.sh
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
View heroku_env_copy.sh
#!/usr/bin/env bash
# Original Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
## Usage: heroku_env_copy [options] SOURCE TARGET
##
## NOTE: This script will only output the command, you should run it yourself.
##
## Options:
## -h, --help Display this message.
##
@ktec
ktec / arel_cast_datetime_as_as.rb
Last active Jun 27, 2016
When you want to filter by date, but you've only got a datetime property, this will help you cast your datetime
View arel_cast_datetime_as_as.rb
# frozen_string_literal: true
class Things < ApplicationRecord
scope :filter_after_date, -> (date) {
where(created_at_as_date.gteq(date))
}
scope :filter_before_date, -> (date) {
where(created_at_as_date.lteq(date))
}
def self.created_at_as_date
Arel::Nodes::NamedFunction.new "DATE", [ arel_table[:created_at] ]
You can’t perform that action at this time.