Skip to content

Instantly share code, notes, and snippets.

@multidis
multidis / ubuntu_nodejs_install.sh
Last active December 23, 2015 01:34
Node.js providing `node` and `npm` commands on Ubuntu 14.04.
# use Node.js-maintained repositories
# http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
# update npm
sudo npm install --global npm@latest
# verify
node --version
@multidis
multidis / brother_setup_ubuntu.md
Created September 26, 2015 00:35
Brother printer/scanner setup on Ubuntu computer as IP printer/scanner.

Setup

Detailed instructions at Brother Linux page.

To change IP address of previously configured scanner

Edit (root priviledges) /opt/brother/scanner/brscan4/brsanenetdevice4.cfg file (could be called slightly differently, see the output of dpkg -l | grep Brother as described in Brother scanner instructions.

Verify updated settings with brsaneconfig4 -q | grep SCANNER.

@multidis
multidis / itbit_test_keys.py
Last active September 15, 2015 17:29
ItBit REST API example: list wallets for the user account. Testing API keys.
## itBit private API
## https://github.com/itbit/itbit-restapi-python/blob/master/example.py
from itbit_api import itBitApiConnection
import json
# private API keys
with open('exchange_private.json') as f:
exchdata = json.load(f)
ticksymb = exchdata['ticker']
client_key = exchdata['client_key']
@multidis
multidis / docker_cp_host_to_container.sh
Created September 5, 2015 01:40
File copy workaround from host to docker container (`docker cp` works from container to host, not other way around).
#https://forums.docker.com/t/will-docker-cp-command-work-for-copying-files-from-host-to-a-container/2022/2
cat /local/file/path | docker exec -i <running-container-id> sh -c 'cat > /inside/docker/file/path'
@multidis
multidis / 10_julia_pmap_funarray.jl
Last active August 29, 2015 14:25
Parallel processing of a list of functions with `pmap`. Start Julia session with e.g. `julia -p 4`.
## keep in mind @everywhere
a = Array(Function, 5)
# example function to generate closures for a-elements
@everywhere fpo(x::Float64, n::Int64) = x^n
# function that will be applied to each element of a
@everywhere bb(f::Function) = f(2.0)
@multidis
multidis / julia_fun_optarg_vararg.jl
Last active October 12, 2015 23:31
Optional arguments and vararg-functions in Julia: a collection of what is not immediately obvious in the docs.
# optional arguments are collected as an array, not dictionary
ff(a, b; optargs...) = optargs
aa = ff(2, 3, u=1, z="qq")
#2-element Array{Any,1}:
# (:u,1)
# (:z,"qq")
# can add only (Symbol, Any) tuples in that array
push!(aa, (:newarg, 95.8))
@multidis
multidis / aws_s3_ls.sh
Last active March 22, 2024 07:30
List of files in a specific AWS S3 location in a shell script.
#!/bin/bash
# setup AWS CLI first
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html
# configure AWS CLI (e.g. use IAM role for S3 access)
export AWS_DEFAULT_REGION=us-east-1
export AWS_ACCESS_KEY_ID=IDHERE
export AWS_SECRET_ACCESS_KEY=KeyHere
@multidis
multidis / Dockerfile
Last active September 15, 2021 12:24
Cron job scheduling inside a Docker container.
# phusion baseimage initiates cron properly
# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/baseimage:0.9.16
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
@multidis
multidis / aws_s3_simple.py
Last active August 29, 2015 14:19
Simple way of working with files in S3 bucket in Python. For more complex operations use boto.
## https://www.smore.com/labs/tinys3/
## http://stackoverflow.com/questions/25602415/upload-to-amazon-s3-using-tinys3
import tinys3
# access credentials: make create user for s3 read or full access
# can restrict to a specific bucket if needed as well
access_key = 'keyhere'
secret_key = 'secrethere'
@multidis
multidis / gcloud_sdk_docker_setup.sh
Last active August 29, 2015 14:18
Development environment setup with Google Cloud SDK + Docker for Google App Engine custom runtime Virtual Machine. Tested on Ubuntu 12.04. NOTE: not using VirtualBox, using native local Docker process instead.
# Linux docker for App Engine without VirtualBox
# http://stackoverflow.com/questions/27118022/how-to-use-gcloud-preview-app-run-without-boot2docker
# add to /etc/default/docker:
# DOCKER_OPTS="-d -H unix:///var/run/docker.sock -H tcp://localhost:2375"
# apply the change:
sudo service docker restart
# add to ~/.bashrc:
export DOCKER_HOST=tcp://localhost:2375
# verify in new shell