Skip to content

Instantly share code, notes, and snippets.

View spg's full-sized avatar

Simon-Pierre Gingras spg

View GitHub Profile
@spg
spg / gist:872cb9376bb0e954948e
Created September 2, 2015 18:31
bug when running py.test on qutebrowser
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/_pytest/config.py", line 543, in importconftest
mod = conftestpath.pyimport()
File "/usr/local/lib/python2.7/site-packages/py/_path/local.py", line 641, in pyimport
__import__(modname)
File "/Users/spg/qutebrowser/tests/conftest.py", line 32, in <module>
import helpers.stubs as stubsmod
ImportError: No module named stubs
ERROR: could not load /Users/spg/qutebrowser/tests/conftest.py
@spg
spg / gist:700f5b62ce9c28019fdd
Created July 1, 2015 14:43
gevent: Pool with greenlets that raise
import gevent.monkey
gevent.monkey.patch_all()
import gevent.pool
def raiseifmod3(n):
if n % 3 == 0:
print n
FROM phusion/baseimage:0.9.16
RUN apt-get update && apt-get install -y \
build-essential \
libreadline-gplv2-dev \
libncursesw5-dev \
libssl-dev \
libsqlite3-dev \
tk-dev libgdbm-dev \
libc6-dev libbz2-dev
@spg
spg / gist:1f22a1d4c3dafc23d67d
Last active August 29, 2015 14:15
Exception handling example
// MyActionHandler throws an exception. Note that we're throwing a custom exception
public class MyActionHandler extends AbstractAction<MyAction, MyActionResult> {
@Override
public MyActionResult execute(MyAction action, ExecutionContext context) throws ActionException {
if (somethingGoesWrong()) {
throw new MyCustomException("This is my custom message");
}
// everything ok
@spg
spg / gist:bc3758be72dc606427d4
Created September 25, 2014 15:26
Using Ultra Dev Mode
Enable the new Super dev mode.
Guys I'm using locally for one week now, the snapshot of GWT 2.7.0 in my projects. This (nightly) snapshot contains the new development improving the super dev mode. The super dev mode now does a compilation "per file" and each time you hint the button compile, it recompiles only the modified files if any. So you need less than 1 or 2 seconds to recompile the application!!! (the first compilation takes the same time than before)
And in the near future, you won't have to click on the compile button, the super dev mode will recompile your application on the fly.
To enable it, modify your maven pom files:
- use this version of GWT
<gwt.version>2.7.0-SNAPSHOT</gwt.version>
@spg
spg / gist:9375514
Created March 5, 2014 20:07
Chosen hack for typeahead
ChosenOptions chosenOptions = new ChosenOptions().setNoResultsText("No results");
final ChosenListBox chosenListBox = new ChosenListBox(false, chosenOptions);
chosenListBox.setWidth("300px");
chosenListBox.addAttachHandler(new AttachEvent.Handler() {
@Override
public void onAttachOrDetach(AttachEvent event) {
if (event.isAttached()) {
$("input", container).keyup(new Function() {
@spg
spg / gist:9195021
Created February 24, 2014 19:21
Editor
import javax.inject.Inject;
import com.escribehost.charts.client.application.widget.DrugInteractionDto;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.LabelElement;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.SimpleBeanEditorDriver;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@spg
spg / ctor
Created February 14, 2014 21:18
// A)
@Inject
HomePresenter(EventBus eventBus,
MyView view,
MyProxy proxy,
MedsPresenter medsPresenter) {
super(eventBus, view, proxy, ChartsPresenter.SLOT_CHARTS_MODULE);
ClassLoader classLoader = HttpRequestBase.class.getClassLoader();
System.out.println(classLoader.getResource("org/apache/http/client/methods/HttpRequestBase.class"));
List<String> DAYS = Arrays.asList("Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
TextCell textCell = new TextCell();
// Create a CellList that uses the cell.
CellList<String> cellList = new CellList<String>(textCell);
// Set the total row count. This isn't strictly necessary, but it affects
// paging calculations, so its good habit to keep the row count up to date.
cellList.setRowCount(DAYS.size(), true);