Skip to content

Instantly share code, notes, and snippets.

View haskellcamargo's full-sized avatar
🪲
Everything is terrible

Marcelo Camargo haskellcamargo

🪲
Everything is terrible
View GitHub Profile
(ns pattern.core)
(defn translate [x y]
(str "translate(" x "," y ")"))
(def pack
(.. js/d3
-layout
pack
(size (array (- diameter 4) (- diameter 4)))
@haskellcamargo
haskellcamargo / vimrc.vim
Created August 24, 2015 14:15
My vim settings
syntax on
set tabstop=2
set guifont=consolas
set number
colorscheme material
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
@haskellcamargo
haskellcamargo / maxDepth.js
Last active August 29, 2015 14:28
Max depth of tree
Array.prototype.ifNotEmpty = function(fn, otherwise) {
return this.length !== 0
? fn.call(this)
: otherwise;
};
function maxDepth(struct) {
return struct.children && Array.isArray(struct.children)
? struct.children
.map(function(child) {
@haskellcamargo
haskellcamargo / SQLSelectGrammar.pegjs
Created August 26, 2015 14:19
SQL Select Grammar
/**
* Grammar for validating simple SQL selects.
* @author Marcelo Camargo
* @since 2015/08/26
*/
{
var Sql = {
listToString: function(x, xs) {
return [x].concat(xs).join("");
@haskellcamargo
haskellcamargo / SweetEnum.sjs
Last active September 18, 2015 12:21
Sweet.js enum implementation
let (<@>)
= macro {
case { _ $name:ident } => {
letstx $str = [makeValue(unwrapSyntax(#{$name}), #{here})];
return #{$str};
}
}
macro enum {
case {
@haskellcamargo
haskellcamargo / integer.lex
Created October 5, 2015 11:19
PHP_Integer
%{
/**
* Lexical grammar for matching PHP integers
* @author Marcelo Camargof
*/
#include <math.h>
#include <stdlib.h>
%}
{
"type": "Program",
"value": [
{
"type": "Expr",
"value": {
"type": "LetExpr",
"typedef": {
"type": "TypeDef",
"class": "PrimitiveType",
/**
* Grammar for (T)emplate (Q)uery (L)anguage
* @author Marcelo Camargo
* @since 2015/10/08
*/
{
var TypeChecker = {
assert: function(t1, t2) {
if (t1 !== t2) {
throw new TypeError("Type [" + t2 + "] is not assignable to [" + t1 + "]");
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
<?php
// Build a function which can double a list
$double_list = partial 'array_map' on (function($x) { return $x * 2; });
$double_list([1, 2, 3, 4, 5]); // [2, 4, 6, 8, 10]