Skip to content

Instantly share code, notes, and snippets.

View sajoku's full-sized avatar
🏠
Working from home

Sander sajoku

🏠
Working from home
View GitHub Profile
@sajoku
sajoku / testflight.sh
Created June 14, 2017 05:17 — forked from keith/testflight.sh
Upload an ipa to testflight using altool
#!/bin/bash
set -e
set -u
altool="$(dirname "$(xcode-select -p)")/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool"
ipa="path/to/foo.ipa"
echo "Validating app..."
time "$altool" --validate-app --type ios --file "$ipa" --username "$ITC_USER" --password "$ITC_PASSWORD"
@sajoku
sajoku / setup-vmware-image-with-static-IP.markdown
Created July 3, 2017 11:33 — forked from pjkelly/setup-vmware-image-with-static-IP.markdown
VMWare Fusion Images with a static IP Address on Mac OS X Snow Leopard

How to setup your VMWare Fusion images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base a

@sajoku
sajoku / post.md
Created September 25, 2017 14:56 — forked from bag-man/post.md
fzf + rgrep + vim mini tutorial

I've always had fzf and ripgrep on my radar, and I've finally gotten around to using them together. Good lord it makes a world of difference, especially when added to Vim as well as Bash.

Add the following snippet to your ~/.bashrc, this add's fzf keybindings to bash and gets fzf to use ripgrep by default for faster searching.

[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!.git/*"'
bind -x '"\C-p": vim $(fzf);'

Okay now what can you do?

@sajoku
sajoku / nginx.conf
Created November 15, 2017 19:20 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@sajoku
sajoku / forms.py
Created February 9, 2018 07:49 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@sajoku
sajoku / active_tag.py
Created February 16, 2018 13:30 — forked from mnazim/active_tag.py
(Django) A simple template tag to add an 'active' class to anchor tags
from django import template
from django.core.urlresolvers import reverse
register = template.Library()
@register.simple_tag
def add_active(request, name, by_path=False):
""" Return the string 'active' current request.path is same as name
Keyword aruguments:
@sajoku
sajoku / readme.md
Created October 19, 2018 07:04
Roomy bootstrap 4 table with border spacing

This creates a roomy table with borders around it. The important stuff here is the border-spacing and border-collapse. border-collaps: 0px 5px; -> 0px means the spacing between the cells (left and right), 5px is the spacing between the rows.

@sajoku
sajoku / base_set.py
Created November 27, 2018 12:07
Immediate evaluation of a QuerySet vs lazy
# This way executes two queries because if not evaluates the base_set argument
def execute_query(base_set=None):
if not base_set: # Eecutes the queryset thrown in
base_set = YourObject.objects
base_set.filter(pk=1) #this is where the queryset should be executed
# Checking with is None does not evaulate the given base_set
def execute_query(base_set=None):
if base_set is None: # Does not execute the given queryset.
@sajoku
sajoku / .vimrc
Created March 5, 2019 09:57
Local vimrc to run rails test inside docker
"Sometimes I want to run stuff in a docker-container like rails tests. With this local .vimrc that's configurable per project
" This 'overrides' the rails executable command and replaces it with docker-compose.
" Drawback is that it takes a bit of time to run docker
let g:test#ruby#rails#executable = 'docker-compose run web bin/rails test'
@sajoku
sajoku / pipenv_install.sh
Created April 24, 2019 17:18
Pipenv install offline
# pipenv allows us to install packages straight from source but only
# when providing a location to the wheel
#pipenv install file:///home/packages/packages/aioredis-1.2.0-py3-none-any.whl
packages_directory='/home/packages/packages/'
packages=(aioredis asgiref asn1crypto async-timeout attrs autobahn automat cffi channels-redis channels constantly cryptography daphne django-redis django-reversion django-webpack-loader django h2 hiredis hpack hyperframe hyperlink idna incremental msgpack priority psycopg2-binary psycopg2 py-moneyed pyasn1-modules pyasn1 pycparser pyhamcrest pyopenssl pytz redis restless selenium service-identity six sqlparse twisted[http2,tls] txaio urllib3 uwsgi whitenoise zope.interface)
for package in ${packages[@]}
do
package_location=$(find "$packages_directory" -print | grep -i "$package")
echo "Found package: $package in location: $package_location"