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 / censor_ascii.py
Created May 26, 2013 16:50
Censor out ascii art, made for Candy Box
import pprint
import os
from collections import Counter
ascii_markers = "|\\/_\" ()n"
def ascii_prob(line):
line = line.strip()
"""
Data from
http://en.wikipedia.org/wiki/CPU_socket#List_of_80x86_sockets_and_slots
copy pasted html to excel, copy pasted excel to python
ran python
pasted output to excel, drew a graph
There's probably a simpler way to do a pivot table but I don't know how.
var origin = function () {
// IE10 Doesn't have window.location.origin :(
if (!window.location.origin) {
var port = window.location.port ? ':' + window.location.port : '';
return window.location.protocol + "//" + window.location.hostname + port;
} else {
return window.location.origin;
}
}
@ubershmekel
ubershmekel / volume
Last active April 11, 2016 01:32
Control volume on an alsamixer in ubuntu from the command line
#!/usr/bin/python
"""
Control volume on an alsamixer in ubuntu from the command line using python-alsaaudio
Written for Crouton Chromebooks to have easy hotkeys for their volume control in ubuntu.
https://github.com/dnschneid/crouton/wiki/Keyboard
usage:
@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 / 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 / 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 / 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 / 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 / concat.py
Created January 22, 2017 23:06
Concatenate a few video files into one with ffmpeg
"""
Concatenate a few video files into one with ffmpeg
Use a wild card
"""
import subprocess
import glob
import re
to_concat = 'robocar*'