This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reload/recompile code before each request in development only using Plug & Mix. | |
# Assumes MyApp.Router is a plug that handles actual routing. | |
def MyApp.Main do | |
use Plug.Builder | |
plug :reload | |
plug :dispatch | |
def reload(conn, _opts) do | |
if Mix.env == :dev, do: Mix.Tasks.Compile.Elixir.run(["--ignore-module-conflict"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl; | |
server_name xxx.xx.io | |
ssl on; | |
ssl_certificate /etc/asterisk/certs/xxx.io.pem; | |
ssl_certificate_key /etc/asterisk/certs/xxx.io.key; | |
ssl_session_timeout 5m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// Load plugins | |
const autoprefixer = require("autoprefixer"); | |
const browsersync = require("browser-sync").create(); | |
const cp = require("child_process"); | |
const cssnano = require("cssnano"); | |
const del = require("del"); | |
const eslint = require("gulp-eslint"); | |
const gulp = require("gulp"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env elixir | |
defmodule Canvas do | |
@behaviour :wx_object | |
@title "Canvas Example" | |
@size {600, 600} | |
def start_link() do | |
:wx_object.start_link(__MODULE__, [], []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern mod extra; | |
use extra::json::*; | |
/* | |
* This function manages to do absolutely no copying, which is pretty cool. | |
* | |
* "What are all those `'r`s?" you ask. Well, they're liftime parameters. They | |
* indicate how long something lasts (before it's freed). They can't change how | |
* long something lives for, they only allow you to tell the compiler stuff it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Option 1 | |
# Imagine that the implementations of these three functions span ~100 LOC each, including | |
# private functions | |
defmodule Users do | |
def create(params) do | |
# this and all private functions for this are like 100 LOC | |
end | |
def update(user, params) do | |
# this and all private functions for this are like 100 LOC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace main; | |
define("BACKEND_SOCKET", '<where the unix socket>'); | |
define("BASE_URL", '<where this file located>'); | |
function exit_500($msg) { | |
$msg = rtrim($msg, "\n") . "\nDebug trace:\n"; | |
foreach(debug_backtrace() as $trace) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@doc""" | |
Returns a map containing all files and their contents from the compressed tar archive. | |
""" | |
def extract_tar_from_binary(binary) do | |
with {:ok, files} <- :erl_tar.extract({:binary, binary}, [:memory, :compressed]) do | |
files | |
|> Enum.map(fn {filename, content} -> {to_string(filename), content} end) | |
|> Map.new | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here is an extremely simple version of work scheduling for multiple | |
// processors. | |
// | |
// The Problem: | |
// We have a lot of numbers that need to be math'ed. Doing this on one | |
// CPU core is slow. We have 4 CPU cores. We would thus like to use those | |
// cores to do math, because it will be a little less slow (ideally | |
// 4 times faster actually). | |
// | |
// The Solution: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="canvas"></div> | |
<style> | |
#canvas { | |
width: 500px; | |
height: 300px; | |
border: 5px solid black; | |
position: relative; | |
box-sizing: content-box; | |
} |
OlderNewer