Skip to content

Instantly share code, notes, and snippets.

View ryantbrown's full-sized avatar

Ryan Brown ryantbrown

  • GRIN
  • Sacramento, CA
View GitHub Profile
@ryantbrown
ryantbrown / blank-vagrant-ubuntu-box.rb
Last active August 29, 2015 14:17
vagrant-blank-ubuntu-box.rb
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'devbox'
config.vm.network "private_network", ip: "10.4.4.58"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 443, host: 44300
# mysql
config.vm.network "forwarded_port", guest: 3306, host: 33060
@ryantbrown
ryantbrown / rails-nginx-site-config.txt
Created March 26, 2015 05:57
Vagrant / Rails / Nginx / Site Config
# create app file
sudo vim /etc/nginx/sites-available/appname
# insert server block in app file
server {
listen 80 default_server;
server_name www.mydomain.com;
passenger_enabled on;
passenger_app_env development;
root /vagrant/appname/public;
@ryantbrown
ryantbrown / postgres-admin.txt
Last active August 29, 2015 14:17
Postgres Administration
# command line:
sudo -u postgres createuser --superuser username
sudo -u postgres createdb -O vagrant dbname
# enter shell
psql dbname username
# list users:
\du
#list databases:
\list
@ryantbrown
ryantbrown / gulp-zip.js
Created March 22, 2015 23:08
Node: Create Zip File with Gulp
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')(); // Load all gulp plugins
// automatically and attach
// them to the `plugins` object
var runSequence = require('run-sequence'); // Temporary solution until gulp 4
// https://github.com/gulpjs/gulp/issues/355
@ryantbrown
ryantbrown / laravel-5-dynamic-events.php
Last active December 10, 2019 00:24
Laravel 5: Dynamic Events
<?php
// creating new event handlers by extending Handler and
// store them in a "Handlers" directory to be read by
// the service provider, which will loop through the
// directory and Event::subscribe to each one.
// Make sure you prefix each handler method with
// "on" (ex: onUserRegister) as only these methods
// will be listened for.
@ryantbrown
ryantbrown / anyobject-to-int.swift
Created March 8, 2015 06:11
Swift: Downcast AnyObject to Int
func didReceiveCredit(creditInfo: [NSObject:AnyObject]!) {
// the following does not work
var amount: Int = creditInfo["credits"]! as Int
// nor does this
var amount: Int = Int(creditInfo["credits"]! as NSNumber)
// but this does
var amount: String = creditInfo["credits"]! as String
@ryantbrown
ryantbrown / sprite.swift
Created February 15, 2015 05:17
Working with sprite nodes in swift
// create image sprite
let img = SKSpriteNode(imageNamed:"ImageName");
// scale the image
img.xScale = 0.5;
img.yScale = 0.5;
// set the image position
img.position = CGPoint(x: 100, y: 100);
@ryantbrown
ryantbrown / label.swift
Created February 15, 2015 04:11
Create a label in swift
// new label node
let lbl = SKLabelNode()
// set label props
lbl.text = "POLYGON";
lbl.fontSize = 20;
// set label position
lbl.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMaxY(self.frame)-30);
// add to frame
@ryantbrown
ryantbrown / gulpfile.js
Last active August 29, 2015 14:08
Laravel Elixir Starter Gulpfile
// paths
var combine_dir = 'resources/assets';
var build_dir = 'resources/assets/build';
var less_file = 'main';
var less_output = combine_dir + '/css';
// set scripts to combine
var scripts = [
'vendor/jquery/jquery.js',
'js/main.js'
@ryantbrown
ryantbrown / magento-add-attribute-option.php
Last active April 10, 2016 07:24
Magento - Add attribute option
<?php
function addAttributeOption($attribute_code, $attribute_value) {
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;
$attribute_code = $attribute_model->getIdByCode('catalog_product', $attribute_code);
$attribute = $attribute_model->load($attribute_code);