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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
function base64ImageUploader(dialog) { | |
var reader, image_url, img; | |
var canvas = document.createElement("canvas"); | |
var canvas_context = canvas.getContext('2d'); | |
function rotateImage(direction){ | |
//These are swapped when rotating |
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
defmodule ZigZagConversion do | |
@moduledoc """ | |
Qqwy's solution to https://leetcode.com/problems/zigzag-conversion/ | |
""" | |
@doc """ | |
Converts a string into a zig-zagged string: | |
- the characters of string is distributed over `num_rows`, as follows: |
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
# See https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L52 | |
# for the list of operators with associativity, etc. | |
# The operators in this list are grouped by precedence, low to high. | |
# The comments indicate the operator's normal function, as well as its ability to be defined/overridden. | |
-> # CompileError 'unhandled operator'. only allowed in anonymous function syntax. | |
& # CompileError, only allowed in short anonymous function syntax. |
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
defmodule Modulo do | |
defmacro guard_safe_int_max(a, b) do | |
quote do | |
div(unquote(a)+unquote(b) + abs(unquote(a) - unquote(b)), 2) | |
end | |
end | |
defmacro int_sign(x) do | |
quote do |
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
/* | |
In this snippet, the failure cases are not close to the conditions they belong to. | |
This makes it hard to track when which error case is triggered (especially when they are more than a screen height apart). | |
It also adds a lot of `{}` and indentation. | |
*/ | |
int someFunction(int foo, int bar, int baz) | |
{ | |
if (foo == 1) | |
{ |
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
defmodule Scream do | |
defmacro scream!(ast) do | |
{exclams, res} = count_exclams(ast, 0) | |
case exclams do | |
_ when exclams < 5 -> | |
quote do "You say: #{inspect(unquote(res))}." end | |
_ when exclams < 10 -> | |
quote do "You yell: #{inspect(unquote(res))}!" end | |
_ when exclams < 15 -> | |
quote do "You scream: #{inspect(unquote(res))}!!" 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
{-#OPTIONS_GHC -O2 -optc-O3 #-} | |
{- | |
Author: Wiebe-Marten Wijnja | |
Date: 2018-02-12 | |
This simple program is a Prime Checker. | |
It is special, in that does not perform any | |
division or modulo operations to check if a number is a prime, | |
which most prime checkers or prime sieves do. |
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
defmodule YCombinator do | |
@moduledoc """ | |
Some functions explaining the Y-Combinator. | |
Can definitely be improved upon, but this is as much as time allowed me this evening. | |
""" | |
def factorial(n) do | |
y_combinator(&almost_factorial/1).(n) |
OlderNewer