Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@jrgcubano
jrgcubano / boot.js
Created June 27, 2014 17:42 — forked from jdx/boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@jrgcubano
jrgcubano / Vagrantfile
Created June 30, 2014 07:22
Vagrantfile for jekyll blog
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$jekyll_script = <<SCRIPT
curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0
source /home/vagrant/.rvm/scripts/rvm
gem install bundler
cd /vagrant && bundle install
// articles per page
var limit = 10;
// pagination middleware function sets some
// local view variables that any view can use
function pagination(req, res, next) {
var page = parseInt(req.params.page) || 1,
num = page * limit;
db.articles.count(function(err, total) {
res.local("total", total);
@jrgcubano
jrgcubano / TextBoxMaskBehavior
Created July 24, 2014 13:30
WPF TextBox TextBoxMaskBehavior
sing System;
using System.Windows;
using System.Globalization;
using System.Windows.Controls;
namespace CustomControls
{
#region Documentation Tags
/// <summary>
/// WPF Maskable TextBox class. Just specify the TextBoxMaskBehavior.Mask attached property to a TextBox.
@jrgcubano
jrgcubano / TextBoxMaskBehaviorWithMask
Created July 30, 2014 10:16
WPF TextBox TextBoxMaskBehavior (by smarter DB and me)
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace PMS_UI.CommonControls.Behaviours
{
public enum ValueTypes
{
@jrgcubano
jrgcubano / NumericConverter
Created July 30, 2014 10:18
Numeric Converters from string
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
namespace PMS_UI.CommonControls.Converters
{
public class NumericConverter : IValueConverter
@jrgcubano
jrgcubano / ConverterHelper
Created July 30, 2014 10:19
Converter Helper from string
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace PMS_UI.CommonControls.Converters
{
public static class ConverterHelper
{
@jrgcubano
jrgcubano / EnumExtensions
Created July 30, 2014 11:27
Enum Extensions
public static class EnumExtensions
{
private static void CheckIsEnum<T>(bool withFlags)
{
if (!typeof(T).IsEnum)
throw new ArgumentException(string.Format("Type '{0}' is not an enum", typeof(T).FullName));
if (withFlags && !Attribute.IsDefined(typeof(T), typeof(FlagsAttribute)))
throw new ArgumentException(string.Format("Type '{0}' doesn't have the 'Flags' attribute", typeof(T).FullName));
}
<UserControl x:Class="DTPicker.DateTimePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:IntelliMap.WPF"
xmlns:wpftc="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
mc:Ignorable="d">
<UserControl.Resources>
<ControlTemplate x:Key="IconButton" TargetType="{x:Type ToggleButton}">