(C-x means ctrl+x, M-x means alt+x)
start new:
tmux
start new session with name:
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/" | |
} | |
function proml { | |
local BLUE="\[\033[0;34m\]" |
- create - | |
curl -XPUT 'localhost:9200/my-index/my-type/1' -d '{"title" : "Coffee percolator", "body" : "A coffee percolator is a type of ..."}' | |
- search - | |
curl -XGET 'localhost:9200/my-index/_search' -d '{"query" : {"match" : {"body" : "coffee"}}}' | |
- get all - | |
curl -XGET 'localhost:9200/my-index/_search?pretty=true' | |
- Register a query - |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'csv' | |
require 'spidr' | |
CSV.open('pets_crawl.csv', 'wb') do |csv| | |
csv << ['page title', 'page url'] | |
Spidr.site('http://www.petsmart.com', :ignore_links => [/gsi/]) do |spider| | |
spider.every_html_page do |page| |
function order(words){ | |
// return empty string for undefined | |
if (words === undefined) { | |
return ''; | |
} | |
let rval = []; | |
let pieces = words.split(' '); | |
for (let i=0; i<10; i++) { | |
if (pieces.hasOwnProperty(i)) { |
/* | |
A function that computes a factorial recursively. | |
A factorial is when you take a number n and multiply by each preceding integer until you hit one. | |
n * (n-1) * (n-2) ... * 3 * 2 * 1 | |
Call the function factorial | |
factorial(1) = 1 | |
factorial(2) = 2 | |
factorial(3) = 6 |
#!/bin/sh | |
DOCKER=`which docker` | |
IMAGE='owasp/zap2docker-weekly' | |
URL='https://www.example.com' | |
ZAP_API_PORT='8090' | |
# Start our container | |
CONTAINER_ID=`$DOCKER run -d \ | |
-p $ZAP_API_PORT:$ZAP_API_PORT \ |
provider "aws" { | |
region = "us-east-1" | |
} | |
resource "aws_security_group" "instance" { | |
name = "terraform-example-instance" | |
ingress { | |
from_port = "${var.server_port}" | |
to_port = "${var.server_port}" |
##git mergetool
In the middle file (future merged file), you can navigate between conflicts with ]c
and [c
.
Choose which version you want to keep with :diffget //2
or :diffget //3
(the //2
and //3
are unique identifiers for the target/master copy and the merge/branch copy file names).
:diffupdate (to remove leftover spacing issues)
:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)