Skip to content

Instantly share code, notes, and snippets.

View eeroan's full-sized avatar

Eero Anttila eeroan

View GitHub Profile
@eeroan
eeroan / format_json.js
Last active March 22, 2021 08:13
Json formatter
#!/usr/bin/env node
const chunks = []
process.stdin
.on('data', chunk => chunks.push(chunk))
.on('end', () => console.dir(eval('(' + JSON.stringify(JSON.parse(chunks.join(''))) + ')' + process.argv.slice(2).join(' ')), { colors: true, depth: null }))
# Example: echo '{"foo": [{"bar":[2],"baz":[1,2,3]}]}'| ./format_json.js .foo[0].baz
# results: [ 1, 2, 3 ]
@eeroan
eeroan / puhu.sh
Created December 12, 2016 17:38
Script for making easy for Mac to talk
#!/bin/bash
echo "Kirjoita ja paina ⏎ , edellinen komento: ↑, lopetus: Ctrl-C)"
while true; do
read -e text
say -v Satu $text
history -s "$text">/dev/null
done
@eeroan
eeroan / confluence.user.js
Created November 22, 2013 12:41
User script for making confluence blog layout decent. To install, save this file (from <>) and drag it to window -> extensions in Chrome
// ==UserScript==
// @match https://extra.reaktor.fi/*
// ==/UserScript==
var link = document.createElement('style')
link.setAttribute('type', 'text/css')
link.innerHTML=[
'.page-metadata ul { overflow: auto; }',
'.page-metadata { overflow: hidden; }'
].join('\n')
document.getElementsByTagName('head')[0].appendChild(link)
@eeroan
eeroan / jira.user.js
Created July 31, 2013 09:24
User script for Chrome. To install, save this file and drag it to window -> extensions Improve jira kanban board by setting max height and auto scroll for columns
// ==UserScript==
// @match http://jira.tallinkintra.net/secure/RapidBoard.jspa*
// ==/UserScript==
var link = document.createElement('style')
link.setAttribute('type', 'text/css')
link.innerHTML=[
'.ghx-parent-group {overflow-y:auto;overflow-x:hidden;max-height:500px;}',
'.ghx-columns .ghx-column {padding-bottom:0;}'].join('\n')
document.getElementsByTagName('head')[0].appendChild(link)
@eeroan
eeroan / slides.js
Created April 26, 2013 07:37
Slideshow from directory index
((function(){
if(typeof window.jQuery == 'undefined') {
var script = document.createElement('script');
script.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');
document.getElementsByTagName('head')[0].appendChild(script);
var attempts = 15;
;(function(){
if(typeof window.jQuery == 'undefined') {
if(--attempts > 0) {
window.setTimeout(arguments.callee, 250);
@eeroan
eeroan / papply.js
Last active December 15, 2015 02:19
Awesome partial application function for JavaScript
var __ = {}
function papply(func, givenArguments) {
var indexOf = givenArguments.indexOf(__)
var givenArgsSize = givenArguments.length
var requiredArgsSize = func.length
if(givenArgsSize >= requiredArgsSize && (indexOf < 0 || indexOf >= requiredArgsSize))
return func.apply(func, givenArguments)
else
return function() {
return (function(givenArguments, remainingArguments) {
@eeroan
eeroan / styleWaiter.js
Last active December 14, 2015 09:29
Poll untill styles are loaded
var href = 'http://url.com'
appendStyle(href)
waitForStyles(loadApp)
function appendStyle(href) {
var link = document.createElement('link')
link.setAttribute('rel', 'stylesheet')
link.setAttribute('type', 'text/css')
link.setAttribute('href', href)
document.head.appendChild(link)
@eeroan
eeroan / anagram.js
Created February 13, 2013 00:54
Anagram tester algoritm
function anagramTester(dictionary) {
var hash = _.groupBy(dictionary, sortStr)
return function(word) {
var sortedWord = sortStr(word)
return (sortedWord in hash) ? hash[sortedWord] : []
}
function sortStr(str) { return _.map(str, _.identity).sort().join('') }
}
@eeroan
eeroan / pom.xml
Created January 24, 2013 19:34
Maven configuration for running compass compile
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>0.28.6</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
@eeroan
eeroan / pom.xml
Last active December 11, 2015 16:19
Working solution for bundling require.js project using maven Rhino version (js.jar) is from require.js site
<properties>
<bundle.rhinoJar>${project.basedir}/lib/js.jar</bundle.rhinoJar>
<bundle.rhinoMainClass>org.mozilla.javascript.tools.shell.Main</bundle.rhinoMainClass>
<bundle.rJsPath>${webappPath}/vendor/r-2.1.2.js</bundle.rJsPath>
</properties>
<profile>
<id>bundle-js-assets</id>
<build>
<plugins>
<plugin>