Skip to content

Instantly share code, notes, and snippets.

View kyl191's full-sized avatar

Kyle Lexmond kyl191

View GitHub Profile
@kyl191
kyl191 / wp_compare.py
Created February 26, 2015 13:49
Wordpress post comparison
# Compares 2 WP post tables to find published posts with the same name but different content
# Used after merging an old WP install into an existing one
import csv, difflib, hashlib, sys
file = open(1, encoding='utf-8')
main = [row for row in csv.reader(file)]
file = open(2, encoding='utf-8')
xen = [row for row in csv.reader(file)]
# There is no doubt a better way to do this using difflib, but I did this before finding out about it
main_posts = {}
@kyl191
kyl191 / gist:442455bfd47fa8603ba2
Created February 3, 2015 06:40
password hasher for ansible
# Securely generate a hash for ansible
# don't paste the password into code at any point in time
from __future__ import print_function
from passlib.hash import sha256_crypt
from getpass import getpass
pw = getpass()
print(sha256_crypt.encrypt(pw))
@kyl191
kyl191 / inventory.py
Created January 18, 2015 06:36
Python Inventory file for Ansible
#!/usr/bin/python
from __future__ import print_function
import json
overarch = {}
overarch["us"] = [
"kc.example.com",
"la.example.net",
]
overarch["germany"] = ["de.test.net"]
import hashlib, os, sys, re
from os.path import join, getsize
def sha512file(file):
sha512 = hashlib.sha512()
try:
f = open(file,"rb")
except IOError:
print("IO Error, unable to open file", file)
while True:
def ary(p):
f = [0]
i = 1
j = 0
while i < len(p):
if p[i] == p[j]:
f.append(j+1)
i = i + 1
j = j + 1
elif j > 0:
@kyl191
kyl191 / Q2.asm
Created October 22, 2013 04:13
ECE222 Midterm Practice
MOV r0, #0
LDR r1, =N; N is label in memory, assuming it's +/- 4096
MOV r2, #0; r2 is the counter
LOOP; just a label
MUL r3, r2, r2; i * i
ADD r0, r0, r3; total += i*i
ADD r2, r2, #1; i++
CMP r2, r1; break out of loop when i = N
BNE LOOP
今天我发现你的javascript想一个中文字是一个ASCII字。
所以我现在用中文写比较多的东西。
但是,我没有特别好的东西写。
所以我希望你会以为写中文是一个非常独特的东西。
Translated, it's:
Today I found out your javascript code is thinking one chinese character is equivalent to one standard ASCII character.
So I'm using Chinese to write more than I would otherwise be able to.
Unfortunately, I can't think of anything really interesting to write.
So I'm hoping you will think writing Chinese is a very unique thing.
@kyl191
kyl191 / marmoset_submit.sh
Last active October 12, 2015 16:37
Modified version of marmoset_submit to automagically add a tag in git when submitting, and push the tag to github
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: marmoset_submit course project file [...]"
exit 1
fi
if [ $# -eq 3 ]; then
zip "$3" >& /dev/null
if [ $? -eq 12 ]; then
/u8/cs_build/bin/marmoset_submit "$@"
exit 0;
@kyl191
kyl191 / triangles.c
Created October 19, 2012 16:07
Triangles - finding angles between lines.
#include <stdio.h>
#include <math.h>
#include <assert.h>
//c99 removed M_PI, so check if it's defined, if not, define it
#ifndef M_PI
#define M_PI acos(-1.0)
#endif
void triangles(double a, double b, double h){
@kyl191
kyl191 / filenames.py
Created May 12, 2012 17:22
Dropquest 2012 Chapter 1 Counting
for x in [3,4,6]:
if x == 3:
y = 8
z = 4
if x == 4:
y = 6
z = 3
if x == 6:
y = 4
z = 2