Skip to content

Instantly share code, notes, and snippets.

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

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
View abTest.js
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 Dec 5, 2017
Rule 30 using Elixir streams
View rule30.exs
# 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)
View recursive_discriminators.js
const Schema = require("mongoose").Schema;
const mongoose = require("mongoose");
const checkSchema = new Schema(
{},
{
discriminatorKey: "type",
_id: false
}
);
@pcorey
pcorey / fourths.exs
Created Aug 15, 2018
Diatonic fourths in C using the Chord project. https://github.com/pcorey/chord/
View fourths.exs
# 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]
View clappingMusic.tidal
-- 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 Jun 24, 2020
katrain in iTerm2 with debug_level set to 2
View gist:831a194b7e83418404b4169ee7392098
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>
@pcorey
pcorey / .spacemacs
Created Sep 10, 2018
My .spacemacs config file
View .spacemacs
;; -*- 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
You can’t perform that action at this time.