Skip to content

Instantly share code, notes, and snippets.

$outdir = 'splitout'
def split file
base = File.basename file
if File.size(file) < 10000000
puts `cp #{file} #{$outdir}/#{base}`
else
puts `zcat #{file} | split - -l 1000000 --filter='gzip > $FILE.gz' #{$outdir}/#{base[0..-3]}`
end
end
select ts,
seats,
sum(seats) over(order by rownum) as usage
from (
select
row_number() over(order by '1') as rownum,
to_timestamp(columns[0], 'yyyy-MM-dd HH:mm:ss Z z') as ts,
case
when columns[1] = 'out' then cast(columns[3] as int)
@nkkarthik
nkkarthik / email.go
Last active July 27, 2019 00:00
golang send smtp email with subject
type Email struct {
From string
To []string
Subject string
Body string
}
func (email *Email) Send() error {
data := fmt.Sprintf("To: %s\r\nSubject: %s\r\n\r\n%s\r\n",
strings.Join(email.To, ","),
@Grab(
group='org.codehaus.jackson',
module='jackson-mapper-asl',
version='1.9.11')
import org.codehaus.jackson.map.*
import org.codehaus.jackson.annotate.*
import groovy.transform.*
@Canonical
class MachineConfig {
@nkkarthik
nkkarthik / 0_reuse_code.js
Created March 18, 2016 21:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nkkarthik
nkkarthik / mssql.php
Last active August 29, 2015 14:19
php runs mssql query on command line and returns the results
<?php
$server = $_POST['server'];
$db = $_POST['db'];
$raw_query = $_POST['query'];
$trimmed_query = trim(preg_replace('/\s+/', ' ', $raw_query));
$cmd = 'sqlcmd -S ' . $server . ' -d ' . $db . ' -Q "' . $trimmed_query . '"';
echo shell_exec($cmd);
?>
@nkkarthik
nkkarthik / partial-class-name-completion.patch
Created July 15, 2012 16:16
Clojure-complete: Partial class name completion patch
From ec8d67db882c28c74097020cc09b09f4cddc3097 Mon Sep 17 00:00:00 2001
From: Krishna Karthik <nkkarthik@gmail.com>
Date: Sun, 15 Jul 2012 18:12:11 +0530
Subject: [PATCH] Partial class name completion
---
src/complete/core.clj | 24 ++++++++++++++++++++----
test/complete/core_test.clj | 10 +++++++++-
2 files changed, 29 insertions(+), 5 deletions(-)