- Issues with the following Linux/Bash one-liner:
- It is ugly
- It has trailing tabs (
\t
)
- Challenge:
- Come up with a more elegant and concise Linux one-liner.
- Rules:
- You must only use Linux and/or Bash and it must be able to be run from the Linux CLI as a one-liner.
This file contains 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
# NAME: pyrax_create_cloud_server | |
# AUTHOR: Christoph Champ | |
# DESCRIPTION: This script creates a Cloud Server in your Rackspace account. | |
# It then creates an image of that server, and, finally, creates a new server | |
# from that saved image. | |
# | |
# NOTES: Within each of the created VMs, the generated credentials are in | |
# master_server.adminPass and clone_server.adminPass. To access the box, use | |
# master_server.accessIPv4 and clone_server.accessIPv4. | |
# However, it is _much_ better/safer/wiser to use SSH keypairs. |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
$common_script = <<COMMON_SCRIPT | |
# Set verbose | |
set -v | |
# Set exit on error |
This file contains 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
#!/bin/bash | |
# | |
# description: Apache Tomcat init script | |
# processname: tomcat | |
# chkconfig: 234 20 80 | |
# | |
# | |
# Copyright (C) 2014 Miglen Evlogiev | |
# | |
# This program is free software: you can redistribute it and/or modify it under |
This file contains 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 python | |
from random import randint | |
RANGE = 1000000 | |
def random_guess(RANGE): | |
wins = [] | |
for _ in range(0, RANGE): | |
guess = randint(0, 1) | |
outcome = randint(0, 1) |
This file contains 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 python | |
import yaml | |
import json | |
""" | |
DESCRIPTION: The goal of this script is to find the outermost/top-level key in | |
the following YAML document, given only the sub-group/sub-key name. | |
EXAMPLE: Say you only know the sub-group "mars" or "pluto", and you want to | |
know which top-level key they belong to (i.e., "apps" and "services", | |
respectively). The find_category() function will do just that, albeit, very |
This file contains 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
$ REGION=dfw; CONTAINER_NAME=sandbox; for i in *.png; do curl -XPUT -T $i -v -H "X-Auth-Token:$MYRAXTOKEN" -H"Content-Type: text/plain" "https://storage101.${REGION}1.clouddrive.com/v1/MossoCloudFS_ffff-ffff-ffff-ffff-ffff/${CONTAINER_NAME}/$i"; done |
This file contains 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
# Steganography trick: | |
$ cat foo.zip >> bar.gif # "hides" 'foo.zip' inside 'bar.gif' | |
$ qiv bar.gif # views just fine (note: you can use any image viewer you like here) | |
$ unzip bar.gif # extracts 'foo.zip' | |
# Example: | |
$ echo "HELLO WORLD" > file.txt | |
$ zip -r foo.zip file.txt | |
$ cat foo.zip >> bar.gif | |
$ hexdump -C bar.gif |tail -12 |
This file contains 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
# Calculate amino acid codon frequency | |
from collections import defaultdict | |
#the first 600 nucleotides from GenBank: AAHX01097212.1 | |
rna = ("tcccccgcagcttcgggaacgtgcgggctcgggagggaggggcctggcgccgggcgcgcg" | |
"cctgcgccccaccccgccccaccctggcgggtctcgcgcgcccggcccgcctcctgtcaa" | |
"ccccagcgcggcggtcaggtggtccccagcccttggccccagcctccagcttcctggtcc" | |
"ctcgggctctgagtcctgtctccggcagatcgcctttctgattgttctcctgcgcagctg" | |
"gaggtgtatagcccctagccgagctatggtgcctcagcagatgtgaggaggtagtgggtc" | |
"aggataaacccgcgcactccataataacgtgccagggctcagtgacttgggtctgcatta") |
This file contains 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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "AWS CloudFormation Sample Template LAMP_Single_Instance: Create a LAMP stack using a single EC2 instance and a local MySQL database for storage. This template demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the Apache web server, PHP and MySQL at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.", | |
"Parameters" : { | |
"KeyName": { | |
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", | |
"Type": "AWS::EC2::KeyPair::KeyName", |
OlderNewer