Skip to content

Instantly share code, notes, and snippets.

View ocorreiododiogo's full-sized avatar

diogo oliveira ocorreiododiogo

View GitHub Profile
@ocorreiododiogo
ocorreiododiogo / options.html
Last active September 16, 2016 12:04
HTML for "New Tab Page Injector with Bookmarks" Chrome extension options. Creates a blank canvas for writing or pasting content.
<style>
* { box-sizing: border-box }
html {
font-family: sans-serif !important; /* 1 */
line-height: 1.15 !important; /* 2 */
-ms-text-size-adjust: 100% !important; /* 3 */
-webkit-text-size-adjust: 100% !important; /* 3 */

CSS media queries in JS

Here's a small hack to easily reflect CSS media queries in JavaScript. I'm using the css content attribute in HTML and I'm not sure abou nasty consequences of this and if it works on every browser. Consider this Highly alpha.

A Pen by diogo oliveira on CodePen.

License.

@ocorreiododiogo
ocorreiododiogo / pw_buid-form.php
Created November 12, 2013 08:54
For Processwire. Mirror admin forms in the frontend. Works well with regular fields (text, textareas, checkboxes, radios, multiple choice, etc), but didn't manage to make it work well with images
<?php
// Get the page you need to edit
$mypage = $pages->get('/some/page/');
// Populate with the names of the fields you want to exclude OR include (see instructions below)
// Leave empty to output all the fields
$myfields = array('body', 'email');
$form = $modules->get('InputfieldForm');
$fields = $mypage->getInputfields();
@ocorreiododiogo
ocorreiododiogo / allternativeLoopPW.php
Last active December 27, 2015 12:09
Loop pages in ProcessWire without building a $pageArray. This is useful for when a find() would return too many results to keep in memory.
$selector = "template=pages_template"; // as an example
while (1) {
$p = wire('pages')->get("{$selector}, id>$id"); // get page with id bigger than previous
if(!$id = $p->id) break; // assign current page's id to $id or break the loop if it doesn't exist
// do stuff using $p as the current page
wire('pages')->uncacheAll(); // clean the memory (with $p->uncache() doesn't work. why?)
};
@ocorreiododiogo
ocorreiododiogo / pw_delete_templates
Last active December 21, 2015 15:39
Quick interface to batch delete template in ProcessWire
<?php
if ($input->post->submit) {
foreach ($input->post as $t) {
// proceed only if the input is an integer different from 0
if (!(int)$t) return;
$t = $templates->get($t);
$templates->delete($t);
$name = $t->name;
// delete the fieldgroup associated with this template. more info in the next post