Skip to content

Instantly share code, notes, and snippets.

@CodeShane
CodeShane / com.codeshane.examples.java.BitwiseOr
Created October 17, 2012 06:50
Examples of merging bit-masks with bitwise-or
package com.codeshane.examples.java;
/* Examples of merging bit-masks with bitwise-or.
* Also available via http://snipt.org/vgxg5
*
* @author codeshane.com
* @version 1
*
*/
@CodeShane
CodeShane / gist:78382349769e509659c3
Created February 15, 2015 06:39
Redirect command output to a file named as a prefix suffixed with the current date and time ( prefix_yyyy-mm-dd_hh-mm.txt )
@echo off
echo " "
echo " dtg.bat - Redirect command output to a file named as "
echo " a 'prefix' suffixed with the date ^& time group (DTG). "
echo " "
echo " Usage: dtg prefix <command [-params]> "
echo " Filename: prefix_yyyy-mm-dd_hh-mm.txt "
echo " "
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set thedate=%%c-%%a-%%b)
for /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set thetime=%%a-%%b)
@CodeShane
CodeShane / gist:a2ed5d50f08bff8df3d3
Created February 15, 2015 06:41
Recursively move all files from current dir and below to the parent dir.
for /R . %%G IN (*.*) do move "%%G" ..
@CodeShane
CodeShane / name.sh
Created May 6, 2016 16:22
View or Change Local System Names on Mac OS X - OSX
#!/bin/sh
#
# View or Change Local System Names
#
# to view: ./name.sh
# to change: ./name.sh newname
# passwordless: sudo ./name.sh
#
if [ -z ${1+x} ]
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAxiZpCBe7YAbIsft0P7FdUtjBgZ8DzuWenzFRFig7NZT4DBrPd3aaBaWdjk0VjNk6NohLOer/AiY3u4WqiLuyi7XbDgNh564xmazC384omDVKabhkAPE/RkJn+GODYLhYXR7hqO/OAK8QL9MBemBA4U/XpWsykMZcNtQ5UDJ2c219U6Ul1dG0dfY10mnU4LDoUGIg3EGRJwSuEhvbIe7pg+niIJw2ZeHv6YLV0AMFPfdmIAy/gKGJAOP4Nm5jUreUb3XnHE2tPXXOom8jqvu5EjfFM4qsWyuBWWkW3M+FsltKDcqTuAucl/s44INsjvbWinbPRkl7RzWI6enE7j7mlQ== cp-node
@CodeShane
CodeShane / chksums.sh
Created April 18, 2017 23:53
Checksum one-liners.
# bourne shell functions below take 1 argument, the file_to_hash.
# prints hex digest on stdout
md5() {
perl -MDigest::MD5=md5_hex -le'print md5_hex(<> or die)' "$1"
# ruby -rdigest/md5 -e"puts Digest::MD5.file'/dev/null'"
# python -sBc "import hashlib;print hashlib.md5(open('$1','rb').read()).hexdigest()"
# md5 "$1"|cut -d' ' -f4 # mac
# md5sum "$1"|cut -d' ' -f1 # linux
# openssl md5 "$1" | grep -o '[[:xdigit:]][[:xdigit:]]*$' | cat
@CodeShane
CodeShane / jqcheatsheet.md
Last active November 22, 2018 21:44 — forked from talwrii/jqcheatsheet.md
jq cheatsheet

jq cheatsheet

Extract field from list of objects

jq 'map(.foo)'

[ { foo: 1 }, { foo: 2 } ]
[1, 2]
@CodeShane
CodeShane / s3.sh
Created July 13, 2017 19:51 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
<!DOCTYPE html>
<html>
<head><title>Javascript RT</title></head>
<style>canvas {width: 1280px; height: 768px}</style>
<body>
<canvas id="framebuffer"></canvas>
<script type="text/javascript">
/* Fizzlefade using a Feistel network.