Skip to content

Instantly share code, notes, and snippets.

@johshoff
johshoff / main.rs
Created November 15, 2016 04:31
scan ips
use std::thread;
use std::net::TcpStream;
fn check_open_port(host: &str, port: u16) -> bool {
TcpStream::connect((host, port)).is_ok()
}
fn main() {
const PORT : u16 = 22;
@johshoff
johshoff / main.rs
Created November 1, 2015 22:28
encode hashmap as list
extern crate rustc_serialize;
use std::collections::HashMap;
use rustc_serialize::{Encodable, Encoder};
use rustc_serialize::json;
#[derive(RustcEncodable, PartialEq, Eq, Hash, Debug)]
struct Point {
x: u64,
@johshoff
johshoff / tictactoe.py
Last active August 29, 2015 14:10 — forked from maghoff/tictactoe.py
# Python 3!
import random
def show(board):
print('+---+')
print('|%s|' % board[0:3])
print('|%s|' % board[3:6])
print('|%s|' % board[6:9])
print('+---+')
@johshoff
johshoff / nap.py
Last active December 16, 2015 23:19
nap — better than sleep
#!/usr/bin/env python
from sys import argv, exit
from time import sleep, time
import re
if len(argv) != 2:
print('Usage: nap <interval>')
print('Where: <interval> is <num>h hours')
#!/bin/bash
# Example usage:
#
# foreach '*.cs' grep foo
find . -iname "$1" -print0 | xargs -0 ${@:2}
@johshoff
johshoff / new_bashrc.sh
Created August 11, 2012 11:05 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
(ns tetris
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Dimension Color Polygon GraphicsEnvironment Transparency Toolkit)
(java.awt.image BufferStrategy BufferedImage PixelGrabber WritableRaster)
(java.awt.event ActionListener KeyListener KeyEvent))
(:gen-class))
(def *cols* 10)
(def *rows* 20)