Skip to content

Instantly share code, notes, and snippets.

<companies type="array">
<company>
<created-at type="datetime">2013-05-04T18:05:09Z</created-at>
<id type="integer">2</id>
<name>There we go</name>
<updated-at type="datetime">2013-05-04T18:40:45Z</updated-at>
</company>
<company>
<created-at type="datetime">2013-05-04T18:14:23Z</created-at>
<id type="integer">5</id>
# GET /companies/1
# GET /companies/1.json
def show
@company = Company.find(params[:id])
respond_with @company
end
# POST /companies
# POST /companies.json
<div class="field">
<%= f.label :category_id %><br />
<%= f.collection_select :category_id, @categories, :id, :name %>
</div>
# Tasks for managing Unicorn instances of a Rails application.
# Compatible with Ruby >= 1.9.2 and Rails >= 2 .
# Unicorn signals: http://unicorn.bogomips.org/SIGNALS.html
namespace :unicorn do
class UnicornPIDError < StandardError; end
def rails_env
Rails.env
var url = "http://bot.whatismyipaddress.com/";
var request = WebRequest.Create(url);
var res = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(res.GetResponseStream());
string ip = reader.ReadToEnd();
return ip;
ps aux | grep unicorn
kill 39504 <=== replace with master's id
@jmarmolejos
jmarmolejos / GetCardType.cs
Last active January 2, 2016 14:59
Quick port of the function used here to detect the credit card type: http://webstandardssherpa.com/reviews/auto-detecting-credit-card-type
// Quick port of the function used here to detect the credit card type:
// http://webstandardssherpa.com/reviews/auto-detecting-credit-card-type
public static string GetCardType(string Number)
{
//start without knowing the credit card type
var result = "unknown";
//first check for MasterCard
if (Regex.Match(Number, @"^5[1-5]").Success)
public async Task<WhateverYourClientReturns> GetData()
{
var dataClient = new DataAccessLayerClient();
Task<WhateverYourClientReturns> getData = client.GetData();
// Esto de aquí se ejecuta en lo que el hacha va y viene
var form = new Frm_Custom_MessageBox();
form.ShowDialog();
// RaygunErrorHandlerAttribute.cs
using System.Web.Mvc;
using Microsoft.WindowsAzure;
using Mindscape.Raygun4Net;
namespace MyProject.Attributes
{
public class RaygunErrorHandlerAttribute : HandleErrorAttribute
{
public ActionResult GetTokenFromThinkTecture()
{
var form = new FormUrlEncodedContent(
new Dictionary<string, string>
{
{OAuth2Constants.GrantType, OAuth2Constants.Password},
{OAuth2Constants.UserName, "user},
{OAuth2Constants.Password, "password"},
{OAuth2Constants.Scope, "https://localhost:44300/OAuth"}
});