<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/"/>

<title>Jeff Epler's blog</title>
<modified>2025-11-26T16:09:19Z</modified>
<tagline>Photos, electronics, cnc, and more</tagline>
<author><name>Jeff Epler</name><email>jepler@unpythonic.net</email></author>
<entry>
<title>Junk drawer & embedding</title>
<issued>2025-11-26T16:09:19Z</issued>
<modified>2025-11-26T16:09:19Z</modified>
<id>https://gamma.unpythonic.net/01764173359</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01764173359"/>
<content type="text/html" mode="escaped">



&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css&quot;&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/python.min.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;
.junkpre { border: 1px solid black; max-width: 132ex; max-height: 45lh; overflow: auto; }
&lt;/style&gt;
&lt;script&gt;
const do_embed = function(container, url) {
    const request = new Request(url);
    fetch(request)
      .then((response) =&gt; response.json())
      .then((data) =&gt; {
        container.textContent = atob(data['content']);
        hljs.highlightElement(container)    
    })
    .catch((error) =&gt; {
       console.error(error);
    });
}
const do_embed_here = function(url, classes) {
    const id = &quot;embed&quot; + (((1 + Math.random()) * 0x1000000) | 0).toString(16).substring(1);
    document.write(&quot;&lt;pre class=junkpre&gt;&lt;code id=&quot; + id + &quot; class=junkembed&gt;&lt;/code&gt;&lt;/pre&gt;&quot;)
    const el = document.getElementById(id)
    if (classes) {
        el.className = el.className + &quot; &quot; + classes
    }
    do_embed(el, url)
}
&lt;/script&gt;


&lt;p&gt;I have been working on leaving github.

&lt;p&gt;One thing I liked from github was gist, including command-line upload and the ability to embed it.
I want to replace this but with codeberg. And, I think I've gotten close.
More polish wouldn't hurt, but ehhh...

&lt;p&gt;First, here's the &lt;a href=&quot;shttps://codeberg.org/api/v1/repos/jepler/junkdrawer/contents/aygdu2e9/junk.py?ref=main&quot;&gt;script for uploading&lt;/a&gt;:

&lt;p&gt;
&lt;script&gt;
do_embed_here(&quot;https://codeberg.org/api/v1/repos/jepler/junkdrawer/contents/aygdu2e9/junk.py?ref=main&quot;, &quot;language-python&quot;);
&lt;/script&gt;

&lt;p&gt;And here's an &lt;a href=&quot;https://codeberg.org/jepler/junkdrawer/src/branch/main/he58aqtn/junkembed.html&quot;&gt;example of embedding&lt;/a&gt;:

&lt;script&gt;
do_embed_here(&quot;https://codeberg.org/api/v1/repos/jepler/junkdrawer/contents/he58aqtn/junkembed.html?ref=main&quot;, &quot;language-html&quot;);
&lt;/script&gt;
</content>
</entry>
<entry>
<title>Cheating at incremental games using angularjs</title>
<issued>2015-02-19T19:31:59Z</issued>
<modified>2015-02-19T19:31:59Z</modified>
<id>https://gamma.unpythonic.net/01424374319</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01424374319"/>
<content type="text/html" mode="escaped">

I don't know a thing about javascript frameworks, but I like to cheat at
incremental games.  So it's frustrating when a game is made with some framework
that seems to leave everything inaccessible. (I think this is more about
the framework trying to be hygenic than anti-cheating)

&lt;p&gt;So I was happy to learn enough about angularjs to cheat at my favorite
incremental game of the moment, &lt;a href=&quot;https://swarmsim.github.io/&quot;&gt;Swarm Simulator&lt;/a&gt;.

&lt;p&gt;&lt;pre &gt;
var sc = angular.element(document.querySelector('.ng-scope')).scope()
sc.env.isDebugEnabled = 1
sc.game._units.byName.nexus.prodByName.energy.val = new Decimal(1000)
sc.game.unit('mutagen')._addCount(new Decimal(1e100))
&lt;/pre&gt;
</content>
</entry>
<entry>
<title>Marking anchors in HTML with a javascript bookmark</title>
<issued>2008-08-13T13:01:19Z</issued>
<modified>2008-08-13T13:01:19Z</modified>
<id>https://gamma.unpythonic.net/01218632479</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01218632479"/>
<content type="text/html" mode="escaped">
To send links to internal anchors in HTML documents, use &lt;a href=&quot;javascript:(function(){%20var%20rows=document.evaluate('//a[@name]',%20document,%20null,%20XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,%20null);%20for(var%20i=0;%20i%3crows.snapshotLength;%20i++)%20{%20var%20it%20=%20rows.snapshotItem(i);%20var%20name%20=%20it.getAttribute('name');%20if(0%20%26%26%20it.GetAttribute('href')%20||%20it.innerHTML)%20continue;%20it.innerHTML=%22#%22;%20it.setAttribute(%22href%22,%20%22#%22%20+%20name);%20}%20rows%20=%20document.evaluate('//*[@id]',%20document,%20null,%20XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,%20null);%20for(var%20i=rows.snapshotLength-1;%20i%3e=0;%20i--)%20{%20var%20it%20=%20rows.snapshotItem(i);%20var%20id%20=%20it.getAttribute('id');%20it.innerHTML%20=%20%22%3ca%20href=\%22#%22%20+%20id%20+%20%22\%22%3e#%3c/a%3e%22%20+%20it.innerHTML;%20}%20})()&quot;&gt;this bookmarklet&lt;/A&gt;.

&lt;p&gt;I find this bookmarklet very useful when sending people links to emc
documentation and the wiki, because there are often more anchors available than
those that are actually linked to in tables of contents.

&lt;p&gt;</content>
</entry>
<entry>
<title>glif: generate client-side gif files from javascript</title>
<issued>2005-09-11T18:15:11Z</issued>
<modified>2005-09-11T18:15:11Z</modified>
<id>https://gamma.unpythonic.net/software/01126462511-glif</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/software/01126462511-glif"/>
<content type="text/html" mode="escaped">It probably won't be the biggest thing since AJAX, but I hit upon the
idea of generating images client-side.  The current ways to do this seem to
involve using tables or absolute-positioning of very small DIVs.  (See, for
example, &lt;a href=&quot;http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm&quot;&gt;http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm&lt;/a&gt;) My
technique, which I call &lt;i&gt;glif&lt;/i&gt; (for &lt;i&gt;GIF&lt;/i&gt; and &lt;i&gt;glyph&lt;/i&gt;),
generates a gif-format image on the client side.

&lt;p&gt;One application for this that comes immediately to mind is client-side
generation of &lt;a href=&quot;http://www.xml.com/pub/a/2005/06/22/sparklines.html&quot;&gt;sparklines&lt;/a&gt;-type images, possibly from an AJAX source.


&lt;p&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/software/01126462511-glif/glif.html&quot;&gt;glif.html&lt;/a&gt; is a small demo which draws a sine wave in an image (Known not to work in IE) &lt;b&gt;Update: &lt;a href=&quot;https://media.unpythonic.net/emergent-files/software/01126462511-glif/sparglif2.html&quot;&gt;SparGlif demo&lt;/a&gt;&lt;/b&gt;</content>
</entry>
</feed>
