Skip to content

Instantly share code, notes, and snippets.

View matthaliski's full-sized avatar
🏠
Building stuff.

Matt Haliski matthaliski

🏠
Building stuff.
View GitHub Profile
@matthaliski
matthaliski / arraysandlists.md
Last active August 13, 2020 15:01
Note about Arrays

Arrays and Lists

Arrays

Arrays are a little bit different in c# than they are in most other languages and they basically suck. Main reason: they're fixed length. In order to make an array longer you basically have to copy the contents of the old array into a newer, longer array that also has a fixed length.

There are a few instances where arrays may be slightly more performant, but the c# community seems to favor lists for almost all occasions.

@matthaliski
matthaliski / post.rb
Last active January 18, 2016 22:42
Editing a form using fields_for in Rails
# app/models/post.rb
class Post < ActiveRecord::Base
has_many :tags, dependent: :destroy
# Enable the building of complex forms
accepts_nested_attributes_for :tags, allow_destroy: true
end
@matthaliski
matthaliski / foobar.rb
Created January 10, 2016 23:25
Foobar
# I am a ruby comment
def foobar(param)
puts param
end

Gems

Rails-related Gems and guides to accelerate your web project.

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generat
@matthaliski
matthaliski / 0_reuse_code.js
Last active August 29, 2015 14:07
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
@matthaliski
matthaliski / gist:419faf08c77d258d4224
Created September 29, 2014 14:42
Fix for -> PG::Error: ERROR: duplicate key value violates unique constraint
# 'users' is whatever table you need to fix.
# http://stackoverflow.com/questions/13670235/after-importing-data-in-postgresql-duplicate-key-value-violates-unique-constrai

ActiveRecord::Base.connection.reset_pk_sequence!('users')
@matthaliski
matthaliski / gist:ab24a670f0b35316d1d7
Last active August 29, 2015 14:02
Testing for admin role using Devise

Create your devise User model

We start by getting devise up and running and generating the User model.

rails generate devise User

Then you'll probably run rake db:migrate and follow their instructions for making sure you have a few default things in order. Okay, so far so good.

Add a role column to Users

@matthaliski
matthaliski / gist:10290892
Last active August 29, 2015 13:58
Click Tags

Basic vanilla clickTag that should work everywhere.

Note: you'll probably end up with IE giving you the butter bar.

function basicClickTag(e:MouseEvent):void { 
	flash.net.navigateToURL( 
		new URLRequest(root.loaderInfo.parameters.clickTAG), '_blank' );
} 
@matthaliski
matthaliski / RailsTesting.md
Last active December 19, 2015 09:49
Rails Testing

Rails Testing

Below are some tools, workarounds, and gotchas to help speed things up when getting testing working.

Capybara


To get tests to run properly you'll need to add a line to spec_helper.rb file.

.
.
@matthaliski
matthaliski / gist:4253339
Last active July 11, 2016 19:35
How to Post to a Google Spreadsheet

How to Post to a Google Spreadsheet

Part 1 - Setting up the Google Document

  • Go to Google Docs and create your spreadsheet
  • Give column names and make note of them as they become the names of your input fields
  • Give the spreadsheet the tab name of "DATA"
  • Click Tools > Script Editor
  • Choose 'Spreadsheet' under 'Create Script for'