Skip to content

Instantly share code, notes, and snippets.

# The following will split a CSV (file.csv) into multiple parts of 1 million lines each
# with each part having its own header.
#
# PREFIX denotes the filename to use for the parts. A number will be added to the end.
tail -n +2 file.csv |
split -d -l 1000000 - --filter='sh -c "{ head -n1 file.csv; cat; } > $FILE"' PREFIX
@damc-dev
damc-dev / _service.md
Created February 17, 2019 19:29 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@damc-dev
damc-dev / RequestAndResponseLoggingFilter.java
Created January 23, 2019 01:24 — forked from int128/RequestAndResponseLoggingFilter.java
Spring Web filter for logging request and response
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
@damc-dev
damc-dev / giphy_download_links.js
Created September 22, 2017 14:40
Giphy Download Links to All Gifs
@damc-dev
damc-dev / reload_explorer.bat
Created August 7, 2017 14:27
Reload explorer.exe to pick up changes such as environment variables
taskkill /f /im explorer.exe
explorer.exe
@damc-dev
damc-dev / ps-notify-example.go
Created July 18, 2017 13:51
Example using ps notify
package main
import (
"bytes"
"log"
"os"
"os/exec"
"syscall"
"github.com/cloudfoundry/gosigar/psnotify"
@damc-dev
damc-dev / tmux.md
Created June 16, 2017 21:28 — forked from smhjn/tmux.md
Clean tmux cheat-sheet

Clean tmux cheat-sheet

By resources

sessions

list-sessions        ls         -- List sessions managed by server
new-session          new        -- Create a new session
@damc-dev
damc-dev / parallel-subshells.sh
Last active May 30, 2017 13:34
Run Bash subshells in parallel
#!/bin/bash
TMP_DIR="$(mktemp -d -t subshells.XXXXXXXXXX)"
function cleanup {
rm -rf "${TMP_DIR}"
}
trap cleanup EXIT
PIDS=()
for i in 1 2 3; do
@damc-dev
damc-dev / convertToKb.sh
Created May 15, 2017 15:07
Convert a value provided to the JVM to Kb
#!/bin/bash
convertToKb() {
data="$1"
unit="${data//[0-9]/}"
value="${data//[!0-9]}"
converted="ERROR"
case $unit in
k | K)
converted="$value"
;;