Skip to content

Instantly share code, notes, and snippets.

View Naatan's full-sized avatar

Nathan Rijksen Naatan

View GitHub Profile
@Naatan
Naatan / gist:9231532
Created February 26, 2014 15:25
Komodo IDE - Open Files Pattern for DocPad
ko.openfiles.groupers.byPattern.patterns = [
{
name: 'Databases',
pattern: /\/databases(?:\/|$)/i
},
{
name: 'Scripts',
pattern: /\/scripts(?:\/|$)/i
},
{
@Naatan
Naatan / gist:9231578
Created February 26, 2014 15:26
Komodo IDE - Open Files Pattern for Komodo Development
ko.openfiles.groupers.byPattern.patterns = [
{
name: 'Plat - %match% - config',
pattern: /\/skin\/plat\/([a-z0-9_-]*)\/_config\//i
},
{
name: 'Plat - %match%',
pattern: /\/skin\/plat\/([a-z0-9_-]*)\//i
},
{
@Naatan
Naatan / auto-braces.js
Created May 7, 2014 17:39
Komodo IDE - Auto Braces
/**
* @fileoverview Auto completes curly braces to start on a new line - experimental
* @author Nathan Rijksen
* @version 0.1
*/
/**
* Komodo Extensions Namespace.
* This namespace was suggested by JeffG. More information is available at:
* {@link http://community.activestate.com/forum-topic/extension-s-namespace}
@Naatan
Naatan / Select_Brace_Contents.js
Created June 2, 2014 16:54
Select Brace Contents
(function() {
var sm = ko.views.manager.currentView.scimoz;
function selBraceContents()
{
ko.commands.doCommand('cmd_selectToMatchingBrace');
var selText = sm.selText;
@Naatan
Naatan / vertical-tabs.js
Created June 18, 2014 15:47
Old Komodo Vertical Tabs Macro
var view = ko.views.manager.currentView;
var tabbox = view.parentNode;
while (tabbox && tabbox.nodeName != "tabbox" && tabbox.nodeName != "xul:tabbox") {
tabbox = tabbox.parentNode;
}
// Vertical tabs
tabbox.setAttribute("orient", "horizontal");
tabbox.setAttribute("dir", "reverse");
tabbox.tabs.setAttribute("orient", "vertical");
@Naatan
Naatan / SCC - Open on GitHub.js
Last active August 29, 2015 14:14
Komodo Macro - Open current file location on github
var notify = require("notify/notify");
var editor = require("ko/editor");
/* Quickly thrown together, only supports Komodo 9 and GitHub */
var koDoc = ko.views.manager.currentView.koDoc;
if ( ! koDoc || ! koDoc.file) return;
var uri = koDoc.file.URI;
var sccSvc = ko.scc.getServiceForUrl(uri);
@Naatan
Naatan / highlightword.js
Created March 6, 2015 15:54
Komodo Macro: Quick Find / Highlight
/**
* Original macro: http://community.activestate.com/forum/macro-quick-find-highlight
* Forked to fix API's for Komodo 7 and beyond
*
* Copyright (c) 2009 Stan Angeloff http://blog.angeloff.name
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
@Naatan
Naatan / flatten_array
Created November 11, 2011 20:54
Converts multi dimensional array / object to single depth array
function flatten_array($array, $parents = '')
{
if ( !is_array($array) AND !is_object($array))
{
return array($parents . $array);
}
$array = (array) $array;
$flat = array();
@Naatan
Naatan / object_to_array
Created November 11, 2011 20:48
Converts objects to array, recursively
function object_to_array($ob)
{
if (!is_array($ob) AND !is_object($ob))
{
return $ob;
}
$ob = (array) $ob;
foreach ($ob AS $k => $v)
@Naatan
Naatan / PHP Yaml encode
Created April 20, 2012 15:20
Tries to convert a PHP variable of any type to yaml. This is EXTREMELY experimental, I'm just playing around.
<?php
function renderYaml($result, $prefix = '', $indentation = 0, $ptype = '')
{
$result = json_decode(json_encode($result)); // convert key based arrays to objects
$indent = $prefix;
for ($c=0;$c<$indentation; $c++) {
$indent = ' ' . $indent;