Skip to content

Instantly share code, notes, and snippets.

Setup remote git repo on EC2

Create a bare repository

$ mkdir <repo-name>.git
$ cd <repo-name>.git
$ git init --bare
@richardkall
richardkall / backup-db.sh
Last active October 12, 2015 04:17
Backup MySQL database to Amazon S3.
#!/bin/sh
# Dumps MySQL database to a file, uploads to S3 and rotates out old backups.
# Set correct dates
NOWDATE=`date +%Y-%m-%d`
LASTDATE=$(date +%Y-%m-%d --date='1 week ago')
DESTINATION=/var/backup
DB=

#Password-less SSH

Generate keys on local machine:

$ ssh-keygen

Create ~/.ssh directory on remote machine.

@richardkall
richardkall / nginx.conf
Last active December 16, 2015 07:18
Nginx + PHP5
charset utf-8;
gzip_disable "msie6";
gzip_types text/plain text/css application/x-javascript application/xml text/javascript;
# www.example.com
server {
listen 80;
server_name *.example.com;
rewrite ^(.*) http://example.com$1 permanent;
@richardkall
richardkall / LICENSE
Last active December 16, 2015 07:19
MIT License
The MIT License (MIT)
Copyright (c) Richard Käll <[email protected]> (richardkall.se)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@richardkall
richardkall / store.coffee
Last active December 3, 2023 22:08
Ember.js REST adapter without JSON root element.
App.Adapter = DS.RESTAdapter.extend
serializer: DS.RESTSerializer.extend
extract: (loader, json, type, record) ->
root = @rootForType(type)
// Embed JSON data in a new object with root element
newJSON = {}
newJSON[root] = json
json = newJSON
//
@richardkall
richardkall / rsync-exclude.sh
Last active April 17, 2016 14:24
Exclude files when using rsync
# Using .rsync-filter
$ rsync -avz --delete --exclude-from=".rsync-filter" -e "ssh" --rsync-path="sudo rsync" project/* [email protected]:/project
# Using pattern
$ rsync -avz --exclude=".DS_Store" -e "ssh" --rsync-path="sudo rsync" project/* [email protected]:/project
@richardkall
richardkall / nvm.sh
Last active April 17, 2016 14:21
Improve shell startup time by commenting out lines in nvm.sh (nvm 0.31.0). See https://github.com/creationix/nvm/issues/860.
# Node Version Manager
# Implemented as a POSIX-compliant function
# Should work on sh, dash, bash, ksh, zsh
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <[email protected]>
# with much bash help from Matthew Ranney
{ # this ensures the entire script is downloaded #
@richardkall
richardkall / Base16 Default Dark.terminal
Created September 11, 2016 08:03
OS X Terminal Color Schemes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECow
LjA4MjM1Mjk0MzcyIDAuMDgyMzUyOTQzNzIgMC4wODIzNTI5NDM3MgAQAYAC0hAREhNa
JGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFy
@richardkall
richardkall / wepack.config.js
Last active May 26, 2019 16:20
Webpack CSS loaders
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = (env = { production: false }) => ({
module: {
rules: [
{
test: /\.css$/,
use: [
...(env.production