Skip to content

Instantly share code, notes, and snippets.

View julienma's full-sized avatar

Julien Ma julienma

View GitHub Profile
@julienma
julienma / #rails101.md
Last active December 19, 2015 16:59
Properly bootstrapping a new rails app, including RSpec + Spork + Foreman + Heroku

All these useful tips (and more!) taken from http://ruby.railstutorial.org/chapters/

This is based on Rails 3.2, but should work on Rails 4.0.

Create Rails app

(skip standard test unit and instead will use RSpec)

$ cd ~/rails_projects
# fetch @patio11's tweets from microconf (roughly apr 3 on)
# signature generated from https://dev.twitter.com/rest/reference/get/statuses/user_timeline
curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' --data 'count=200&screen_name=patio11&since_id=717036680947965953' --header 'Authorization: OAuth oauth_consumer_key="x6nmC5cEByCeyudJjVKsMA", oauth_nonce="56b83cf5f068e31996fc484364e99423", oauth_signature="0vY6VEDKTI2Bb8J09osG0yqTA6M%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1460264255", oauth_token="49019793-1cje0xH21w4OsEudjSXTIj1hDQhorGifIrfuBQ0Eb", oauth_version="1.0"' --verbose > tweets.json
# import into postgres
psql -d test -c "CREATE TABLE pgtweets (data json)"
psql -d test -c "COPY pgtweets FROM '$(pwd)/tweets.json'"
# total activity over these 200 tweets
@julienma
julienma / rsync-1-liner.sh
Created April 4, 2016 22:45
rsync big folders from one server to another, with custom port and RSA key.
rsync -e 'ssh -p 12345 -i ~/.ssh/id_custom_rsa' --stats --progress -vaz ~/local-folder julien@host.com:~/remote-folder
@julienma
julienma / download_latest_pgbackup_from_heroku.sh
Last active August 4, 2016 20:23
Download latest Postgres backup for an Heroku app. Based on latest Heroku's `pg:backups`.
#!/bin/bash
#
# Download latest PG backup for an Heroku app.
# See https://devcenter.heroku.com/articles/heroku-postgres-backups#downloading-your-backups
#
# Usage:
# Don't forget to chmod +x the script, then:
#
# $ ./download_latest_pgbackup_from_heroku.sh {HEROKU_APPNAME}
#
@julienma
julienma / private.xml
Created July 21, 2016 02:39
Karabiner modifier for Logitech K811 Keyboard: [EJECT] will do next/previous tracks.
<?xml version="1.0"?>
<root>
<deviceproductdef>
<productname>LOGITECH_K811</productname>
<productid>0xb317</productid>
</deviceproductdef>
<item>
<name>Logitech K811 Eject to Next / Previous Tracks</name>
@julienma
julienma / Git tricks.txt
Last active January 19, 2017 18:22
Collection of useful OSX commands.
### Move a directory out of an existing repo, and push it to its own repo, keeping only relevant commits:
See http://teach.github.com/articles/lesson-filter-branch/
@julienma
julienma / update-wordpress.sh
Created July 7, 2018 12:53
Script to update Wordpress FR and deploy via git push (like Heroku/Dokku)
#!/bin/bash
#
# Don't forget to `chmod +x update-wordpress.sh`
#
# Updates WordPress to a new version.
#
# The MIT License (MIT)
# Copyright (c) 2016 Sander Venema <sander@sandervenema.ch>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@julienma
julienma / add - new omnifocus task.scpt
Last active September 23, 2018 08:41
DO Note to Omnifocus inbox
(*
Author: Julien Ma - https://github.com/julienma
This script creates a new task in Omnifocus inbox, parsing a text file's content to create the task.
I use it to quickly create tasks from Android, using IFTTT's DO Note widget.
Installation (on the computer where you use Omnifocus):
- Setup this IFTTT applet: https://ifttt.com/applets/47483145d-send-to-omnifocus
(Basically a DO Note to a Dropbox folder, with the note as the file content)
- Put a copy of the script in /Library/Scripts/Folder Action Scripts or ~/Library/Scripts/Folder Action Scripts.