Skip to content

Instantly share code, notes, and snippets.

Aviv Ben-Yosef abyx

Block or report user

Report or block abyx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cache.swift
let URLCache = NSURLCache(memoryCapacity: 4 * 1024 * 1024, diskCapacity: 25 * 1024 * 1024, diskPath: nil)
NSURLCache.setSharedURLCache(URLCache)
View evernote_exporter.applescript
#!/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 May 16, 2019
AngularJS HTTP Error Handling Mechanism
View angular-error-handling.js
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 Jun 7, 2012
Game of Life in Codea | Video available here http://www.youtube.com/watch?v=G5yg64joL-8
View Board.lua
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
View BetterTest.java
public void betterTest() throws Exception {
// Do some setup
// ...
final Exchanger<Exception> exchanger = new Exchanger<Exception>();
new Thread() {
@Override
public void run() {
Exception thrown = null;
View build.xml
<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}"/>
@abyx
abyx / gol.rb
Created Jan 31, 2012
Final exercise at Corey Haines' Improving Your TDD workshop
View gol.rb
class Board
def initialize
@living = []
end
def evolve_dead_cells
end
def add_living_cell(location)
View gist:1392238
# 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)
View const_lookup.rb
Object.const_defined? :Integer
#=> true
You can’t perform that action at this time.