Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shipping it

Moritz Schmale narrowtux

:shipit:
Shipping it
View GitHub Profile
View polymorphic_embed.ex
defmodule PolymorphicEmbed do
@moduledoc """
Allows you to embed with an unknown schema at compile time.
The schema is decided by a `type_field` which could be an elixir module,
but also an enum which can be converted into a module with an `embedded_schema`.
"""
use Ecto.Type
View userconfig.cfg
violence_hblood 6
violence_hgibs 6
violence_ablood 6
violence_agibs 6
hud_fastswitch "1"
bind "F1" "vesthelm; defuser"
bind "F2" "ak47; m4a1"
bind "F3" "galil; famas"
bind "F4" "sg552; aug"
View xgettext-loader.js
let child = require("child_process")
let source_map = require("source-map")
let SourceMapConsumer = source_map.SourceMapConsumer
let path = require("path")
var crypto = require('crypto');
module.exports = function(source, sourceMap) {
this.cacheable()
this.async()
var self = this
View gist:19220fc077ecbaeb274c56e8497f8e61
*smoothScroll.js*
*smooth*.js*
*nicescroll*js*
*jquery.mousewheel.js*
*plugins-scroll.js*
https://d33wubrfki0l68.cloudfront.net/bundles/85ee573a175fbccec4ed26bf47ede7fd06c1d248.js
@narrowtux
narrowtux / repo_stream.ex
Created Oct 9, 2017
Module for Ecto and GenStage to work together when you want to use Repo.stream in conjunction with a GenStage subscriber or a Flow.
View repo_stream.ex
defmodule RepoStream do
defmodule Producer do
use GenStage
defstruct [:demand, :pid]
def start_link() do
GenStage.start_link(__MODULE__, self())
end
@narrowtux
narrowtux / libcluster_rabbit.ex
Created Sep 20, 2017
RabbitMQ strategy for libcluster
View libcluster_rabbit.ex
defmodule Cluster.RabbitStrategy do
use GenServer
use Cluster.Strategy
import Cluster.Logger
alias Cluster.Strategy.State
@routing_key "cluster.heartbeat"
def start_link(opts) do
View swarm_dynamic_supervisor.ex
defmodule Swarm.DynamicSupervisor do
use GenServer
require Logger
defstruct [
:child_name,
:child_module,
:child_args,
:group,
:pid,
@narrowtux
narrowtux / wifi_sleep.lua
Last active Aug 14, 2017
Remedy for a sleep problem my MacBook Pro late 2016 has.
View wifi_sleep.lua
displaySleep = false -- Need better way to determine initial state of this variable. But it should be the truth most of the time.
systemSleep = false
function handleCaffeinateUpdates()
wifiPower = hs.wifi.interfaceDetails().power
if displaySleep and systemSleep and wifiPower then
print("Disabling WiFi before going to sleep")
hs.wifi.setPower(false)
elseif not displaySleep and not systemSleep and not wifiPower then
print("Woke up - enabling wifi")
View lol.ex
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation]
query = from outer in __MODULE__,
join: t in fragment("""
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS (
?
UNION ALL
SELECT
o.organization_id,
View lol.ex
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation]
query = from outer in __MODULE__,
join: t in fragment("""
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS (
?
UNION ALL
SELECT
o.organization_id,
You can’t perform that action at this time.