Skip to content

Instantly share code, notes, and snippets.

View knicklabs's full-sized avatar
✏️

Nickolas Kenyeres knicklabs

✏️
View GitHub Profile
@knicklabs
knicklabs / gist:3681933
Created September 9, 2012 01:33
Example POST of JSON data to an API
curl -v -H "Content-Type: application/json" -X POST -d '{"title":"Hello World"}' http://localhost:3000/notes
@knicklabs
knicklabs / gist:3625649
Created September 4, 2012 19:52
Unix Permissions
Octal Text Binary Description
=============================================================
0 --- 000 All types of access are denied
1 --x 001 Execute access is allowed only
2 -w- 010 Write access is allowed only
3 -wx 011 Write and execute access are allowed
4 r-- 100 Read access is allowed only
5 r-x 101 Read and execute access are allowed
6 rw- 110 Read and write access are allowed
7 rwx 111 Everything is allowed
@knicklabs
knicklabs / gist:1676568
Created January 25, 2012 14:40
CarrierWave Configuration
# The current configuration for CarrierWave
CarrierWave.configure do |config|
config.storage = :s3
config.s3_access_policy = :public_read
config.s3_access_key_id = S3_CONFIG['access_key_id']
config.s3_secret_access_key = S3_CONFIG['secret_access_key']
config.s3_bucket = S3_CONFIG['bucket']
end
@knicklabs
knicklabs / gist:1594575
Created January 11, 2012 13:07
Model-Level Validations in Play Framework 1.x
// This example was summarized from http://www.playframework.org/documentation/1.2/validation and
// reproduced here for quick reference.
// To achieve model-level validations (versus handling at controller level), first annotate
// the properties of the model.
package models;
public class User {
@knicklabs
knicklabs / os.rb
Created December 19, 2011 14:34
How to get the type of operating system in a ruby script.
require 'rbconfig'
host_os = RbConfig::CONFIG['host_os']
if host_os ~= /mac|darwin/i
# Mac
elsif host_os ~= /bsd/i
# BSD
elsif host_os ~= /solaris|sunos/i
# Solaris
elsif host_os ~= /linux/i
@knicklabs
knicklabs / HTML5 Page
Created January 30, 2011 05:14
A skeleton HTML 5 page
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Your Website</title>
</head>
<body>
@knicklabs
knicklabs / will_paginate.rb
Created January 30, 2011 05:13
How to use the will paginate plugin to paginate items
# Add the Will Paginate plugin to the gemfile
gem 'will_paginate', '3.0.pre2'
# Place this code in the controller
@items = Item.all.paginate(:page => params[:page] || 1, :per_page => 10)
# Place this code in the view
<%= will_paginate @items %>