Skip to content

Instantly share code, notes, and snippets.

@omerida
omerida / Puzzles-2023-02.tsv
Created January 10, 2023 04:48
Tab separated values for Puzzle Corner, Febraury 2023
Student # Grade 1 Grade 2 Grade 3 Grade 4 Grade 5 Grade 6
222301 86 76 70 86 90 79
222302 85 90 81 91 90 95
222303 93 80 86 80 81 85
222304 80 93 77 93 82 84
222305 92 84 86 86 88 75
222306 69 86 85 80 86 98
222307 102 99 86 99 88 94
222308 73 74 95 88 70 87
222309 80 78 85 82 79 82
@omerida
omerida / text-to-rolltable.js
Created October 18, 2022 15:33
Foundry Macro: Text to RollTable Ma
function makeTable(tableName, inputRows) {
let rows = inputRows.split(/\r?\n/);
// prepare table rows
let results = rows.map((row, count) => {
return {
text: row.trim(),
type: CONST.TABLE_RESULT_TYPES.TEXT,
weight: 1,
range: [count + 1, count + 1],
@omerida
omerida / oauth-gist.txt
Last active December 30, 2015 04:27
Updated Text
This is completely new text, right?
@omerida
omerida / om_exporter.drush.inc
Last active October 14, 2015 16:49
Export Drupal Nodes to CSV with EntityFieldQuery and PHP 5
<?php
function om_exporter_drush_command() {
$items['export-newest'] = array(
'description' => 'Export Newest Content to CSV',
'aliases' => ['ex-new'],
'callback' => 'om_export_newest',
'arguments' => [
'date' => '',
]
@omerida
omerida / drupal-migrate-helpers.php
Last active August 29, 2015 14:27
Helper functions for rewrting images in body fields from remote to local
<?php
/**
* Updates remote image tags to work locally.
*
* @param $node
*/
function _rewrite_images($body)
{
// quick test before we commit to DOM processing
// must have images from our old
@omerida
omerida / gist:7f7fae2f9273d26898d1
Created June 6, 2014 17:55
Drupal hooks for finding orphaned nodes
<?php
/**
* Implements hook_menu()
*/
function node_orphaned_menu() {
$items['admin/content/node-orphaned'] = array(
'page callback' => 'node_orphaned_list',
'title' => 'Orphaned Pages',
'access arguments' => 'administer nodes',
'type' => MENU_LOCAL_TASK,
@omerida
omerida / draw.php
Last active December 30, 2015 03:59
Simplified World Cup draw simulator
<?php
/*
* World Cup Draw Example.
*
* Using Array functions & SPL Iterators to simulate (simplified) World Cup draws.
*
* @author Oscar Merida <oscar@phparch.com>
*/
// teams organized by pot, 8 in each.
@omerida
omerida / gist:2251728
Created March 30, 2012 13:59
Mysql find and update duplicate fields before creating a unique index
# create temp table
CREATE TEMPORARY TABLE link_dupes (
`id` int(11) unsigned NOT NULL,
`user_id` int(11) unsigned NOT NULL,
`link` varchar(1000) NOT NULL,
`link_unique` varchar(1000) NOT NULL
);
# find rows with duplicate link fields, into temp table
# add a hash to the url so that it still works
@omerida
omerida / gist:2237704
Created March 29, 2012 13:58
jquery: Toggle another element without .toggle
// something we can click
$button = $('.some-button');
// the container we want to show and hide
$dialog = $('#dialog');
// bind click to open & close
$button.click(function(event) {
if ($dialog.is(':visible')) {
// could use another effect or do any shutdown work here