Skip to content

Instantly share code, notes, and snippets.

Avatar

sarnobat

View GitHub Profile
View Bourne shell iterate over stdin.sh
while read line
do
echo "$line"
done < "${1:-/dev/stdin}"
@sarnobat
sarnobat / .bashrc.keys.sh
Last active Sep 25, 2017
Key binding equivalents between Bash and Zsh
View .bashrc.keys.sh
# bash
bind '"\el":"ls -lrtha --color=always\n"'
bind '"\ef":"find $PWD -type f -iname \"**\""'
bind '"\eg":"| xargs grep --delimiter \"\\n\" grep --color=always -ni \"*\""'
bind '"\e[1;3D": backward-word'
bind '"\e[1;3C": forward-word'
bind '"\e[1;3A": history-search-backward'
bind '"\e[1;3B": history-search-forward'
bind '"\ep":"pwd\n"'
bind '"\e4"':yank-last-arg
@sarnobat
sarnobat / mac_install.sh
Last active Sep 19, 2017
MAC OS X - install these
View mac_install.sh
brew install coreutils
brew install findutils
brew install wget
brew install netcat --verbose
brew install ssh-copy-id
@sarnobat
sarnobat / ubuntu_install.sh
Last active Sep 19, 2017
Ubuntu - install these
View ubuntu_install.sh
sudo apt-get install -y zsh
chsh $(whoami) -s /usr/bin/zsh
sudo apt-get install -y git
sudo apt-get remove -y vim
sudo apt-get install -y vim
sudo apt-get install -y openjdk-7-jdk
#sudo apt-get install -y default-jdk
@sarnobat
sarnobat / cygwin_install.txt
Last active Sep 19, 2017
Cygwin - install these
View cygwin_install.txt
# From Wizard
Admin
cron
Archive
p7zip
rsnapshot
zip
Devel
git
@sarnobat
sarnobat / CommonsCLI.java
Last active Sep 19, 2017
java command line options
View CommonsCLI.java
import org.apache.commons.cli.*;
/** TODO: which maven artifact version do we need? */
public class CommandLineOptionsExample {
public static void main(String[] args) {
String port;
_parseOptions: {
Options options = new Options()
@sarnobat
sarnobat / index.html
Last active Aug 30, 2017
jQuery call REST service
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://localhost:9099/helloworld/json?param1=" + encodeURIComponent(document.getElementById("urls").innerHTML),function(result){
$.each(result, function(i, field){
$("#items").append(i + " " + field + " ");
@sarnobat
sarnobat / RestServer.java
Last active Sep 20, 2017
Jersey Hello World Servlet Resource
View RestServer.java
import java.net.URI;
import java.net.URISyntaxException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.jdkhttp.JdkHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
@sarnobat
sarnobat / Stdin.java
Last active Aug 28, 2018
Java command line program that loops over stdin
View Stdin.java
import java.io.*;
public class StdinLoop {
public static void main(String[] args) {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {