Skip to content

Instantly share code, notes, and snippets.

View tsabat's full-sized avatar

Tim Sabat tsabat

View GitHub Profile
@tsabat
tsabat / fix.rb
Created April 4, 2013 21:31
fix to user subscription
if !subscription.nil?
$redis.set(redis_key, subscription.plan_id)
return subscription.plan_id
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "12_10"
config.vm.box_url = "http://goo.gl/wxdwM"
config.vm.network :hostonly, "33.33.33.10"
config.vm.customize ["modifyvm", :id, "--memory", 2048]
end
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks"]
chef.roles_path = "roles"
if ENV['CHEF_DEBUG']
chef.log_level = :debug
end
chef.data_bags_path = 'data_bags'
if ENV['CHEF_RUN']
chef.run_list = ['recipe[chef_solo]'] << ENV['CHEF_RUN'].split(',')
else

from inside the box, copy the symlinks:

mkdir /tmp/backup
sudo cp /etc/nginx/sites-enabled/* /tmp/backup

then install your service

then again, from inside your box:

Be sure you're running the homebrew version of mysql:

ps aux | grep mysql

The homebrew stuff will be in a Cellar directory.

edit /etc/my.cnf, adding:

@tsabat
tsabat / port_forward.md
Last active March 26, 2020 06:27
port forwarding bash script

We hide the services behind an AWS Security Group. But, we can use some trusty SSH action to forward localhost ports to those on the Solr server.

After you've added this to your ~/.zshrc or ~/.bash_profile and sourced (source ~/.bash_profile) it, you can forward these ports from localhost to your server like so:

portforward <hostname>

zsh and bash handle string splitting differently, so be sure to choose correctly for your shell.

str = 'Error on line number: 3. Invalid CSS after " test": expected "{", was ";"'
result = /line number: (\d+)/.match(str)[1]
@tsabat
tsabat / gist:5778287
Created June 13, 2013 23:27
passenger instructions
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-enterprise-server-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-enterprise-server-4.0.5
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Press ENTER to continue.
@tsabat
tsabat / remove.md
Created June 14, 2013 18:43
Function to remove line from known_hosts without vim, using sed, for Mac OSX

put this in your .zshrc and smoke it.

function known_host_remove() {
  sed -i .bak "$1 d" ~/.ssh/known_hosts
}
<?php
echo 'hi';
$str = '<iframe src="http://player.vimeo.com/video/68302803" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
$matches = preg_match('/player\.vimeo\.com\/video\/(\d+)/', $str, $arr);
if ($matches) {
echo $arr[1];
}
?>