Skip to content

Instantly share code, notes, and snippets.

View joyoyoyoyoyo's full-sized avatar
🏴
supporting my community

Angel Ortega joyoyoyoyoyo

🏴
supporting my community
  • InterMedia Advertising
  • SoCal / Remote / LA / IE
View GitHub Profile
@joyoyoyoyoyo
joyoyoyoyoyo / parse_csv_demo.sh
Created November 29, 2017 14:16 — forked from huandu/parse_csv_demo.sh
Demo to parse CSV file with awk.
# parse csv files to an awk array.
awk -F, '{
parse_csv(r);
# replace following line with your code.
print r[1], r[2], r[3], r[4];
} function parse_csv(r, _quote, _i, _n) {
_i = 1;
_quote = 0; # in a quoted string or not.
@joyoyoyoyoyo
joyoyoyoyoyo / sample.bankstmt.csv
Created November 29, 2017 14:16 — forked from navdove/sample.bankstmt.csv
Bash shell one liner to parse numbers and manipulate them (sum for e.g) using awk
grep 'DEPOSIT' sample.bankstmt.csv | cut -d ',' -f4 | awk '{s+=$1} END {print s}'
//produces correct output by summing the numbers
//951.95
@joyoyoyoyoyo
joyoyoyoyoyo / csv.awk
Created November 29, 2017 14:17 — forked from scottmcclung/csv.awk
AWK script for parsing and reconstructing CSV data files. Originally written by Lorance Stinson...I've just made a few tweaks to this for my own use.
#!/usr/bin/awk -f
########################### AWK CSV Parser ###########################
# #
# ********** This file is in the public domain. ********** #
# #
# Use this source in any way you wish. #
# Feedback and bug reports would be appreciated. #
# As would a note about what how you are using it. #
# #
@joyoyoyoyoyo
joyoyoyoyoyo / count.hs
Created November 29, 2017 14:17 — forked from killerswan/count.hs
Haskell back in awk's order of magnitude <_<
-- Kevin Cantu
-- April 2012
import Control.Monad (when)
import Data.Map (Map)
import Data.List
import Data.List.Split
import qualified Data.Map as M
import System.Environment
import System.IO
@joyoyoyoyoyo
joyoyoyoyoyo / foo.rb
Created November 29, 2017 14:17 — forked from beav/foo.rb
parsing katello task export
require 'csv'
require 'time'
FORMAT = "%Y-%m-%d %H:%M:%S %Z"
CSV.foreach('times') do |row|
begin
start = DateTime.strptime(row[2].lstrip, FORMAT)
stop = DateTime.strptime(row[3].lstrip, FORMAT)
@joyoyoyoyoyo
joyoyoyoyoyo / questions.txt
Created November 29, 2017 14:17
Assorted interview quetions
* Generic questions:
- How does a CDN work?
- Can you describe how DNS works?
- Can you describe the difference between TCP and UDP?
- What is the difference between /32 and 255.255.255.255, what notation is used in each case?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joyoyoyoyoyo
joyoyoyoyoyo / JSONSample.scala
Created November 29, 2017 14:22 — forked from takezoe/JSONSample.scala
Example of scala.util.parsing.json
import scala.util.parsing.json._
val result = JSON.parseFull("""
{"name": "Naoki", "lang": ["Java", "Scala"]}
""")
result match {
case Some(e) => println(e) // => Map(name -> Naoki, lang -> List(Java, Scala))
case None => println("Failed.")
}
@joyoyoyoyoyo
joyoyoyoyoyo / grep.scala
Created November 29, 2017 14:25 — forked from frgomes/grep.scala
Scala - grep-like processing a list of inclusions and a list of exclusions
//-------------------------------------------------------------------------------------------------
// This would be something equivalent to:
// $ cat inputs.txt | fgrep -f includes.txt | fgrep -v -f excludes.txt | uniq | sort
//-------------------------------------------------------------------------------------------------
import scala.util.matching.Regex
def grep(inputs: Seq[String], includes: Set[Regex], excludes: Set[Regex], sort: Boolean = false, uniq: Boolean = false): Iterable[String] = {
def pass(s: String, set: Set[Regex]): Boolean = set.exists(r => r.findFirstIn(s).isDefined)
val grep1: Iterable[String] = if(includes.size==0) inputs else for { c <- inputs if(pass(c, includes)) } yield { c }
@joyoyoyoyoyo
joyoyoyoyoyo / java7_read_file_line_by_line.scala
Created November 29, 2017 14:26 — forked from frgomes/java7_read_file_line_by_line.scala
Scala - (Java style) Read file line by line
val filename = "data/wallet/wallet.sample.txt"
val lines: java.util.List[String] =
java.nio.file.Files.readAllLines(
java.nio.file.Paths.get(filename), java.nio.charset.StandardCharsets.UTF_8)