Skip to content

Instantly share code, notes, and snippets.

@pcorey
pcorey / categories.js
Last active August 29, 2015 14:15
Editable Categories in Meteor's Orion
orion.dictionary.addDefinition('categories', 'basic', {
type: [String],
label: 'Categories'
});
orion.addEntity('articles', {
title: {
type: String,
label: 'Title'
},
orion.addEntity('categories', {
category: {
type: String,
label: 'Category',
optional: false
},
attributes: {
type: [String],
label: 'Attributes',
optional: true
@pcorey
pcorey / README.md
Last active November 20, 2015 00:50

Is there any version of input that can be used to run arbitrary code in the vm context?

The unicode line and paragraph separators (\u2028 and \u2029) can be used to break the VM interpreter, but as far as I know, it's not possible to exploit this to run arbitrary code:

evalmachine.<anonymous>:1
var test = "foo
           ^^^^

SyntaxError: Unexpected token ILLEGAL
@pcorey
pcorey / abTest.js
Last active January 24, 2016 14:47
var groups = [
{
query: {group: "A", createdAt: {$gte: ISODate("2016-01-01 05:00:00.000Z")}}
},
{
query: {group: "B", createdAt: {$gte: ISODate("2016-01-01 05:00:00.000Z")}}
}
];
groups.map(function(group, index) {
@pcorey
pcorey / rule30.exs
Last active December 5, 2017 20:39
Rule 30 using Elixir streams
# https://en.wikipedia.org/wiki/Rule_30
defmodule Rule30 do
def stream(values) do
Stream.resource(fn -> {values, 0} end, &next_fun/1, fn _ -> :ok end)
end
defp next_fun({values, layer}) do
next = ([0, 0] ++ values ++ [0, 0])
|> Enum.chunk_every(3, 1, :discard)
const Schema = require("mongoose").Schema;
const mongoose = require("mongoose");
const checkSchema = new Schema(
{},
{
discriminatorKey: "type",
_id: false
}
);
@pcorey
pcorey / fourths.exs
Created August 15, 2018 23:29
Diatonic fourths in C using the Chord project. https://github.com/pcorey/chord/
# 0 1 2 3 4 5 6 7 8 9 10 11
# C D E F G A B
f_maj7 = [5, 9, 0, 4]
b_m7b5 = [11, 2, 5, 9]
e_m7 = [4, 7, 11, 2]
a_m7 = [9, 0, 4, 7]
d_m7 = [2, 5, 9, 0]
g_7 = [7, 11, 2, 5]
c_maj7 = [0, 4, 7, 11]
-- https://en.wikipedia.org/wiki/Clapping_Music
do {
resetCycles;
d1 $ seqP [
(
0,
13 * 4,
n "0 0 0 ~ 0 0 ~ 0 ~ 0 0 ~"
# pan (range 0.2 0.25 perlin)
@pcorey
pcorey / gist:831a194b7e83418404b4169ee7392098
Created June 24, 2020 21:08
katrain in iTerm2 with debug_level set to 2
This file has been truncated, but you can view the full file.
[WARNING] [Deprecated ] Pygame has been deprecated and will be removed after 1.11.0: Call to deprecated function __init__ in /usr/local/lib/python3.7/site-packages/kivy/core/window/window_pygame.py line 42.Called from /usr/local/lib/python3.7/site-packages/kivy/core/__init__.py line 70 by core_select_lib().
[TRACE ] [Lang ] Found 2 rules for <Screen name=''>
[TRACE ] [Lang ] Found 0 rules for <kivymd.uix.navigationdrawer.NavigationLayout object at 0x1139ff2d0>
[TRACE ] [Lang ] Found 1 rules for <kivy.uix.screenmanager.ScreenManager object at 0x1139ff350>
[TRACE ] [Lang ] Found 1 rules for <Screen name=''>
[TRACE ] [Lang ] Found 2 rules for <katrain.gui.kivyutils.BGBoxLayout object at 0x1139ffa50>
[TRACE ] [Lang ] Found 1 rules for <kivymd.uix.boxlayout.MDBoxLayout object at 0x1139ffd50>
[TRACE ] [Parser ] parsing 5 lines
[TRACE ] [Lang ] Found 0 rules for <kivy.uix.gridlayout.GridLayout object at 0x113a3d350>
[TRACE ] [Lang ] Found 3 rules
@pcorey
pcorey / .spacemacs
Created September 10, 2018 14:32
My .spacemacs config file
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory