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
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 <george@lesica.com>
#
# 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
glesica / bootstrap-sile.sh
Last active Mar 21, 2017
Install dependencies for SILE on Ubuntu 16.04
View bootstrap-sile.sh
#!/bin/sh
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 keybase.md

Keybase proof

I hereby claim:

  • I am glesica on github.
  • I am glesica (https://keybase.io/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:

View units.exs
defmodule Units do
def add({x, :in}, {y, :in}), do: {x + y, :in}
def sub({x, :in}, {y, :in}), do: {x - y, :in}
end
Units.add({5, :in}, {4, :in})
@glesica
glesica / dynamic_pool.go
Created May 20, 2015
Dynamic pool that allows concurrency for a set of tasks to be throttled.
View dynamic_pool.go
package main
import "sync"
func main() {
jobChan := make(chan (chan int))
resChan := make(chan int)
squareGroup := new(sync.WaitGroup)
// The workers
@glesica
glesica / ratelimit.ex
Last active Aug 29, 2015
GenServer implementation that wraps a function in order to allow calls to be rate limited.
View ratelimit.ex
defmodule Auscrape.RateLimit do
use GenServer
use Timex
def start_link(fun, interval, opts \\ []) do
GenServer.start_link(__MODULE__, {fun, interval}, opts)
end
def call_fun(server, args) do
GenServer.call(server, {:call, args}, :infinity)
@glesica
glesica / units.jl
Last active Aug 29, 2015
Rudimentary implementation of units of measure in Julia.
View units.jl
import Base.show, Base.convert
abstract Unit
abstract ScalarUnit <: Unit
abstract CompoundUnit <: Unit
abstract LinearUnit <: ScalarUnit
macro defunit(name::Symbol, parent::Symbol)
@glesica
glesica / equality.py
Created Mar 11, 2015
Brief exploration of Python's magic methods for equality testing.
View equality.py
# Equality in Python
# When using custom types (classes) many programmers like to be able
# to use built-in concepts like "==" instead of something like
# "a.equals(b)". Generally it is only a good idea to do this if the
# concept you are implementing is conceptually the same as what the
# operator is normally used for. An example:
class Person1(object):
def __init__(self, name, age):
View simple_pool.go
package main
import "sync"
func main() {
jobChan := make(chan int)
resChan := make(chan int)
squareGroup := new(sync.WaitGroup)
// The workers
@glesica
glesica / pool.go
Created Jan 27, 2015
Simple example of a goroutine pool.
View pool.go
package main
import (
"fmt"
"sync"
)
func main() {
numbers := make(chan int, 10)
squares := make(chan int, 10)
You can’t perform that action at this time.