Skip to content

Instantly share code, notes, and snippets.

@misaxi
misaxi / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@misaxi
misaxi / jaccard.fs
Last active August 29, 2015 14:20
Jaccard Similarity F# http://en.wikipedia.org/wiki/Jaccard_index Good for fuzzy searching
let jaccard (a:string) (b:string) =
let set1 = Set.ofSeq a
let set2 = Set.ofSeq b
if Set.isEmpty set1 && Set.isEmpty set2
then
1.0
else
let i = Set.intersect set1 set2
let u = set1 + set2
(float)(Set.count i) / (float)(Set.count u)
@misaxi
misaxi / EventsCtrl.js
Created November 2, 2015 06:18
Ionic: using $ionicHistory to calm down the ion-nav-bar
angular
.module('app')
.config(config)
.controller('EventsCtrl', EventsCtrl)
function config ($stateProvider) {
$stateProvider
.state('tab.events', {
url: '/events',
cache: false,
@misaxi
misaxi / gulpfile.js
Last active November 9, 2015 22:14
gulp task error handling
gulp.task('sass', function () {
return gulp.src('./scss/ionic.app.scss')
.pipe(sass().on('error', onErrorResumeNext)) // the meat
.pipe(gulp.dest('./www/css/'))
})
function onErrorResumeNext (err) {
gutil.log(err) // logs the error for dianostics
this.emit('end') // ends the stream
}
function test () {
console.log('hello world')
}
function getPerimeter(matrix) {
let sum = 0;
for(let i = 0; i < matrix.length; i++) {
let row = matrix[i]
for(let j = 0; j < row.length; j++) {
if (isLand(matrix, i, j)) {
sum += 4;
if (isLand(matrix, i - 1, j)) {
sum--;
}