Skip to content

Instantly share code, notes, and snippets.

View AnnaMag's full-sized avatar

AnnaMag

View GitHub Profile
@AnnaMag
AnnaMag / get_crackle_pop.py
Last active January 6, 2016 19:34
Printing numbers
#! /usr/bin/env python
"""
Toy code for a very special application:)
Write a program that prints out the numbers 1 to 100 (inclusive). If the number is divisible by 3, print Crackle
instead of the number. If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop.
"""
def print_crackle_pop(max_no):
x = range(1, max_no + 1)
return ['CracklePop' if (i % 3 == 0 and i % 5 == 0) else 'Crackle' if not (i % 3) else 'Pop' if not (i % 5) else i for i in x]
@AnnaMag
AnnaMag / DP_reg.py
Last active January 20, 2016 21:26
Computational geometry + geo-computations: polyline simplification, convex hulls
#!/usr/bin/python
"""
Created on Mon Jan 17 2016
Anna M. Kedzierska
Python3 implementation of the Douglas-Peucker algorithm for polyline simplification
"""
from functools import singledispatch
from functools import reduce
@AnnaMag
AnnaMag / convex_hull_Melkman.py
Last active January 25, 2016 18:45
test whether a point is inside a polygon represented by a deque + full Melkman's convex hull algorithm
#! /usr/bin/env python3
"""
Created on Sun Jan 24 2016
Anna M. Kedzierska
"""
import matplotlib.pyplot as plt
import numpy as np
import collections
import math
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AnnaMag
AnnaMag / fill_text.py
Created April 27, 2016 20:13
graphical experiments1
colors = ximport( "colors" )
font( "Courier", 350 )
align( CENTER )
text_path_line = textpath( "PURA VIDA", 0, 200, width = WIDTH)
resx = 200
resy = 80
rx = 2.0
ry = 1.5
@AnnaMag
AnnaMag / keybase.md
Created May 19, 2016 19:38
encryption

Keybase proof

I hereby claim:

  • I am AnnaMag on github.
  • I am amk (https://keybase.io/amk) on keybase.
  • I have a public key whose fingerprint is 5C68 832F 118E CB69 87C4 8A11 A289 C432 AF46 6FA8

To claim this, I am signing this object:

var snap = require("./js/snap.svg-min.js");
var under = require("./js/underscore-min.js");
function getRandom (weights, values) {
var num = Math.random(),
s = 0,
lastIndex = weights.length - 1;
for (var i = 0; i < lastIndex; ++i) {
s += weights[i];
if (num < s) {
@AnnaMag
AnnaMag / test-vm-unchanged-global.js
Created December 28, 2016 20:48
Node.js doc: Outside of scripts run by the vm module, "global variables" will remain unchanged.
const util = require('util');
const vm = require('vm');
var globalVar = 3;
const sandbox = { globalVar: 1 };
vm.createContext(sandbox);
vm.runInContext('globalVar *= 2;', sandbox);
@AnnaMag
AnnaMag / helpers.cc
Last active July 15, 2019 05:59
Helper functions for printing V8 Local-wrapped objects
#include "v8.h"
#include "helpers.h"
#include <iostream>
using v8::Local;
using v8::String;
using v8::Array;
void PrintLocalString(v8::Local<v8::String> key){
@AnnaMag
AnnaMag / test-vm-accessor-props.js
Created December 28, 2016 21:25
Test for changes in the Node.js's Copy Properties (accessor property check)
'use strict';
require('../common');
const vm = require('vm');
const assert = require('assert');
var x = { value : 13};
Object.defineProperty(x, 'p0', {value : 12});
Object.defineProperty(x, 'p1', {
set : function(value) { this.value = value; },
get : function() { return this.value; },