Skip to content

Instantly share code, notes, and snippets.

View tfaris's full-sized avatar

Tom Faris tfaris

  • NicheVision Inc.
  • Akron,OH
View GitHub Profile
@tfaris
tfaris / gist:2797a487f29155077389
Created May 5, 2014 20:35
IronPython progressbar
from bootstrap import AX
from System.Windows.Forms import *
from System.Drawing import *
import threading
import time
# Create the form
f = Form()
f.Size = Size(500, 200)
@tfaris
tfaris / gist:ff8c828229ce30fbd65d
Created July 23, 2014 21:32
Get value of __version__ attribute from a python module file
import re
s = open('C:/ProgramData/Nichevision Forensics/ArmedXpert/plugins/reports/mixture_combinations_report.py').read()
m = re.search('__version__\s*=(.*)\s?', s)
if m.groups():
v = m.groups()[0].replace("'", "").replace('"', '').strip()
print v
import requests
import time
from pyquery import PyQuery
SLEEP_TIME = 60 * 5
SERVICES = (
'SocialandGaming',
'XboxLiveCoreServices',
'PurchaseandContentUsage',
@tfaris
tfaris / printJsonDiff.js
Last active December 1, 2015 22:42
Javascript function that logs JSON changes (not additions or deletions) found using http://tlrobinson.net/projects/javascript-fun/jsondiff to the console.
function printJsonDiff(ch){
for (var i in ch){
var el = ch[i],
header;
if (el.parentNode.parentNode.firstChild.firstElementChild && el.parentNode.parentNode.firstChild.firstElementChild.innerText === "(array)"){
header = el.parentNode.parentNode.parentNode.parentNode.firstChild.innerText + " :: " + el.parentNode.parentNode.firstChild.innerText;
}
else{
header = el.parentNode.parentNode.firstChild.innerText;
}
@tfaris
tfaris / textareaVisualMargin.html
Created April 2, 2013 05:53
Vertical printer margin visual aid for textareas, position-able by specifying the column to "draw" at. Done entirely with CSS positioning and jQuery - no images.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<style>
.container{
position:relative;
left:0;
top:0;
}
textarea{
@tfaris
tfaris / gist:5673562
Last active December 17, 2015 21:19
SpreadsheetGear Dropdown
# To add a dropdown
dd_range = sheet.Range[0, 0]
shape = sheet.Shapes.AddFormControl(SpreadsheetGear.Shapes.FormControlType.DropDown,
sheet.WindowInfo.ColumnToPoints(dd_range.Column), # left
sheet.WindowInfo.RowToPoints(dd_range.Row), # top
width_in_points, # width
height_in_points) # height
# all the measurements above are in POINTS rather than row/column. I forget the calculations exactly.. there are
# conversions from columns/rows to points as seen above
shape.ControlFormat.AddItem("some string")
@tfaris
tfaris / unblock_file.py
Created September 28, 2016 22:06
[ArmedXpert Plugin] Programmatically Unblock a file that has been downloaded from the internet
"""
Removes the NTFS file stream that indicates that a file has been
downloaded from the internet untrusted zone.
Requires clrtype.py library (see https://raw.githubusercontent.com/IronLanguages/main/master/Languages/IronPython/Samples/ClrType/clrtype.py).
"""
import sys
import os
import clr
import clrtype
@tfaris
tfaris / retrain_example.sh
Last active February 7, 2017 06:45
Tensorflow+Inception transfer learning
# Might be missing some steps... putting this together as I go
docker run -it tensorflow/tensorflow bash
###
apt-get update
apt-get install python-virtualenv nano
mkdir ~/src && cd ~/src
virtualenv tensorflow_retrain
source ./tensorflow_retrain/bin/activate
@tfaris
tfaris / ArmedXpertRunArbitrarySQL.py
Created October 18, 2017 19:46
[ArmedXpert] One method for running an arbitrary SQL SELECT query using the ArmedXpert plugin editor.
editor.ClearLog()
import clr
clr.AddReference('System.Data.SQLite')
from nichevision.forensics.armedxpert.dnada.datalayer import Database
from System.Data.SQLite import SQLiteCommand
cmd = SQLiteCommand("select * from AlleleCombination", Database.SharedDatasource.Connection)
reader = cmd.ExecuteReader()
@tfaris
tfaris / load_osiris_oar.py
Created October 25, 2017 18:34
[ArmedXpert Plugin] Load an osiris .oar or .oer file
from nichevision.forensics.armedxpert.SampleSource import SampleSourceOSIRISOER
src = SampleSourceOSIRISOER(
r"filepath.oar",
True)
src.BeginLoadingSource(False)
for sample in src.AllEntries:
print sample.SampleName