Skip to content

Instantly share code, notes, and snippets.

@jayceekay
jayceekay / split_word.py
Last active June 7, 2016 20:38
find min number of splits such that every subword is a palindrome
def is_palindrome(word):
# should round down
limit = len(word) / 2
for i in xrange(limit):
if word[i] != word[limit - i - 1]:
return False
return True
def find_splits(word):
if is_palindrome(word):
@jayceekay
jayceekay / print_diag.py
Created June 7, 2016 18:27
print a 2d matrix diagonally
def print_diag(matrix):
h = len(matrix)
w = len(matrix[0])
x = 0
y = 0
anchor = 0
while True:
if x >= w or y < 0:
anchor += 1
@jayceekay
jayceekay / test_server.js
Created April 21, 2016 02:06
attempting to write an integration test for a simple loopback api
var assert = require('chai').assert;
var status = require('http-status');
var app = require('../server/server');
var request = require('supertest');
var boot = require('loopback-boot');
var DataSource = require('loopback-datasource-juggler').DataSource;
request = request('http://0.0.0.0:3000/api');
describe('Metrics resource', function() {
{
"always_show_minimap_viewport": true,
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": ".",
justin@arrakis:~ $ curl -L -A "Googlebot/2.1 (+http://www.google.com/bot.html)" http://www.jamespgannon.com
justin@arrakis:~ $ curl -L -A "justin" http://www.jamespgannon.com
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" lang="en-US">
<![endif]-->
class Person:
def __init__(self, name):
self.name = name
def get_name(self):
return self.name;
p = Person('justin')
print('p\'s name is {}.'.format(p.get_name()))