Skip to content

Instantly share code, notes, and snippets.

View lincank's full-sized avatar
🎯
Focusing

lincank

🎯
Focusing
View GitHub Profile
@lincank
lincank / ghost1
Created August 16, 2016 08:28 — forked from vbtechsupport/ghost1
ghost.centminmod.com CentOS 6.4 init.d startup script configured for per Ghost install instance + clearing Nginx proxy_cache on restart. http://ghost.centminmod.com/ghost-blog-node-js-init-startup-script/
#!/bin/bash
###########################################
# chkconfig: 2345 98 02
#
# description: PM2 next gen process manager for Node.js
# processname: ghost1
#
### BEGIN INIT INFO
# Provides: ghost1
# Required-Start:
@lincank
lincank / 0_reuse_code.js
Created March 2, 2016 09:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lincank
lincank / resolve_appstore.sh
Created December 25, 2015 08:03
reset hanging App Store download or installation on Mac
rm -r ~/Library/Caches/storeinappd
rm -r ~/Library/Caches/storedownloadd
rm -r ~/Library/Caches/storeassetd
rm -r ~/Library/Caches/storeaccountd
rm -r $TMPDIR../C/com.apple.appstore
rm -r /private/var/folders/*/*/*/com.apple.appstore
rm -r ~/Library/Caches/com.apple.appstore
rm -r ~/Library/Saved\ Application\ State/com.apple.appstore.savedState
rm ~/Library/Preferences/com.apple.appstore.plist
@lincank
lincank / gist:a2be8bd8e23acd646fce
Created November 14, 2015 14:25 — forked from ynaoto/gist:5228280
Install 'mosh' to CentOS 6
rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install mosh –enablerepo=epel
@lincank
lincank / backup.sh
Last active December 17, 2015 18:29
Backup with rsync
#!/bin/bash
export PATH=$PATH:/usr/bin:/usr/local/bin
mysqldump -uname -ppasswd db_name > /data/backup/backup_`date +%F`.sql
# Remove backups older than 15 days
find /data/backup/ -maxdepth 1 -mtime +15 -delete
# backup to remote server
@lincank
lincank / ftp_sync.sh
Created May 24, 2013 18:39
FTP sync with lftp
#!/bin/bash
HOST='web_host'
USER='foo'
PASS='pwd'
TARGETFOLDER='www'
SOURCEFOLDER='/path/to/something'
lftp -f "
open $HOST
user $USER $PASS
@lincank
lincank / User.rb
Created March 7, 2013 15:45
A possible good practice for cancan gem
# encoding: utf-8
class User < ActiveRecord::Base
# roles for authorization for "cancan" gem, each user can have more than one roles,
# the abilities that this user own, are the union of all roles it has
# ability definition located in models/ability.rb
def roles
roles = ["guest"]
if self.new_record?
@lincank
lincank / extract.r
Last active December 14, 2015 15:09
extract values from xls files
# JDK required, install jdk on mac with:
# R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
require(xlsx)
#file <- system.file("/tmp/", "cobbdoug.xlsx", package = "xlsx")
wb <- loadWorkbook("/tmp/cobbdoug.xlsx")
sheets <- getSheets(wb) # get all sheets
sheet <- sheets[['cobbdoug.xls']] # get sheet with name "cobbdoug.xls"
rows <- getRows(sheet)
cells <- getCells(rows, colIndex=2)
@lincank
lincank / gist:5012243
Last active December 14, 2015 02:18 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

#Steps to install RVM + Ruby 1.9.3 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Todo get up to date repo's
# Install git and curl, if not already installed
sudo yum install git
sudo yum install curl-devel
# Create the rvm group and add any users who will be using rvm to the group
sudo su -