Skip to content

Instantly share code, notes, and snippets.

View CodyKochmann's full-sized avatar

Cody Kochmann CodyKochmann

  • Severn, MD
View GitHub Profile
@CodyKochmann
CodyKochmann / generate_duplicate_name.py
Created May 17, 2015 06:51
python snipet that allows duplicate file generation
def generate_duplicate_name(f_name,output_path):
## snipet that allows duplicate file generation if need be
# by: Cody Kochmann
from os import listdir
if f_name in listdir(output_path):
if allow_duplicates == False:
v_print(f_name+" already downloaded")
return(False)
else:
placeholder_name=2
@CodyKochmann
CodyKochmann / pct_of_smaller_side.js
Created May 20, 2015 00:37
sizes a dom element to the smaller sized side
var pct_of_smaller_side = function(dom_e,selected_percent){
// sizes a dom element to the smaller sized side
var width = $(window).width();
var height = $(window).height();
var important_measurement=0;
if (width>height){
important_measurement=height*selected_percent;
} else {
important_measurement=width*selected_percent;
}
@CodyKochmann
CodyKochmann / set_view.js
Created May 20, 2015 00:46
sets horizontal or vertical view rules of a dom element
var set_view = function(dom_e){
// sets horizontal or vertical view rules of a dom element
// by: Cody Kochmann
var width = $(window).width();
var height = $(window).height();
var horizontal=width>height;
var vertical=!horizontal;
if (horizontal){
if(dom_e.hasClass('horizontal')==false){
dom_e.addClass('horizontal');
@CodyKochmann
CodyKochmann / timed_interval.coffee
Created June 12, 2015 17:00
An improved setInterval function with pausing and no overlapping of intervals.
window.timed_interval = (@main_process, @timeout, @verbose=true) ->
`/*
Author: Cody Kochmann
Build: 4
Date Last Modified: Fri Jun 12 09:53:37 PDT 2015
This is an improved function to the currently used setInterval in javascript.
It has better Controls towards the control flow of the interval overall.
This implementation also prevents function overlapping where is the interval
is set too quickly and tries to run again before the previous
@CodyKochmann
CodyKochmann / crypto.js
Created October 5, 2015 18:09
Simple wrapper around CryptoJS to make best practices in encryption simple and easier to remember. Example usage: Crypto.encrypt(secret_data,password) Crypto.decrypt(encrypted,password) Crypto.hash(password)
(function(){
/* CryptoJS v3.1.2 below */
var CryptoJS=CryptoJS||function(g,p){var e={},m=e.lib={},r=function(){},v=m.Base={extend:function(a){r.prototype=this;var d=new r;a&&d.mixIn(a);d.hasOwnProperty("init")||(d.init=function(){d.$super.init.apply(this,arguments)});d.init.prototype=d;d.$super=this;return d},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
u=m.WordArray=v.extend({init:function(a,d){a=this.words=a||[];this.sigBytes=d!=p?d:4*a.length},toString:function(a){return(a||x).stringify(this)},concat:function(a){var d=this.words,l=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var q=0;q<a;q++)d[b+q>>>2]|=(l[q>>>2]>>>24-q%4*8&255)<<24-(b+q)%4*8;else if(65535<l.length)for(q=0;q<a;q+=4)d[b+q>>>2]=l[q>>>2];else d.push.apply(d,l);this.sigBytes+=a;return this},clamp:fu
@CodyKochmann
CodyKochmann / secure-7z.sh
Created October 16, 2015 03:46
Easy sha256 bit encrytion archive for securing important files because the 7z command is generally hard to remember.
# easy sha256 bit encrytion archive for securing important files
7z a -mhe=on -p <archive-name>.7z <important-file-1> <important-file-2>
@CodyKochmann
CodyKochmann / gen-ssh-key.sh
Created October 16, 2015 16:34
Easy ssh key generator to keep best practices simple to type
echo "enter the key name." \
&& read keyname \
&& cd ~/.ssh \
&& ssh-keygen -b 4096 -t rsa -f $keyname
@CodyKochmann
CodyKochmann / basic-ufw-setup.sh
Last active October 16, 2015 16:47
This is the first command I run on a new ubuntu machine in order to set up a simple firewall allowing only exclusively what I want.
for i in outgoing incoming
do
ufw default deny $i
done
for i in ssh http https "out http" "out https" 1194/udp 53
do
ufw allow $i
done
&& ufw enable
@CodyKochmann
CodyKochmann / try-catch-block.sh
Created October 16, 2015 17:17
This is a try / catch block to make debugging scripts easier to make.
{ # try
} || { # catch
# print the error here
}
@CodyKochmann
CodyKochmann / make-swap-file.sh
Created October 17, 2015 03:28
quick generation of a swap file for ubuntu
fallocate -l 4G /swapfile \
&& chmod 600 /swapfile \
&& mkswap /swapfile \
&& swapon /swapfile \
&& echo "/swapfile none swap sw 0 0" >> /etc/fstab