Skip to content

Instantly share code, notes, and snippets.

View vic's full-sized avatar
🤮
puke nuke

Victor Borja vic

🤮
puke nuke
View GitHub Profile
defmodule DefGuard do
defp defguardp(defwith, name, meta = [{:when, _}, {:args, args} | _]) do
meta = meta |> Macro.escape
quote do
@expects {unquote(name), unquote(meta)}
unquote(defwith)(unquote(:"#{name}?")(unquote_splicing(args))) do
values = unquote(args |> Enum.map(fn value = {name, _, nil} -> {name, value} end))
unquote(meta[:when]) |> Macro.prewalk(fn
{name, _, nil} -> Keyword.get(values, name)
@vic
vic / compile.log
Created December 18, 2016 23:02
proof-general warnings on coq-layer installation
Leaving directory ‘/Users/vic/.emacs.d/elpa/proof-general-20161216.202’
Compiling file /Users/vic/.emacs.d/elpa/proof-general-20161216.202/acl2/acl2.el at Sun Dec 18 17:00:39 2016
Entering directory ‘/Users/vic/.emacs.d/elpa/proof-general-20161216.202/acl2/’
Leaving directory ‘/Users/vic/.emacs.d/elpa/proof-general-20161216.202/acl2/’
Compiling file /Users/vic/.emacs.d/elpa/proof-general-20161216.202/ccc/ccc.el at Sun Dec 18 17:00:39 2016
Entering directory ‘/Users/vic/.emacs.d/elpa/proof-general-20161216.202/ccc/’
Leaving directory ‘/Users/vic/.emacs.d/elpa/proof-general-20161216.202/ccc/’
@vic
vic / macro.ex
Created December 15, 2016 09:34
Macro schema objects for absinthe. see https://github.com/absinthe-graphql/absinthe/issues/232
defmodule Absinthe.Schema.Notation.Macro do
defmacro macro_field(name, a, b) do
macro(:field, [name, a, b])
end
defmacro macro_object(name, a) do
macro(:object, [name, a])
end
@vic
vic / README.md
Last active December 9, 2016 21:22
Display elixir exceptions / mix test / credo as iTerm2 notifications.

Open your iTerm2 preferences, then under Profiles / Advanced / Triggers add some regular expressions for the errors you want to notify. On Action select Post Notification, if the regex has group captures, you can use them as parameters.

FunTip: Under Action select Run Command with parameters: say "\1"

ProTip: mix test --listen-on-stdin will re-run tests when you hit enter. Others like to use the mix_test_watch package, but I prefer not to add another dependency.

@vic
vic / ex14parens.rb
Created December 9, 2016 09:13
Add missing parentheses to avoid Elixir 1.4 warnings on function calls.
#!/usr/bin/env ruby
###
# This utility adds missing parentheses to single word function calls
# that are now treated as warnings on Elixir 1.4.
#
# Download this file on your project repo and execute
# ruby ex14parens.rb --help
####
require('fileutils')
@vic
vic / cat
Last active April 30, 2021 03:26
Create an exhibition with bits, due on Thu, Jul 20, 2017 $ cat /bin/cat | xxd --bits
0000000: 11001111 11111010 11101101 11111110 00000111 00000000 ......
0000006: 00000000 00000001 00000011 00000000 00000000 10000000 ......
000000c: 00000010 00000000 00000000 00000000 00010000 00000000 ......
0000012: 00000000 00000000 01010000 00000110 00000000 00000000 ..P...
0000018: 10000101 00000000 00100000 00000000 00000000 00000000 .. ...
000001e: 00000000 00000000 00011001 00000000 00000000 00000000 ......
0000024: 01001000 00000000 00000000 00000000 01011111 01011111 H...__
000002a: 01010000 01000001 01000111 01000101 01011010 01000101 PAGEZE
0000030: 01010010 01001111 00000000 00000000 00000000 00000000 RO....
0000036: 00000000 00000000 00000000 00000000 00000000 00000000 ......
@vic
vic / effect-manager-init.elm
Created May 31, 2016 05:30
empty useless effect manager
effect module My where { command = MyCmd } exposing
( init
)
import Task exposing (Task)
import Platform.Cmd exposing (Cmd)
-- Manager
@vic
vic / example.java
Created September 29, 2015 20:00
Mapping a collection of interfaces
class Target {
List<TargetItem> items;
}
interface TargetItem {}
class TargetItemA implements TargetItem {}
class TargetItemB implements TargetItem {}
class Source {
@vic
vic / InputAutoCfg.ini
Created August 1, 2015 00:45
Wii U Pro for mupen84 using wjoy
[Wiimote (8c-cd-e8-bf-99-de)]
plugged = True
plugin = 2
mouse = False
AnalogDeadzone = 2000,2000
AnalogPeak = 17000,17000
DPad R = button(15)
DPad L = button(13)
@vic
vic / index.html
Created June 2, 2015 19:00
Framework7 router.back bug?
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="bower_components/framework7/dist/css/framework7.css">
<link rel="stylesheet" href="bower_components/framework7/dist/css/framework7.themes.css">
</head>
<body>