Skip to content

Instantly share code, notes, and snippets.

@twobob
twobob / InputEvents.cs
Created April 15, 2017 03:18 — forked from mstevenson/InputEvents.cs
Bind key presses to methods in Unity at runtime
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public delegate void InputKeyDelegate (KeyCode key);
public delegate void InputAxisDelegate (string name,float value);
public class InputEvents : MonoBehaviour
{
@twobob
twobob / Instruments.cs
Created April 15, 2017 03:18 — forked from mstevenson/Instruments.cs
Unity tool for measuring execution time
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Debugging tools
/// </summary>
public static class Instruments
{
static string stopwatchName;
@twobob
twobob / FindReferences.cs
Created April 15, 2017 03:18 — forked from mstevenson/FindReferences.cs
Find Unity objects that reference a selected asset
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class FindReferences : EditorWindow, ISerializationCallbackReceiver
{
List<string> displayedRefs = new List<string>();
@twobob
twobob / rules.cfg
Created April 30, 2017 04:29
Blocking spammy content providers and facebook stuffs via JSON enabled HOST DNS replacement
[
{
"Pattern": "^((.*\\.)*(fastly|1e100|akadns|phicdn|akamaiedge|yahoodns|nr-data|doubleclick|edgecastcdn|smaato|bidswitch|openx|mozaws)\\.net)$",
"Address": "127.0.0.1",
"NameServer": "127.0.0.1"
},
{
"Pattern": "^((.*\\.)*(akamaitechnologies|btrll|casalemedia|rfihub|lfstmedia|spotxchange|adsafeprotected|iasds01|tp-cdn|criteo|gstatic|adnxs|exelator|pubmatic|powerlinks|atgsvcs|imrworldwide|supersonicads|tapad|amazonaws)\\.com)$",
"Address": "127.0.0.1",
"NameServer": "127.0.0.1"
@twobob
twobob / clarifai_local_image_tagging.py
Last active May 20, 2017 18:44 — forked from devStepsize/clarifai_local_image_tagging.py
Local image tagging with Clarifai's Python client
import os
from os.path import expanduser
import glob
from clarifai import rest
from clarifai.client import ClarifaiApi
app = ClarifaiApi()
directory = expanduser('~/pictures/clarifai/')
txts=glob.glob1(directory, "*.tx?")
jpgs=glob.glob1(directory, "*.JPG")
txts = [suffix.replace('.JPG.txt', '.JPG') for suffix in txts]
@twobob
twobob / make_thumbs.py
Last active May 3, 2017 16:08
create thumbails for all JPG files in a folder as 128 128 JPEG files
import os, sys
import PythonMagick
from os.path import expanduser
import glob
import time
directory = expanduser('~\\pictures\\clarifai\\')
thumbsdirectory = expanduser('~\\pictures\\clarifai\\thumbs\\')
thumbs=glob.glob1(thumbsdirectory, "*.THUMB.JP?")
jpgs=glob.glob1(directory, "*.JPG")
thumbs = [suffix.replace('.THUMB.JPEG', '.JPG') for suffix in thumbs]
@twobob
twobob / keys_to_json.py
Created May 1, 2017 04:25
Create a JSON file from a list of txt files parsing the values
# -*- coding: utf-8 -*-
'''
where .JPG.txt AI tag files are like
Tags for IMG_3150.JPG (Tag - Probability)
child - 0.9972
fun - 0.9727
little - 0.9688
people - 0.9647
cute - 0.9637
et cetera
@twobob
twobob / gist:38e796de3aa42b2fd7d296394f3c9279
Created May 1, 2017 21:43
used IN a directory to reorient all files according to the exif data. Obviously YMMV
forfiles /C "cmd /c magick @file -auto-orient ./oriented/@file"
@twobob
twobob / loopy_n.cmd
Created May 1, 2017 21:53
loop n times over command
for /L %a in (1,1,2) do (python.exe %USERPROFILE%\AppData\Local\Programs\Python\Python36\claripy.py)
@twobob
twobob / crunchJPG.cmd
Created May 2, 2017 12:13
crunch jpg(s) with jpeg-recompress.exe
cd /d %USERPROFILE%\Pictures\clarifai\tiny && forfiles /C " cmd /c %USERPROFILE%\Downloads\jpeg-archive-2.1.1-win\jpeg-archive\jpeg-recompress.exe -q med -a -n 60 -x 85 -m smallfry -s @file @file "