Skip to content

Instantly share code, notes, and snippets.

View t27's full-sized avatar

Tarang Shah t27

View GitHub Profile
@t27
t27 / screen-commands.sh
Created July 8, 2018 15:06
Generally useful GNU Screen commands - Especially on cloud compute instances
## Start/Resume a named screen
# -L enables logging
# -d detaches the screen if there is an existing screen attached
# -r resumes the the screen if it exists
screen -d -r -L <sessName>
## See all open screens
screen -ls
## To detach from a screen
@t27
t27 / render_json_jupyter_collapsible.py
Last active February 5, 2024 18:40
Render JSON as a collapsible field in jupyter notebooks - Updated - Also includes instructions for interleaving with print statements
## Add this to the first block in your note book
import uuid
from IPython.core.display import display, HTML
import json
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict):
self.json_str = json.dumps(json_data)
@t27
t27 / external-img-to-inlinebase64.js
Last active February 3, 2018 20:17
Converts all the external images in a webpage to inline base64 format - which makes it easier to then "Save" the whole document without worrying about missing images
// Convert all img tags to use base64 src
function toDataUrl(url, elem) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
//callback(reader.result);
elem.src = reader.result
}
reader.readAsDataURL(xhr.response);
@t27
t27 / git-tag-update.sh
Created February 3, 2018 20:12
Move a git tag on an older commit to a newer commit
#!/bin/bash
# usage
# > ./git-tag-update.sh <tagname>
TAGNAME=$1
git push --delete origin $TAGNAME # Deletes old tag from the server
git tag --delete $TAGNAME # Delete the old tag from local branch
git tag $TAGNAME # add the tag to the latest commit
git push --tags # persist tags to the server
@t27
t27 / docker.sh
Created February 3, 2018 20:07
Virtual Linux docker for compiling apps etc.
# run this command to create the docker container
docker run \
--name ubuntuDev \ #containername
-e HOST_IP=$(ifconfig en0 | awk '/ *inet /{print $2}') \ #map the system and container Its, helpful for dev
-v ~/Code:/Code \ #mount the local directory on the container
-t -i \
ubuntu:14.04 /bin/bash
# This created a container called ubuntuDev using the 'ubuntu:14.04' image from docker hub and runs bash interactively.
# -e ensures your networks are mapped correctly
@t27
t27 / runner.py
Created June 13, 2017 10:02
Run a command continously (Reloads a command/program if it crashes)
#!/usr/bin/env python
import signal
import sys
import os
import subprocess
process = 0
if len(sys.argv[:])<2:
print "USAGE: python runner.py \"<your execution statement>\" \nQuotes are only necessary of you want to do redirection or something like that"
else:
import time
from threading import Thread
def myfunc(i):
print "sleeping 5 sec from thread %d" % i
time.sleep(5)
print "finished sleeping from thread %d" % i
for i in range(10):
t = Thread(target=myfunc, args=(i,))
@t27
t27 / OpenCV-Tesseract.md
Last active March 9, 2021 21:42
Converting OpenCV Mat to Tesseract Compatible formats

I was primarily using the JavaCPP presets for OpenCV(JavaCV) and Tesseract

But I also found some references for C++

Here's what works for C++

#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>    
#include 
@t27
t27 / itemlist.md
Last active March 2, 2017 08:43
Items available

Hardware Items Available

BLDC Motors


@t27
t27 / juhi.ino
Created January 18, 2017 11:27
SparkleSkirt arduino
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303.h>
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321);
// mess with this number to adjust TWINklitude :)
// lower number = more sensitive
#define MOVE_THRESHOLD 45