Skip to content

Instantly share code, notes, and snippets.

@ncimino
ncimino / client.tcl
Created September 25, 2012 22:02
Client Side - Tcl
#!/usr/bin/tclsh
proc read_sock {sock} {
set l [gets $sock]
puts stdout "ServerReply:$l"
}
proc read_stdin {wsock} {
global eventLoop
set l [gets stdin]
@ncimino
ncimino / server.tcl
Created September 25, 2012 22:04
Server Side - Tcl
#!/usr/bin/tclsh
set svcPort 8001
proc doService {sock msg} {
puts $sock "$msg"
}
proc svcHandler {sock} {
set l [gets $sock]
@ncimino
ncimino / untar_all.sh
Created October 10, 2012 18:46
Untar all
MYDIR="/home/${USER}/archives"
ls ${MYDIR}/*.tar > filelist
for FILENAME in `cat filelist`
do
ARCHDIR=${MYDIR}/$(basename $FILENAME .tar)
mkdir $ARCHDIR
echo ==== Extracting $FILENAME to $ARCHDIR:
tar -xf $FILENAME -C $MYDIR
done
@ncimino
ncimino / gist:3885267
Created October 13, 2012 16:34
jQuery create drop-downs and auto-filter
$(function() {
$("input[type=button][value=Add]").click(function(e) {
for (i = 0; i < document.getElementById('sel').value; i++) {
e.preventDefault();
var j = 1;
var newDiv = $("<div>").appendTo("#dropbox");
$("<select>").attr("name", "input1_"+j).appendTo(newDiv).append(
$("<option>").val("0").text("Option 1"), $("<option>").val("1").text("Option 2"));
$("<select>").attr("name", "input2_"+j).appendTo(newDiv).append(
$("<option>").val("0").text("Option 1"), $("<option>").val("1").text("Option 2"));
@ncimino
ncimino / .gitignore
Last active October 11, 2015 19:08
Git Ignore All Except
*
!/a
/a/*
!/a/b
/a/b/*
!/a/b/c
/a/b/c/*
!/a/b/c/foo
# don't forget this one
@ncimino
ncimino / zip_content.sh
Created November 19, 2012 18:39
Bash loop through files - show zip contents
rm contents.txt
ls *.zip > filelist
for FILENAME in `cat filelist`
do
unzip -l $FILENAME >> contents.txt
done
rm filelist
#!/bin/sh
# To copy from the one file to several directories, use:
find -maxdepth 1 -mindepth 1 -type d -exec cp ${1} {} \;
@ncimino
ncimino / .vimrc
Created April 23, 2013 22:38
vimrc, my vim and gvim configuration
" This must be first, because it changes other options as side effect
set nocompatible
" Use pathogen to easily modify the runtime path to include all
" plugins under the ~/.vim/bundle directory
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
"Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
@ncimino
ncimino / gist:5526288
Created May 6, 2013 16:39
Multi character (string) split in Tcl
# mcsplit --
#
# Splits a string based using another string
#
# Arguments:
# str string to split into pieces
# splitStr substring
# mc magic character that must not exist in the orignal string.
# Defaults to the NULL character. Must be a single character.
# Results:
@ncimino
ncimino / gist:346b1d869c14b6b005f7
Last active August 29, 2015 14:05
Linux Disks
fdisk -l | grep '^Disk'; # list drives
file -s /dev/sdd; # list device sdd details
fsck /dev/sdd; # check device sdd
fdisk /dev/sdd; # partition drive
# m - print help
# p - print the partition table
# n - create a new partition
# d - delete a partition
# q - quit without saving changes