Skip to content

Instantly share code, notes, and snippets.

View vladborovtsov's full-sized avatar
🎯
Focusing

Vlad Borovtsov vladborovtsov

🎯
Focusing
View GitHub Profile
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@vladborovtsov
vladborovtsov / randombrightuicolor.m
Created May 22, 2015 13:34
Random bright UIColor
- (UIColor *) randomBrightColor {
UIColor *c = nil;
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
c = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1.0f];
return c;
}
@vladborovtsov
vladborovtsov / elb-nodejs-ws.md
Created January 20, 2016 04:45 — forked from obolton/elb-nodejs-ws.md
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@vladborovtsov
vladborovtsov / explain.py
Created April 29, 2016 09:18 — forked from allixsenos/explain.py
Django QuerySet Explain
from django.db import connections
from django.db.models.query import QuerySet
from __future__ import print_function
class QuerySetExplainMixin:
def explain(self, analyze=True):
cursor = connections[self.db].cursor()
print(self.query)
print()
sql, params = self.query.sql_with_params()
@vladborovtsov
vladborovtsov / extractGifs.py
Created May 3, 2016 13:22 — forked from revolunet/extractGifs.py
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@vladborovtsov
vladborovtsov / godaddy-ssl-howto
Created May 24, 2016 09:02 — forked from ideaoforder/godaddy-ssl-howto
GoDaddy + Nginx SSL
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
http://support.godaddy.com/help/article/3601/generating-a-certificate-signing-request-nginx
http://support.godaddy.com/help/article/4976/rekeying-an-ssl-certificate
# Be sure to remember to chain them!
cat gd_bundle-g2-g1.crt >> yourdomain.crt
# Move 'em
sudo mv yourdomain.crt /etc/ssl/certs/yourdomain.crt
@vladborovtsov
vladborovtsov / s3.sh
Created July 17, 2016 11:30 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1

#MongoDB 3.2.x Replica Sets on AWS EC2 A MongoDB replica set provides a mechanism to allow for a reliable database services. The basic replica set consists of three servers, a primary, a secondary and an arbitrator. The primary and secondary both hold a copy of the data. The arbitrator is normally a low spec server which just monitors the other servers and help with the failover process. In production, there can be more than three servers.

To setup mongo as a replica set on Amazon Web Services EC2 you need to first setup a security group with ssh on port 22 and mongodb on port 27017. You then need to create three servers. Select Ubuntu 14.04 LTS x64 and a micro (or bigger depending on your database size, ideally you should have enough memory to match your database size) instance for the primary and secondary and a nano instance for the arbitrator.

##Adjust the File System on each Server The operating system by default will update the last access time on a file. In a high data throughput database application

@vladborovtsov
vladborovtsov / mongodb.conf
Created July 29, 2016 10:04 — forked from ehazlett/mongodb.conf
MongoDB supervisor config
[program:mongodb]
command=/opt/mongodb/bin/mongod --dbpath /storage/mongodb_data --rest
directory=/opt/mongodb
user=root
autostart=false