This is a SCRIPT-8 cassette.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modules = [ | |
{ date "+DATE: %d/%m/%y TIME: %H:%M:%S" } | |
{ acpi -b | cut -d ',' -f 2 | cut -d ' ' -f 2 } | |
] | |
while $true { | |
for m $modules { $m } | | |
xsetroot -name (joins ' ') | |
sleep 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intersection of two character sets. | |
# ${var//pattern} removes all matches of pattern in $var. | |
# By removing all characters that are not in s2 from s1, you obtain the intersection. | |
s1=abcd | |
s2=axyz | |
echo ${s1//[^s2]} | |
# Determine if a word is in a space-separated list | |
case " $haystack " in | |
*" $needle "*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"io" | |
"os" | |
"unicode" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pressing Enter when the command is empty shows you the last command. | |
# You can press Enter again to execute. | |
edit:insert:binding[Enter] = { | |
if (eq $edit:current-command '') { | |
edit:history:start | |
} else { | |
edit:smart-enter | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env elvish | |
# Run with: socat OPENSSL:irc.freenode.net:6697 EXEC:./issuebot | |
use re | |
api-base = https://api.github.com/repos/elves/elvish/issues | |
web-base = https://github.com/elves/elvish/issues | |
echo "NICK ghhasher" | |
echo "USER ghhasher 0 * :GitHub Issue Linkifier" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have a type that used to be called "EvalCtx" but now called "Frame". | |
# The gorename tool can make a sweeping change of all references to EvalCtx, | |
# but I'm still left with many arguments and method receivers called "ec". | |
# With the type name changed, they now look like: | |
# | |
# func f(ec *Frame, ...) | |
# | |
# I want to do a batch rename of all those variables as well. Here is a really | |
# simple Elvish script to do it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code illustrates a concurrent prompt updating algorithm with the following properties: | |
// 1. Non-parallelism: No two instances of the prompt update function is run in parallel. | |
// 2. Freshness: after an input, the prompt will always updated at early as possible. | |
// 3. Economy: Prompt is only updated when new inputs have arrived. | |
func updatePrompt(req <-chan struct{}) { | |
for range req { | |
update() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following function does not work, because i is allocated on the stack, so a pointer to it becomes | |
// invalid after the function call returns. | |
int *f() { | |
int i = 20; | |
return &i; | |
} | |
// Hence, to return a int pointer, the space must be allocated on the heap: | |
int *g() { | |
int *p = malloc(sizeof(int)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.LinkedList; | |
import java.lang.StringBuilder; | |
class Solution { | |
interface Node { | |
void write(StringBuilder sb); | |
} | |
// SimpleNode is a sequence of non-special characters, like "abc". |