Using the -ldflags
parameter can help set variable values at compile time.
Using the example provided here:
- Running
make build
will create abuild
executable. Running it will result in:
$> ./build
no version (Mon YYYY)
$>
package fun | |
// bufferedSequence | |
type bufferedSeq struct { | |
seq Seq // original Seq | |
buf *[]float64 // shared slice | |
pos int // this pos | |
} | |
// Next implements Seq interface |
set nocompatible " Use Vim defaults (much better!) | |
set bs=2 " allow backspacing over everything in insert mode | |
set ai " always set autoindenting on | |
set backup " keep a backup file | |
set viminfo='20,\"50 " read/write a .viminfo file, don't store more | |
" than 50 lines of registers | |
set history=50 " keep 50 lines of command line history | |
" 000328 from article in Linux Journal, Apr 2000 | |
set incsearch " searches as you enter the string! | |
set ignorecase " Ignore case in searching for matches set smartcase " Ignore case ONLY if all lower case srch str |
#!/bin/bash | |
# args | |
host=$1 | |
shift | |
prefix=$1 | |
shift | |
# from=$1 | |
# shift | |
# to=$1 |
# suffix characters (base 32, sort of) | |
SUFFIX_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" | |
def id18(s: str, *, check_suffix: bool = False) -> str: | |
""" | |
Converts a 15 character Salesforce ID (s) to its 18 character version. | |
If the ID provided has length 18 and check_suffix is True, we will assert | |
that the suffix is correct! |
package stack | |
import ( | |
"reflect" | |
"sync" | |
) | |
// Stack implements Push & Pop | |
type Stack interface { | |
Push(interface{}) |
Using the -ldflags
parameter can help set variable values at compile time.
Using the example provided here:
make build
will create a build
executable. Running it will result in:$> ./build
no version (Mon YYYY)
$>
package aoc | |
import ( | |
"errors" | |
"reflect" | |
) | |
// rotate rotates the values of a slice by rotate positions, preserving the | |
// rotated values by wrapping them around the slice | |
func rotate(slice interface{}, rotate int) error { |
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
""" | |
Learning me some context managers | |
""" | |
# NOTE: see also: contextlib.contextmanager | |
class Context(object): |
#!/usr/bin/env python | |
# encoding: utf-8 | |
from __future__ import print_function | |
import time | |
from multiprocessing import cpu_count | |
from multiprocessing.pool import ThreadPool | |
import requests |
from urllib.parse import urlencode, urlparse | |
def build_url(base: str, *path, qparams: dict=None, trail_slash: bool=False) -> str: | |
''' | |
As close to a generic URL builder for G-API as possible | |
Assumption(s): | |
1. base is a valid URL with an `https` scheme and a valid `netloc` | |
2. path is a variable number of path arguments |