Skip to content

Instantly share code, notes, and snippets.

View bratsche's full-sized avatar

Cody Russell bratsche

  • Atlanta, GA
View GitHub Profile
@bratsche
bratsche / notes.txt
Created December 11, 2023 16:25
Notes for why I think Elixir is worth using
Notes on why I think Elixir is worth using for us
* Phoenix Channels - able to support 2 million concurrent clients on a single server.
* Node.js has an equivalent feature called SocketIO
* Ruby on Rails has an equivalent feature called ActionCable
* Not aware of any similar feature in Python
* Concurrency
* Ruby, restricted by a GIL
* Python, restricted by a GIL, but there is a proposal to remove it. Not sure how long it will take to remove it.
* Node.js, single-threaded async
@bratsche
bratsche / index.ex
Last active August 23, 2023 16:42
Phoenix LiveView 0.17 table
defmodule ExperimentsWeb.ComposerLive.Index do
use ExperimentsWeb, :live_view
import ExperimentsWeb.ComposerLive.Table
alias Experiments.Composers
alias Experiments.Composers.Composer
@impl true
def mount(_params, _session, socket) do

Keybase proof

I hereby claim:

  • I am bratsche on github.
  • I am bratsche (https://keybase.io/bratsche) on keybase.
  • I have a public key ASB1iVAvshnnFu_8fyzVI-1OBhcehQUwyy_ScHu7enY-TAo

To claim this, I am signing this object:

@bratsche
bratsche / git-ls-changes.sh
Last active December 15, 2016 16:11
Differentiate between modified and unmodified files
git ls-files | while read -r line; do
s=$(git status -s "$line");
if [ -n "$s" ]; then
echo "$s";
else
echo " $line";
fi;
done
defmodule Foo.SessionController do
use Foo.Web, :controller
def create(conn, %{"session" => session_params}) do
case Foo.Session.authenticate(session_params) do
{:ok, user} ->
{:ok, jwt, _full_claims} = Guardian.encode_and_sign(user, :token)
conn
|> put_status(:created)
@bratsche
bratsche / Main.elm
Last active March 22, 2016 01:31
Restricted access with elm-transit-router
module Main (..) where
import Effects exposing (Effects, Never, none)
import Json.Decode as Json
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
import StartApp
import Signal exposing (Address)
public void SetSortFunc(int sort_column_id, Gtk.TreeIterCompareFunc sort_func) {
GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func);
IntPtr user_data;
GLib.DestroyNotify destroy;
if (sort_func == null) {
user_data = IntPtr.Zero;
destroy = null;
} else {
user_data = (IntPtr) GCHandle.Alloc (sort_func_wrapper);
destroy = GLib.DestroyHelper.NotifyHandler;
@bratsche
bratsche / gist:ea3085141b35579f1fd5
Created January 18, 2016 20:13
Example custom mix task to seed the database using an existing seed file
# lib/mix/tasks/musikr.seed.ex
defmodule Mix.Tasks.Musikr.Seed do
use Mix.Task
@shortdoc "Seeds the database"
@moduledoc """
Seed the database using the file 'priv/repo/seeds.exs'
"""
@bratsche
bratsche / cairo-win32-font-device-scale.diff
Created December 4, 2015 20:16
Cairo Win32 font changes for device scale
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -379,6 +379,8 @@ _win32_scaled_font_create (LOGFONTW *logfont,
/* don't delete the hfont if we're using the one passed in to us */
f->delete_scaled_hfont = !f->scaled_hfont;
+ cairo_matrix_scale (font_matrix, 1.0 / device_scale, 1.0 / device_scale);
+ cairo_matrix_scale (ctm, device_scale, device_scale);
cairo_matrix_multiply (&scale, font_matrix, ctm);
status = _compute_transform (f, &scale);
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <stdio.h>
/* Don't get link errors because mkdir is redefined to rpl_mkdir. */
#undef mkdir