Skip to content

Instantly share code, notes, and snippets.

View gustaflindqvist's full-sized avatar
🚴‍♂️
Focusing

Gustaf Lindqvist gustaflindqvist

🚴‍♂️
Focusing
View GitHub Profile
@gustaflindqvist
gustaflindqvist / install_postgis_osx.sh
Created September 4, 2017 21:45 — forked from juniorz/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@gustaflindqvist
gustaflindqvist / ci.sh
Created April 6, 2017 07:56 — forked from devn/ci.sh
Simple continuous deployment via Jenkins and Capistrano for all branches. Wire this up with Github post receive hooks from Jenkins for best results.
#!/bin/bash -x
# This should be your "script/ci" checked into version control, and then wired as your sole build step in Jenkins.
#
# Simplifying Assumptions:
#
# * You build all branches
# * You want to deploy all branches.
# * You wired up an SSH key to your CI server appropriately so it can talk to your deployment target(s) via Cap
@gustaflindqvist
gustaflindqvist / sticky.js
Created December 16, 2016 13:11 — forked from javierarques/sticky.js
Sticky Sideabr With Vanilla Javascript. Detects scroll and set fixed the element. Live example: http://codepen.io/javiarques/pen/vKdgjR
// Sticky Nav Component
var Sticky = (function() {
'use strict';
var CSS_CLASS_ACTIVE = 'is-fixed';
var Sticky = {
element: null,
position: 0,
addEvents: function() {
webpack --display-modules | awk '{print $3$4" "$2}' | grep -v bytes | sort -n | tail -100
@gustaflindqvist
gustaflindqvist / media-queries.scss
Created June 30, 2016 09:15 — forked from chrisjlee/media-queries.scss
All Media Queries breakpoints
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }
@gustaflindqvist
gustaflindqvist / sv.yml
Last active August 29, 2015 14:15 — forked from lindblom/sv.yml
# Det måste vara en tom rad här av någon anledning :)
sv:
date:
formats:
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"
day_names: [Söndag, Måndag, Tisdag, Onsdag, Torsdag, Fredag, Lördag]
abbr_day_names: [Sön, Mån, Tis, Ons, Tors, Fre, Lör]

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
class ActiveRecord::Base
def can_destroy?
self.class.reflect_on_all_associations.all? do |assoc|
assoc.options[:dependent] != :restrict || (assoc.macro == :has_one && self.send(assoc.name).nil?) || (assoc.macro == :has_many && self.send(assoc.name).empty?)
end
end
end
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one