Skip to content

Instantly share code, notes, and snippets.

View aeisenberg's full-sized avatar
:octocat:

Andrew Eisenberg aeisenberg

:octocat:
View GitHub Profile
@aeisenberg
aeisenberg / evernote.scpt
Last active December 10, 2015 14:48
Helping awsamuel out with some applescript and evernote integration.
global cleanText
-- set all variables to global [not sure whether this is needed, but it made the script run]
global noteList
global tempTags
global keepPhrase
global messageText
global newText
global theEverBody
global thisNote
global fileText
@aeisenberg
aeisenberg / PHP.scripted-completions
Created January 22, 2013 22:46
Simple Scripted completions for php files.
{
"scope": "source.php - variable.other.php",
"completions": [
"php",
{ "trigger": "abs", "contents": "abs(${1:number})" },
{ "trigger": "acos", "contents": "acos(${1:arg})" },
{ "trigger": "ternary", "contents": "${1:condition} ? ${2:then} : $0 " }
]
@aeisenberg
aeisenberg / PHP-variables.scripted-completions
Created January 22, 2013 22:48
simple completions using variables for scripted-completions
{
"scope": "source.php",
"completions": [
{ trigger: "What year is it?", contents: "It is ${year}." },
]
}
@aeisenberg
aeisenberg / PHP-template.scripted-completions
Last active December 11, 2015 12:18
A simple template for a scripted-completions file.
{
"scope": "source.php",
"completions": [
{ trigger: "if (surround with)",
contents: "if (${1:condition}) {\n\t${selection}\n}",
isTemplate: true}
]
}
@aeisenberg
aeisenberg / ClosureWriter.java
Created June 7, 2013 04:39
Where's the memory leak?
public class ClosureWriter {
protected interface UseExistingReference {}
public void writeClosure(ClosureExpression expression) {
// create some byte-code
// ...
expression.setNodeMetaData(ClosureWriter.UseExistingReference.class,Boolean.TRUE);
// do some more byte-code writing
@aeisenberg
aeisenberg / not_modular.html
Last active August 29, 2015 14:04
Angular apps are not modular
<!DOCTYPE html>
<html ng-app="parent">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js"
type="text/javascript"></script>
<script type="text/javascript">
angular.module('sub1', [])
.run(function(sub2Value) {
console.log(sub2Value);
@aeisenberg
aeisenberg / nested_scopes.html
Last active August 29, 2015 14:04
Nested scopes in angular behave strangely because of prototypal inheritance.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js"
type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module('watchingApp', [])
.controller('watchedController', function($scope) {
$scope.value = 9;
})
@aeisenberg
aeisenberg / nested_scopes2.html
Created August 1, 2014 20:33
Nested scopes in angular behave strangely because of prototypal inheritance.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module('watchingApp', [])
.controller('watchedController', function($scope) {
$scope.value = 9;
})
.directive('watching', function() {
@aeisenberg
aeisenberg / path-count.js
Last active May 15, 2016 03:01
Here is a generalized solution to the [path-counting brain teaser from Kahn Academy](https://www.khanacademy.org/math/math-for-fun-and-glory/puzzles/brain-teasers/v/3-d-path-counting-brain-teaser). You can run this in node passing the size and number of dimensions as arguments.
// argv: size, dims
'strict mode';
var size = process.argv[2];
var dims = process.argv[3];
var grid = initializeGrid(size, dims);
setValueAt(createArray(dims, 0), grid, 1);
var initialLoc = createArray(dims, size-1);
@aeisenberg
aeisenberg / evernote-migration.scpt
Created May 31, 2016 03:05
Use this apple script to migrate your files out of evernote and into notes.app.
tell application "Evernote"
set _Notebooks to every notebook
repeat with _NoteBook in _Notebooks
set _NoteBookName to name of _NoteBook
set _Notes to every note of _NoteBook