Skip to content

Instantly share code, notes, and snippets.

View NatoliChris's full-sized avatar

Chris Natoli NatoliChris

View GitHub Profile
@NatoliChris
NatoliChris / copy_aws_image.sh
Created July 20, 2020 06:05
Copy from AWS region
#!/bin/bash
# Copies the AWS image from one AZ to another.
# Parameters:
# 1) image name
# 2) from zone
# 3) to zone
# e.g. ./copy_aws_image rbbc-clean us-west-1 ap-northeast-2
if [[ $# -ne 3 ]]; then
#!/usr/bin/env python
from __future__ import print_function
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import hashes, hmac
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.backends import default_backend
import os

Keybase proof

I hereby claim:

  • I am natolichris on github.
  • I am natc (https://keybase.io/natc) on keybase.
  • I have a public key ASCcm1mNlLoPMcn89F1CJyHdgmBXKxtFDwhRyLSAvLEjHQo

To claim this, I am signing this object:

#!/usr/bin/env python3
import datetime
askday = datetime.date(2015, 12, 1)
rightnow = datetime.date.today()
days = rightnow.day - askday.day
months = (rightnow.year - askday.year)*12 + rightnow.month - askday.month
years = months / 12
months = months % 12
/*
* How to use cookies
* => check if cookie
* => Set cookie with expiry if necessary
* => Use cookie
* => Clear cookie if necessary
*/
function setCookie(key, value, expiryDays){
document.addEventListener("DOMContentLoaded", function(){
/*
* Working with colours
* Asking for a prompt -> changing the colours
*/
//first check if we can access localStorage
if(typeof(Storage) !== "undefined"){
//check that it is not NULL and that it exists
if(localStorage.background && localStorage.background !== "null"){
document.body.style.background = localStorage.background;
import XMonad
import XMonad.Actions.OnScreen
import XMonad.Actions.SpawnOn
import XMonad.Layout.Named
import XMonad.Layout.IM
import XMonad.Layout.Grid
import XMonad.Layout.PerWorkspace
import XMonad.Hooks.DynamicLog
import XMonad.Layout.NoBorders
import XMonad.Hooks.ManageDocks
@NatoliChris
NatoliChris / fileZipper.py
Last active August 29, 2015 14:08
Zips all the files in the list of arguments, the first argument is the name of the zip file [ e.g. python fileZipper.py fileszipped.zip file1 file2 file3 ]
#!/usr/bin/python
import sys, zipfile
print "Zipping Files"
zName = sys.argv[1]
zf = zipfile.ZipFile(zName, mode='w')
for i in xrange(len(sys.argv)):
if i == 0 or i == 1:
continue
else:
@NatoliChris
NatoliChris / PriorityQueue-Java.java
Created August 2, 2014 13:13
Priority Queue / Heap in Java
import java.util.ArrayList;
import java.util.Collections;
class PriorityQueueNode implements Comparable<PriorityQueueNode>{
public Integer key;
public Object value;
//Node constructor;
public PriorityQueueNode(Integer key, Object value){
this.key = key;
@NatoliChris
NatoliChris / BubbleSort.java
Created August 2, 2014 12:24
All different Sorts, implemented in JAVA
import java.util.List;
public class BubbleSort {
public static void sort(List<Integer> list){
int count = 0;
for(int iter = 0; iter < list.size()-1; iter++){
for(int i = 0; i < list.size()-iter-1; i++){ //taking out the already sorted part
if(list.get(i) > list.get(i+1)){
int temp = list.get(i);
list.set(i, list.get(i+1));