# Run the last command as root | |
sudo !! | |
# Serve current directory tree at http://$HOSTNAME:8000/ | |
python -m SimpleHTTPServer | |
# Save a file you edited in vim without the needed permissions | |
:w !sudo tee % | |
# change to the previous working directory | |
cd - | |
# Runs previous command but replacing | |
^foo^bar |
This gist includes components of a oozie workflow - scripts/code, sample data | |
and commands; Oozie actions covered: java mapreduce action; Oozie controls | |
covered: start, kill, end; The java program uses regex to parse the logs, and | |
also extracts the path of the mapper input directory path and includes in the | |
key emitted. | |
Note: The reducer can be specified as a combiner as well. | |
Usecase | |
------- |
// From yesenadam at https://news.ycombinator.com/item?id=23590848 | |
function $(id) { return document.getElementById(id); } | |
function byClass (el, cl) { return el ? el.getElementsByClassName(cl) : [] } | |
function byTag (el, tg) { return el ? el.getElementsByTagName(tg) : [] } | |
function allof (cl) { return byClass(document, cl) } | |
function hasClass (el, cl) { var a = el.className.split(' '); return afind(cl, a) } | |
function addClass (el, cl) { if (el) { var a = el.className.split(' '); if (!afind(cl, a)) { a.unshift(cl); el.className = a.join(' ')}} } | |
function remClass (el, cl) { if (el) { var a = el.className.split(' '); arem(a, cl); el.className = a.join(' ') } } | |
function html (el) { return el ? el.innerHTML : null; } |
This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247
Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book
I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!
A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:
.
#!/usr/bin/env python3 | |
import sqlite3 # yay SQLite! | |
import base64 | |
import os | |
import sys | |
if sys.version_info<(3,6,0): | |
print("You need python 3.6 or later to run this script.") | |
exit(-1) |
import com.google.common.io.Resources; | |
import com.google.gson.GsonBuilder; | |
import com.google.gson.JsonDeserializer; | |
import com.google.gson.JsonObject; | |
import java.io.IOException; | |
import java.net.URL; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import java.util.stream.Stream; |
<?php | |
// half-hearted CSS minification | |
$css = preg_replace( | |
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'), | |
array('$1{ ','$1$3;',"",'} '), | |
file_get_contents('linked.css') | |
); | |
// embed as a data: uri | |
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '='); |
<div class="container"> | |
<form action="https://www.google.com/search" method="get" target="_blank" id="search-form"> | |
<input name="q" type="text" placeholder="Search Google..." autocomplete="off" autofocus> | |
<!-- <button type="button"><i class="fas fa-microphone"></i></button> --> | |
</form> | |
<p class="info"></p> | |
</div> |
<script src="main.js"></script> | |
<link rel="stylesheet" href="main.css"> | |
<h1>Say Color:</h1> | |
<div class="color-cube"> | |
<div class="circle outer"> | |
<div class="circle inner"></div> | |
</div> | |
</div> |