Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
lyoshenka / print-table-ascii.php
Last active August 29, 2015 13:58
Print data from an array as an ASCII table. Pad all the data so it lines up nicely. WARNING: assumes that each datum (table row) has the same exact keys.
<?php
function printTable($data, $columnNames = [])
{
if (!$data || !is_array($data))
{
return;
}
$columns = getColumnsAndMaxLengths($columnNames ? array_merge($data, [$columnNames]) : $data);

Keybase proof

I hereby claim:

  • I am lyoshenka on github.
  • I am lyoshenka (https://keybase.io/lyoshenka) on keybase.
  • I have a public key whose fingerprint is DC91 BD1E 06C4 01D7 AA36 8ADF E78F F016 2B0D 303D

To claim this, I am signing this object:

@lyoshenka
lyoshenka / .gitconfig
Last active August 29, 2015 13:59
my current git config
[user]
name = Alex Grintsvayg
email = lyoshenka@gmail.com
[color]
diff = auto
status = auto
branch = auto
ui = auto
[core]
autocrlf = input
#!/usr/bin/env bash
if [ $EUID -ne 0 ]; then
echo "You must be root: \"sudo ngxvhost\""
exit 1
fi
# May need to run this as sudo!
# I have it in /usr/local/bin and run command 'ngxvhost' from anywhere, using sudo.

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain

@lyoshenka
lyoshenka / redshift.conf
Last active August 29, 2015 14:00
Upstart script for Redshift (http://jonls.dk/redshift/)
# Redshift upstart script
#
# IMPORTANT: you have to specify your lat/lng manually, or redshift won't start. Either put
# it in your config file or pass it explicitly
#
description "Redshift"
start on runlevel [2345]
stop on runlevel [!2345]
@lyoshenka
lyoshenka / santa.php
Last active August 29, 2015 14:00
Script to send out secret santa assignments
#!/usr/bin/php
<?php
// santa file has the following format
//
// name1 email1@mail.com
// another name email2@mail.com
// etc...
$myEmail= 'YOUR EMAIL HERE';
@lyoshenka
lyoshenka / email-ping.py
Last active August 29, 2015 14:04
Sends an email to your account that you want Gmail to check more frequently. Run this in cron for a week or two.
#!/usr/bin/env python
# for crontab
# */5 9-22 * * * /home/grin/bin/cronic /usr/bin/python /home/grin/email-ping.py
# */15 23,0-8 * * * /home/grin/bin/cronic /usr/bin/python /home/grin/email-ping.py
import smtplib, time, sys
from email.mime.text import MIMEText
from_email = ''
@lyoshenka
lyoshenka / safe.md
Last active August 29, 2015 14:04
My summary of SAFE terms

Note: I am not a lawyer. This is my simple understanding in layman's terms.

What is a SAFE?

A SAFE is an agreement between you and a company that lets you buy company stock at a specific price when a specific event occurs.

Price

When the specified event occurs, you get company stock. The amount of stock you get is equal to the price you paid for the SAFE divided by your personal price per share. Your price per share is the same price that everyone else gets, possibly modified by a valuation cap or a discount.

@lyoshenka
lyoshenka / aws_s3_public_bucket_policy.json
Last active August 29, 2015 14:04
Make your whole S3 bucket publicly readable
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::BUCKETNAME/*"]
}]
}