Skip to content

Instantly share code, notes, and snippets.

View abyx's full-sized avatar

Aviv Ben-Yosef abyx

View GitHub Profile
let URLCache = NSURLCache(memoryCapacity: 4 * 1024 * 1024, diskCapacity: 25 * 1024 * 1024, diskPath: nil)
NSURLCache.setSharedURLCache(URLCache)
@abyx
abyx / evernote_exporter.applescript
Created October 1, 2015 07:17
Evernote exporter
#!/usr/bin/osascript
do shell script "open -a /Applications/Evernote.app"
delay 10 # Evernote is slooooooow
with timeout of (10 * 60) seconds
tell application "Evernote"
set allnotebooks to notebooks
repeat with anotebook in allnotebooks
set aname to name of anotebook
@abyx
abyx / angular-error-handling.js
Last active February 4, 2022 19:19
AngularJS HTTP Error Handling Mechanism
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
@abyx
abyx / Board.lua
Created June 7, 2012 05:14
Game of Life in Codea | Video available here http://www.youtube.com/watch?v=G5yg64joL-8
Board = class()
CELL_SIZE = 30
function Board:init(size)
self.grid = {}
for i = 1, size do
self.grid[i] = {}
for j = 1, size do
self.grid[i][j] = false
public void betterTest() throws Exception {
// Do some setup
// ...
final Exchanger<Exception> exchanger = new Exchanger<Exception>();
new Thread() {
@Override
public void run() {
Exception thrown = null;
<target name="compile" depends="compile-grammar">
<javac srcdir="${src}" destdir="${build}">
<classpath refid="classpath.base"/>
</javac>
</target>
<target name="compile-grammar" depends="-check_grammar_needs_compile"
if="grammarBuildRequired">
<java classname="org.antlr.Tool" failonerror="true">
<arg value="${grammar-file}"/>
commentor.should_receive(:add).with(anonymous_comment)
@abyx
abyx / gol.rb
Created January 31, 2012 06:36
Final exercise at Corey Haines' Improving Your TDD workshop
class Board
def initialize
@living = []
end
def evolve_dead_cells
end
def add_living_cell(location)
# When doing this:
class SomeError < Exception
def initialize(some, args); end
end
describe 'bad message' do
it 'raises an exception' do
obj = stub
obj.should_receive(:dude!).and_raise(SomeError)
Object.const_defined? :Integer
#=> true