Skip to content

Instantly share code, notes, and snippets.

George Lesica glesica

Block or report user

Report or block glesica

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
glesica /
Last active Aug 17, 2019
A quick shell script that will automatically update a Linux HOSTS file to block ads and malicious domains.
#!/usr/bin/env sh
# Filename:
# Author: George Lesica <>
# Description: Replaces the HOSTS file with a customized version that blocks
# domains that serve ads and malicious software, creating a backup of the old
# file.
glesica / swgo.bash
Created Mar 27, 2018
Switch Go (swgo): A very simple and intensely opinionated Go version manager
View swgo.bash
# Switch Go (swgo)
# A very simple and intensely opinionated Go version manager.
# Author: George Lesica <>
# To use, create a file called ".swgo" in any project directory.
# Inside of this file, set two variables: GOROOT_ and GOPATH_
# to the values you want assigned to GOROOT and GOPATH,
# respectively. Then, while in that directory, just run "swgo"
# and your GOROOT, GOPATH, and PATH will be updated accordingly.
glesica /
Created Apr 20, 2013
Simple drawing example using Pycairo.
from math import pi
from cairo import SVGSurface, Context, Matrix
WIDTH = 6 * 72
HEIGHT = 4 * 72
s = SVGSurface('example1.svg', WIDTH, HEIGHT)
c = Context(s)
# Transform to normal cartesian coordinate system
glesica /
Last active Mar 21, 2017
Install dependencies for SILE on Ubuntu 16.04
sudo apt-get install libharfbuzz-dev libfreetype6-dev libfontconfig-dev lua5.1 lua-lpeg-dev lua-expat-dev lua-zlib-dev lua-filesystem-dev liblua5.1-0-dev
View convolution.r
convolution <- function(A, B) {
# Computes the convolution of two vectors.
# Args:
# A, B: column vectors representing polynomial coefficients.
# Returns:
# The coefficient vector resulting from multiplying the polynomial
# represented by A by the polynomial represented by B.
Ap <- c(A, B*0)

Keybase proof

I hereby claim:

  • I am glesica on github.
  • I am glesica ( on keybase.
  • I have a public key whose fingerprint is 4378 8FCD 8E05 A920 2EA7 71DE E23B F398 FEBF A545

To claim this, I am signing this object:

Contouring using the Marching Squares algorithm.
George Lesica
from cairo import SVGSurface, Context
WIDTH = 8 * 72.0
HEIGHT = 8 * 72.0
glesica / contour.jl
Created Sep 17, 2013
Contouring algorithm in Julia.
View contour.jl
# contour(A, v)
# Implements the Marching Squares contouring algorithm (see:
# for details). The
# matrix `A` is an m x n scalar field and the scalar `v` is the
# value to be contoured. The return value is an (m-1) x (n-1) matrix
# of contour line type indices (see the Wikipedia article).
# TODO: Implement in parallel
function contour(A, v)
rows, cols = size(A)
glesica / sentiment.r
Created Feb 24, 2013
A really simple sentiment analysis function implemented in R that illustrates some of the nifty features of the R language.
View sentiment.r
sentiment <- function(str, words, weights=NULL) {
if (is.null(weights)) {
weights <- rep(1, length(words))
if (length(words) != length(weights)) {
stop('Length of words and weights not equal')
str.wts <- rep(0, length(str))
View perceptron.r
perceptron <- function(x, y, w, a, verbose=F) {
# Uses the Perceptron algorithm to find a weight vector that
# satisfies the given data.
# Args:
# x: an m by n matrix representing the data under study
# y: objective vector of m elements
# w: initial guess for the weight vector, n elements
# a: learning rate, should be in (0,1]
# verbose: echo information w at each iteration (default: False)
You can’t perform that action at this time.