Skip to content

Instantly share code, notes, and snippets.

View cotto's full-sized avatar

Charis Otto cotto

  • Seattle
  • 03:05 (UTC -07:00)
View GitHub Profile
@cotto
cotto / gist:2706294
Created May 16, 2012 00:32
drupal login bookmarklet
javascript:%20document.body.appendChild(document.createElement('div')).innerHTML%20=%20'<form%20name="BletForm"%20method="POST"%20action="/user/login"><input%20type="hidden"%20name="name"%20value="USERNAME"%20/><input%20type="hidden"%20name="pass"%20value="PASSWORD"%20/><input%20type="hidden"%20name="form_build_id"%20value="form-52be703245d558e8993650a4115cb9ba"%20/><input%20type="hidden"%20name="form_id"%20value="user_login"%20/><input%20type="hidden"%20name="op"%20value="Log%20in"%20/></form>';document.forms['BletForm'].submit();
@cotto
cotto / regname_test.m0
Created May 5, 2012 03:25
now with named registers
.version 0
.chunk "noop"
.constants
0 "1..1\n"
1 "n"
2 "ok 1 or: 9 or 90 = 91\n"
.metadata
.bytecode
.regname ponies = S0
@cotto
cotto / questions.txt
Created May 2, 2012 22:52
m0 memory questions
per-callframe constants segment layout:
constants segment starts with a list of fixed-width pointers. I/N entries are stored directly. S/P entries are pointers to later in the constants segment
The data segment has a couple options. It can be appended after the constants segment (either on the next page or immediately after), with the constants data being marked read-only. Alternately, it can just be another segment attached to a special register.
If callframes are analogous to subs, the constants and data segment can be analogous to lexical data.
If callframes are analogous to subs, how will recursion work?
* clone a callframe (when? before entering ( -> no state) or after entering (less waste, leftover state))
* need to work out calling conventions
@cotto
cotto / gist:2522193
Created April 28, 2012 21:31
4/29/12 M0 todo
add tests for the special registers
implement special registers in cm0
@cotto
cotto / pact-gsoc.mkd
Created April 27, 2012 08:02
PACT gsoc propsal

Project Description

There are three main portions to this project: a library to represent Parrot bytecode (PBC) as a set of classes and compile them to a file, an assembly language that uses that library, and a disassembler that produces the new assembly language. The assembler and disassembler act as proof of concepts for the library, but should be useful tools instead of just toys.

The library should have classes that represent a packfile, subs, and instructions (opcode and arguments). These classes should be used as the model that the library can convert to and from normal PBC files. This provides a far more friendly interface than the standard Packfile PMCs.

The assembly language is intended to be a simple textual representation of bytecode. It mirrors the multiple segments of the packfile itself: a PMC constant section, a float constant section, then a bytecode section. The bytecode section will contain sub markers and labels so that programmers don't have to determine opcode counts themselves. In all

@cotto
cotto / login_example.php
Created April 13, 2012 21:51
services login example
<?php
// Login
$login_data = array(
'username' => 'USER',
'password' => 'PASSWORD',
);
$base_url = "http://your-awesome-site.com/api";
$req = new HttpRequest("$base_url/user/login.json", HttpRequest::METH_POST);
@cotto
cotto / PONIES.txt
Created March 25, 2012 08:32
startup reading list
categories (order of importance):
what can I expect, being part of a startup?
Is it the kind of life I'll be satisfied with?
what kills startups and what are the early warning signs?
How many of them do we have? How many are curable?
How does a culture form, what's good and what's bad?
how are my personality flaws going to be amplified into culture? how to avoid this?
@cotto
cotto / services.patch
Created January 16, 2012 22:35
allow escaped commans in services requests
diff --git a/sites/all/modules/services/services.module b/sites/all/modules/services/services.module
index 7f49837..97ba65a 100644
--- a/sites/all/modules/services/services.module
+++ b/sites/all/modules/services/services.module
@@ -476,9 +476,11 @@ function services_resource_build_index_query($schema, $order, $page, $fields, $s
if (is_array($service_params)) {
foreach ($service_params as $param_field => $param_value) {
$in_placeholders = array();
- foreach (explode(',', $param_value) as $single_value) {
+ // Split on unescaped commas.
@cotto
cotto / server_settings_cleanup.patch
Created November 22, 2011 23:47
clean up endpoint server settings
diff --git a/plugins/export_ui/services_ctools_export_ui.class.php b/plugins/export_ui/services_ctools_export_ui.class.php
index 45ddf2f..00b04b2 100644
--- a/plugins/export_ui/services_ctools_export_ui.class.php
+++ b/plugins/export_ui/services_ctools_export_ui.class.php
@@ -150,7 +150,7 @@ function services_edit_form_endpoint_server($form, &$form_state) {
else {
$definition = $server['settings'];
- $settings = isset($endpoint->server_settings[$endpoint->server]) ? $endpoint->server_settings[$endpoint->server] : array();
+ $settings = isset($endpoint->server_settings) ? $endpoint->server_settings : array();
@cotto
cotto / services-multivalue-index.patch
Created November 15, 2011 00:02
support multiple comma-separated values in index methods
diff --git a/services.module b/services.module
index d620a2a..02b3b98 100644
--- a/services.module
+++ b/services.module
@@ -441,15 +441,16 @@ function _services_resource_controller_as_procedure($resource, $name, $controlle
* Integer page number we are requesting.
* @param $fields
* Array fields to return.
- * @param $parameter
+ * @param $service_parameters