Skip to content

Instantly share code, notes, and snippets.

View C-Sinclair's full-sized avatar
😎

Conor Sinclair C-Sinclair

😎
View GitHub Profile
@rob-brown
rob-brown / ExecuteSigil.ex
Last active April 11, 2023 08:18
An Elixir sigil for executing terminal commands similar to Ruby.
defmodule ExecuteSigil do
@doc """
Handles the sigil %x. Takes the given command line string, unescapes the necessary
characters and replaces interpolations, executes it, and returns the
results as a string.
## Examples
iex> %x"echo Hello \x45\x6c\x69\x78\x69\x72\x21"
@jhonsore
jhonsore / README.md
Last active November 9, 2022 03:07
[DEPRECATED] Upload an Image from camera or gallery in WebView.

This is an old way to Upload an Image from camera or gallery in WebView. It was made a long time ago and is not maintened anymore. Use it at your own risk.

@akexorcist
akexorcist / index.js
Last active November 17, 2022 11:25
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@sdondley
sdondley / tmux split-window subcommand.md
Last active July 22, 2024 09:11
Super Guide to the split-window tmux Subcommand (and Beyond)

Super Guide to the split-window tmux Subcommand (and Beyond)

Guide overview

tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the

@jc-torresp
jc-torresp / raspberry-pi-plex-server.md
Last active July 12, 2024 16:10
Setup a Raspberry Pi Plex Media Server (Including external storage media and Windows to Raspbian migration)

Raspberry Pi Plex Server

Installation

Ensure our operating system is entirely up to date:

sudo apt-get update
sudo apt-get upgrade
@ryandabler
ryandabler / Arithmetic.ts
Last active December 19, 2023 17:09
Complete example of an arithmetic system built inside TypeScript's type system for this article: https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
// Utility types
type Length<T extends any[]> = T extends { length: infer L } ? L : never;
type BuildTuple<L extends number, T extends any[] = []> =
T extends { length: L }
? T
: BuildTuple<L, [...T, any]>;
type MultiAdd<N extends number, A extends number, I extends number> =
I extends 0
@nikoheikkila
nikoheikkila / README.md
Last active July 27, 2024 20:32
Fish Shell function for sourcing standard .env files

envsource

⚠️ NOTE (20.5.2023): I don't really use this function at all anymore since there are now tools such as Taskfile, which reads the .env file for me sparing me the need to pollute my session with environment variables.


I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

@PJUllrich
PJUllrich / big-o.md
Last active June 28, 2024 20:25
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@mcrumm
mcrumm / component_under_test.ex
Last active July 16, 2024 07:22
Testing Phoenix.LiveComponent in Isolation
# lib/party_web/components/example_component.ex
defmodule PartyWeb.ExampleComponent do
@moduledoc """
An example LiveComponent under test.
"""
use Phoenix.LiveComponent
def render(assigns) do
~H"""
<div>
@zachdaniel
zachdaniel / ash_json_api_example.exs
Created July 11, 2024 11:37
Ash & AshJsonApi Example
Mix.install(
[
{:ash, "~> 3.0"},
{:ash_json_api, "~> 1.0"},
{:plug_cowboy, "~> 2.5"},
{:open_api_spex, "~> 3.16"}
],
consolidate_protocols: false
)