Skip to content

Instantly share code, notes, and snippets.

@maxclaus
maxclaus / Get-Json-In-Javascript-From-Model.cshtml
Created April 2, 2013 12:39
Get the json converted from Model to be used on javascript in the View with Razor.
$(function () {
// Get Json ViewModel
var json_response = @Html.Raw(Json.Encode(Model));
});
@maxclaus
maxclaus / Capitalise.cs
Last active December 17, 2015 22:49
Capitalise just the first letter of the whole sentence
private string Capitalise(string str)
{
if(String.IsNullOrEmpty(str))
return string.Empty;
var firstLetter = string.Empty;
if(str.Length > 0)
firstLetter = Char.ToUpper(str[0]);
return (str.Length == 1) ? firstLetter : firstLetter + str.Substring(1).ToLower();
@maxclaus
maxclaus / Install-ZSH-shell-on-Ubuntu.sh
Created May 31, 2013 14:32
Instalar ZSH terminal e Oh My ZSH no Ubuntu
#Instalar ZSH:
sudo apt-get update && sudo apt-get install zsh
#Configurar oh-my-zsh:
wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh
#Tornar ZSH terminal padrão
chsh -s /bin/zsh
#Reinicie o ubuntu.
@maxclaus
maxclaus / Install-nodejs-npm.sh
Created July 31, 2013 23:37
Commands to install nodejs and npm for Linux
sudo apt-get remove nodejs nodejs-dev npm
sudo add-apt-repository ppa:richarvey/nodejs
sudo apt-get update
sudo apt-get install nodejs nodejs-dev npm
nodejs -v #outputs v0.10.13
npm -v #outputs v1.3.3
@maxclaus
maxclaus / fix_import_error_no_module_named_psycopg2.sh
Created August 6, 2013 16:11
How to fix the error: "ImportError: No module named psycopg2"
sudo apt-get build-dep python-psycopg2
pip install psycopg2
@maxclaus
maxclaus / running-locally-rails-server-production.sh
Created August 18, 2013 22:35
How to run rails server locally as production environment
rake db:migrate RAILS_ENV="production"
rails s -e production
(since_became_a_zombie..Float::INFINITY).each { eat :brains, :tasks }
@maxclaus
maxclaus / .gitignore
Created September 25, 2013 20:03
Git keep empty folder: 1. Add a .gitkeep file inside the folder you want to keep 2. Then include this configuration in your .gitignore
path_your_folder/*
!path_your_folder/.gitkeep
mkdir tdd && cd tdd

bundle init

vim Gemfile
# A sample Gemfile
@maxclaus
maxclaus / Ask_Version.cs
Last active December 31, 2015 15:19
Example of Principle Tell don't Ask
private class Screen
{
Form mainForm = ...
private void Screen_Loaded(object sender, ControlLoadedEventArgs e)
{
if(mainForm.InputControls != null && mainForm.InputControls.Contains("Id"))
mainForm.InputControls["Id"].Editable = isEditable;
}
}