Skip to content

Instantly share code, notes, and snippets.

@thejambi
thejambi / PlayTak game to PTN Ninja
Last active January 5, 2021 00:18
PlayTak.com current game to PTN Ninja Bookmarklet
javascript: (function () {
var p1 = $('.player1-name:first').html(); var p2 = $('.player2-name:first').html(); var now = new Date(); var dt = (now.getYear()-100)+'.'+(now.getMonth()+1)+'.'+now.getDate()+' '+now.getHours()+'.'+getZero(now.getMinutes()); $('#download_notation').attr('download', p1+' vs '+p2+' '+dt+'.ptn'); var res=''; res += getHeader('Site', 'PlayTak.com'); res += getHeader('Date', '20'+(now.getYear()-100)+'.'+(now.getMonth()+1)+'.'+now.getDate()); res += getHeader('Player1', p1); res += getHeader('Player2', p2); res += getHeader('Size', board.size); res += getHeader('Result', board.result); res += '\r\n'; var count=1; $('#moveslist tr').each(function() { $('td', this).each(function() { var val = $(this).text(); res += val; if(count%3 === 0) res += '\r\n'; else res += ' '; count++; }) });
window.open('http://ptn.ninja/' + encodeURIComponent(res),'_blank');
}());
@thejambi
thejambi / point_in_polygon_using_winding_number.js
Created July 16, 2020 18:30 — forked from vlasky/point_in_polygon_using_winding_number.js
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on http://geomalgorithms.com/a03-_inclusion.html
function pointInPolygon(point, vs) {
var x = parseFloat(point[0]), y = parseFloat(point[1]);
var wn = 0;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = parseFloat(vs[i][0]), yi = parseFloat(vs[i][1]);
@thejambi
thejambi / FizzBuzz.java
Created December 11, 2012 02:18
Extended FizzBuzz
public static void main(String[] args) {
HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(3, "Fizz");
map.put(5, "Buzz");
map.put(7, "Pop");
for (int i = 1; i <= 100; i++) {
boolean special = false;
for (int j : map.keySet()) {