Skip to content

Instantly share code, notes, and snippets.

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--;
}
function test () {
console.log('hello world')
}
@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
}
@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 / 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 / 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 / web.config
Created September 28, 2014 10:20
web.config for IIS hosted multi-site WordPress
<!-- http://lauragentry.com/blog/2010/07/30/how-to-create-a-wordpress-3-0-multisite-network-on-a-windows-server-using-sub-directories/ -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>
// export to GLOBAL.config so the test code
// can access your settings. i.e. login detail
GLOBAL.config = module.exports.config = {
login: {
username: 'admin',
password: 'adminpwd'
},
AddOwnerPage = require 'Pages/AddOwnerPage'
ViewOwnerPage = require 'Pages/ViewOwnerPage'
TestHelper = require 'Utils/TestHelper'
TestHelper.doAfterLogin 'owner', (it) ->
it 'should be created', ->
# test logics here
AddOwnerPage = require 'Pages/AddOwnerPage'
ViewOwnerPage = require 'Pages/ViewOwnerPage'
TestHelper = require 'Utils/TestHelper'
describe 'owner', ->
# login before each test starts
beforeEach ->
new LoginPage().loginToPt()
# logout after each test finishes