Skip to content

Instantly share code, notes, and snippets.

View ubershmekel's full-sized avatar
🤙
What's a github status?

Yuval Greenfield ubershmekel

🤙
What's a github status?
View GitHub Profile
@ubershmekel
ubershmekel / CodeCollabReviewShellExtension.reg
Created January 18, 2017 00:27
Code Collaborator Code Review Shell Extension, start a review from a folder in windows explorer
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\ccollab]
@="CodeCollab Review"
"Icon"="\"C:\\Program Files\\Collaborator Client\\ccollab.exe\""
[HKEY_CLASSES_ROOT\Directory\shell\ccollab\command]
@="\"C:\\Program Files\\Collaborator Client\\ccollab.exe\" addchanges ask %V"
[HKEY_CLASSES_ROOT\Directory\Background\shell\ccollab]
@ubershmekel
ubershmekel / HtmlJsAlerts.html
Last active December 23, 2016 22:10
Just paste this (probably minify it first) and get red alerts at the bottom of the page when errors occur
<style>
/* This is my error handler to show myself and users when errors are happening */
/* See: https://gist.github.com/ubershmekel/66abb3987b116b4824201f9cd72e1dd9 /*
/* style from http://www.w3schools.com/howto/howto_js_snackbar.asp */
/* The snackbar - position it at the bottom and in the middle of the screen */
#snackAlertsContainer {
position: fixed; /* Sit on top of the screen */
z-index: 1; /* Add a z-index if needed */
bottom: 30px; /* 30px from the bottom */
width: 100%;
@ubershmekel
ubershmekel / TimeoutServer.py
Created October 18, 2016 23:29
Just for when you need a socket to always timeout
# Echo server program
import socket
import time
# Symbolic name meaning all available interfaces
HOST = ''
# Arbitrary non-privileged port
PORT = 18080
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
@ubershmekel
ubershmekel / ibeforeeexceptafterc.py
Created September 25, 2016 04:35
Counting how many times "I before E except after C" is correct
"""
Inspired by this bogus TIL: https://www.reddit.com/r/todayilearned/comments/54c05w/til_there_are_923_words_in_the_english_language/
Downloaded this corpus: https://sourceforge.net/projects/wordlist/files/SCOWL/2016.06.26/scowl-2016.06.26.zip/download?use_mirror=pilotfiber
From http://wordlist.aspell.net/
SCOWL (Spell Checker Oriented Word Lists)
The results of running this script are:
@ubershmekel
ubershmekel / mark_errors_bookmarklet.js
Created June 23, 2016 16:49
Bookmark this and all the instances of errors and warnings on the page will be highlighted
javascript:(function(){var s=document.createElement('script');s.src='https://cdnjs.cloudflare.com/ajax/libs/mark.js/7.0.0/mark.min.js';s.onload=function(){(new Mark(document.body)).mark(["err", "warn", "fail", "exception"])};document.head.appendChild(s);})()
@ubershmekel
ubershmekel / sorttables.js
Last active January 12, 2024 06:00
Sort tables bookmarklet
/*
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable
@ubershmekel
ubershmekel / example.py
Last active February 23, 2023 08:16
Windows python process that upon death windows will kill its subprocesses
import subproc
import time
subproc.Popen('calc')
print('now close this window and see calc closing itself')
while True:
time.sleep(1)
@ubershmekel
ubershmekel / generic_repr.py
Created October 27, 2015 17:32
Simple repr methods that allow you to reconstruct a simple object
"""
These two repr implementations make a "repr" that you can just drop into your class if it's a simple one.
"""
class A:
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return "%s(**%r)" % (self.__class__.__name__, self.__dict__)
import sys
import pprint
import json
import requests
base_url = 'http://localhost:9200'
INDEX_COUNT = 400
@ubershmekel
ubershmekel / debug_http_requests.py
Created August 30, 2015 16:37
This will cause the requests module to print out anything it's doing
"""
Thank you
http://stackoverflow.com/a/24588289/177498
"""
def debug():
import logging
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.