Skip to content

Instantly share code, notes, and snippets.

View scaffeinate's full-sized avatar

Sudharsanan Muralidharan scaffeinate

View GitHub Profile
@scaffeinate
scaffeinate / cordova-npm-ios.md
Last active August 29, 2015 14:05
Cordova npm iOS
@scaffeinate
scaffeinate / desktop-build-steps.md
Created August 18, 2014 00:49
Desktop build using node-webkit & grunt-node-webkit-builder

Desktop build using node-webkit & grunt-node-webkit-builder:

First download node-webkit for your platform(Not the target platform, the working machine's platform). With node-webkit we can package static webpages into native applications. This can be done for all three desktop platforms.

https://github.com/rogerwang/node-webkit

After downloading place the static website inside a folder along with a package.json file. This package.json is not to be confused with node packages json file. The package.json is used to define the specifications of the app such as title, width and height. Here is a sample:

# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@scaffeinate
scaffeinate / 20150701024445_devise_create_users.rb
Last active August 29, 2015 14:24
Devise user migration - socify
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
t.string :name, null: false, default: ""
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
t.string :about
t.string :avatar
t.string :cover
@scaffeinate
scaffeinate / _navbar.html.erb
Last active August 29, 2015 14:24
Navbar Socify
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-top">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to "Socify", root_url, class: "navbar-brand" %>
@scaffeinate
scaffeinate / better-nodejs-require-paths.md
Created April 10, 2016 07:41 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@scaffeinate
scaffeinate / Gemfile
Last active May 25, 2016 09:32
rails-shop/Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
@scaffeinate
scaffeinate / create_users.rb
Created June 8, 2016 10:13
Rails 5 API Migration
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :first_name, null: false, default: ''
t.string :last_name, null: false, default: ''
t.string :email, null: false
t.timestamps
end
add_index :users, :email, unique: true
@scaffeinate
scaffeinate / api_v1_users_controller.rb
Last active June 8, 2016 10:48
Api users controller
module Api::V1
class UsersController < ApplicationController
def show
@user = User.find_by(email: params[:email])
render json: @user
end
end
end
@scaffeinate
scaffeinate / api_v1_user_serializer.rb
Last active June 8, 2016 11:16
Rails 5 API user serializer
class Api::V1::UserSerializer < ActiveModel::Serializer
attributes :id, :name, :email
def name
"#{object.first_name} #{object.last_name}"
end
end