Skip to content

Instantly share code, notes, and snippets.

@leostera
leostera / gist:3535568
Created August 30, 2012 17:58
Selenium WebDriver Python Bindings and Facebook Login
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
usr = ""
pwd = ""
driver = webdriver.Firefox()
# or you can use Chrome(executable_path="/usr/bin/chromedriver")
driver.get("http://www.facebook.org")
assert "Facebook" in driver.title
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@def-
def- / example.nim
Last active November 15, 2018 00:28
Reading a single character with Nim
import getch
let ch = getch()
echo ch
@hasherezade
hasherezade / brainfuck.l
Created May 28, 2015 18:28
BrainfuckToC (Flex & Bison)
%{
#include "brainfuck.tab.h"
#include <string.h>
#include <stdlib.h>
void error()
{
fprintf(stdout, "Plik niepoprawny pod wzglêdem leksykalnym. Linia: %d\n", yylineno);
exit(1);
}
@josyb
josyb / dynconn.py
Last active October 9, 2018 09:23
Exploring improved structural design - Part 1
'''
Created on 29 Dec 2015
@author: Josy
'''
from __future__ import print_function
import random
import myhdl
@josyb
josyb / oo.md
Last active November 20, 2022 10:07
Object Oriented Design in MyHDL

There is a web-page where Adam Taylor lists 10 alternative FPGA development languages: http://www.eetimes.com/document.asp?doc_id=1329857 On some languages the OO-word was used ... I commented that the only thing I have seen so far from these languages is that they are (truly) class based but that I haven't seen any real example. Yet, as I did not study them to their deepest extent, having not enough time and too much other work ...

I already use class-based design for my MyHDL work, see my gist https://gist.github.com/josyb/afd84c9a06fdec77f2fd, but this is not OO as none of these classes have been subclassed.

In stead of doing some real work today (Sat Oct 22nd 2016), I decided to give OO in MyHDL a try. You can see the results in the two next files.

def sample_gumbel(shape, eps=1e-20):
"""Sample from Gumbel(0, 1)"""
U = tf.random_uniform(shape,minval=0,maxval=1)
return -tf.log(-tf.log(U + eps) + eps)
def gumbel_softmax_sample(logits, temperature):
""" Draw a sample from the Gumbel-Softmax distribution"""
y = logits + sample_gumbel(tf.shape(logits))
return tf.nn.softmax( y / temperature)
from lasagne.nonlinearities import *
from lasagne.layers import Layer
class SpatialSoftmaxLayer(Layer):
"""
Softmax layer that computes the softmax over pixels in the same location,
i.e., over the channel axis. This layer will automatically use the CuDNN
version of this softmax if it is available.
Parameters
@mshkrebtan
mshkrebtan / webex-ubuntu.md
Last active October 28, 2022 15:23
Run Cisco Webex on 64-bit Ubuntu 16.04

Run Cisco Webex on 64-bit Ubuntu 16.04

With Audio and Screen Sharing Enabled

Enable support for 32-bit executables

Add the i386 architecture to the list of dpkg architectures :

sudo dpkg --add-architecture i386
@kevinzakka
kevinzakka / data_loader.py
Last active April 19, 2024 23:42
Train, Validation and Test Split for torchvision Datasets
"""
Create train, valid, test iterators for CIFAR-10 [1].
Easily extended to MNIST, CIFAR-100 and Imagenet.
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
"""
import torch
import numpy as np