Skip to content

Instantly share code, notes, and snippets.

View likejazz's full-sized avatar

Sang Park likejazz

View GitHub Profile
for i in `seq 1 8`
do
echo "cat ~/.ssh/id_rsa.pub | ssh account@iaas-hh$i 'cat >> .ssh/authorized_keys'"
cat ~/.ssh/id_rsa.pub | ssh account@iaas-hh$i 'cat >> .ssh/authorized_keys'
done
#!/bin/bash
DAUMID=*****
DAUMPW=*****
# IMAP SSL/TLS
response=`{ echo "a001 login $DAUMID $DAUMPW"; sleep 1; echo "a002 select inbox"; sleep 1; echo "a003 logout"; } | /usr/local/bin/gnutls-cli imap.daum.net --port=993`
# fetch `UNSEEN` mail count
unseen=$(echo $response | grep -oEi 'OK\ \[UNSEEN\ (\d+)' | awk '{print $3}')
PLATFORM=`uname`
if [[ "$PLATFORM" == 'Darwin' ]]; then # Mac
IP=`/sbin/ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'`
elif [[ "$PLATFORM" == 'Linux' ]]; then # Linux
IP=`/sbin/ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'`
fi
print $IP
@likejazz
likejazz / MaxTemp.java
Created November 3, 2014 04:42
O'Reilly's "Hadoop: The Definitive Guide" ch2 sample in a one file
// cc MaxTemperature Application to find the maximum temperature in the weather dataset
// vv MaxTemperature
import java.io.IOException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
.vim
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
NotUsed = 0;
int i;
for (i = 0; i < argc; i++) {
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
#!/bin/bash
set -e
GIT_OPTS="--max-count=10"
commit_id_format=$(tput setaf 3)
date_format=$(tput setaf 4)
author_format=$(tput setaf 2)
ref_name_format=$(tput setaf 1)
#!/bin/sh
# See http://www.wtfpl.net/txt/copying for license details
# Creates a minimal manifest and manifest.uuid file so sqlite (and fossil) can build
git rev-parse --git-dir >/dev/null || exit 1
git log -1 --format=format:%ci%n | sed -e 's/ [-+].*$//;s/ /T/;s/^/D /' > manifest
echo $(git log -1 --format=format:%H) > manifest.uuid
#!/bin/bash
url=`pbpaste`
url=$(echo $url | sed 's/www.dropbox.com/dl.dropboxusercontent.com/g' | tr -d '\n')
echo "$url"
echo "$url" | pbcopy
@likejazz
likejazz / server.c
Last active August 29, 2015 14:22
How to handle TIME_WAIT state
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pthread.h>